[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / devtools / browser_devtools_agent_host.cc
blobaefdc1486f0072708704028839b308a8d00af183
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/devtools/browser_devtools_agent_host.h"
7 #include "base/bind.h"
8 #include "content/browser/devtools/devtools_protocol_handler.h"
9 #include "content/browser/devtools/protocol/io_handler.h"
10 #include "content/browser/devtools/protocol/system_info_handler.h"
11 #include "content/browser/devtools/protocol/tethering_handler.h"
12 #include "content/browser/devtools/protocol/tracing_handler.h"
14 namespace content {
16 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::CreateForBrowser(
17 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
18 const CreateServerSocketCallback& socket_callback) {
19 return new BrowserDevToolsAgentHost(tethering_task_runner, socket_callback);
22 BrowserDevToolsAgentHost::BrowserDevToolsAgentHost(
23 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
24 const CreateServerSocketCallback& socket_callback)
25 : io_handler_(new devtools::io::IOHandler(GetIOContext())),
26 system_info_handler_(new devtools::system_info::SystemInfoHandler()),
27 tethering_handler_(
28 new devtools::tethering::TetheringHandler(socket_callback,
29 tethering_task_runner)),
30 tracing_handler_(new devtools::tracing::TracingHandler(
31 devtools::tracing::TracingHandler::Browser, GetIOContext())),
32 protocol_handler_(new DevToolsProtocolHandler(
33 this,
34 base::Bind(&BrowserDevToolsAgentHost::SendMessageToClient,
35 base::Unretained(this)))) {
36 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher();
37 dispatcher->SetIOHandler(io_handler_.get());
38 dispatcher->SetSystemInfoHandler(system_info_handler_.get());
39 dispatcher->SetTetheringHandler(tethering_handler_.get());
40 dispatcher->SetTracingHandler(tracing_handler_.get());
43 BrowserDevToolsAgentHost::~BrowserDevToolsAgentHost() {
46 void BrowserDevToolsAgentHost::Attach() {
49 void BrowserDevToolsAgentHost::Detach() {
52 DevToolsAgentHost::Type BrowserDevToolsAgentHost::GetType() {
53 return TYPE_BROWSER;
56 std::string BrowserDevToolsAgentHost::GetTitle() {
57 return "";
60 GURL BrowserDevToolsAgentHost::GetURL() {
61 return GURL();
64 bool BrowserDevToolsAgentHost::Activate() {
65 return false;
68 bool BrowserDevToolsAgentHost::Close() {
69 return false;
72 bool BrowserDevToolsAgentHost::DispatchProtocolMessage(
73 const std::string& message) {
74 protocol_handler_->HandleMessage(message);
75 return true;
78 } // content