-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathsync_websocket_factory.cc
41 lines (33 loc) · 1.42 KB
/
sync_websocket_factory.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/test/chromedriver/net/sync_websocket_factory.h"
#include <memory>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "chrome/test/chromedriver/log_replay/log_replay_socket.h"
#include "chrome/test/chromedriver/net/sync_websocket_impl.h"
#include "chrome/test/chromedriver/net/url_request_context_getter.h"
namespace {
std::unique_ptr<SyncWebSocket> CreateSyncWebSocket(
scoped_refptr<URLRequestContextGetter> context_getter) {
return std::unique_ptr<SyncWebSocket>(
new SyncWebSocketImpl(context_getter.get()));
}
std::unique_ptr<SyncWebSocket> CreateReplayWebSocket(base::FilePath log_path) {
return std::make_unique<LogReplaySocket>(log_path);
}
} // namespace
SyncWebSocketFactory CreateSyncWebSocketFactory(
URLRequestContextGetter* getter) {
const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch("devtools-replay")) {
base::CommandLine::StringType log_path_str =
cmd_line->GetSwitchValueNative("devtools-replay");
base::FilePath log_path(log_path_str);
return base::BindRepeating(&CreateReplayWebSocket, log_path);
}
return base::BindRepeating(&CreateSyncWebSocket,
base::WrapRefCounted(getter));
}