Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: content/browser/devtools/browser_devtools_agent_host.cc

Issue 2515613006: [DevTools] Move Memory, SystemInfo and Tethering domains to new generator. (Closed)
Patch Set: fixed review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/browser_devtools_agent_host.h" 5 #include "content/browser/devtools/browser_devtools_agent_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "content/browser/devtools/devtools_protocol_handler.h"
11 #include "content/browser/devtools/devtools_session.h" 10 #include "content/browser/devtools/devtools_session.h"
12 #include "content/browser/devtools/protocol/io_handler.h" 11 #include "content/browser/devtools/protocol/io_handler.h"
13 #include "content/browser/devtools/protocol/memory_handler.h" 12 #include "content/browser/devtools/protocol/memory_handler.h"
14 #include "content/browser/devtools/protocol/protocol.h" 13 #include "content/browser/devtools/protocol/protocol.h"
15 #include "content/browser/devtools/protocol/system_info_handler.h" 14 #include "content/browser/devtools/protocol/system_info_handler.h"
16 #include "content/browser/devtools/protocol/tethering_handler.h" 15 #include "content/browser/devtools/protocol/tethering_handler.h"
17 #include "content/browser/devtools/protocol/tracing_handler.h" 16 #include "content/browser/devtools/protocol/tracing_handler.h"
18 #include "content/browser/frame_host/frame_tree_node.h" 17 #include "content/browser/frame_host/frame_tree_node.h"
19 18
20 namespace content { 19 namespace content {
21 20
22 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::CreateForBrowser( 21 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::CreateForBrowser(
23 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner, 22 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
24 const CreateServerSocketCallback& socket_callback) { 23 const CreateServerSocketCallback& socket_callback) {
25 return new BrowserDevToolsAgentHost(tethering_task_runner, socket_callback); 24 return new BrowserDevToolsAgentHost(tethering_task_runner, socket_callback);
26 } 25 }
27 26
28 BrowserDevToolsAgentHost::BrowserDevToolsAgentHost( 27 BrowserDevToolsAgentHost::BrowserDevToolsAgentHost(
29 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
30 const CreateServerSocketCallback& socket_callback) 29 const CreateServerSocketCallback& socket_callback)
31 : DevToolsAgentHostImpl(base::GenerateGUID()), 30 : DevToolsAgentHostImpl(base::GenerateGUID()),
32 memory_handler_(new devtools::memory::MemoryHandler()), 31 tethering_task_runner_(tethering_task_runner),
33 system_info_handler_(new devtools::system_info::SystemInfoHandler()), 32 socket_callback_(socket_callback) {
34 tethering_handler_(
35 new devtools::tethering::TetheringHandler(socket_callback,
36 tethering_task_runner)),
37 protocol_handler_(new DevToolsProtocolHandler(this)) {
38 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher();
39 dispatcher->SetMemoryHandler(memory_handler_.get());
40 dispatcher->SetSystemInfoHandler(system_info_handler_.get());
41 dispatcher->SetTetheringHandler(tethering_handler_.get());
42 NotifyCreated(); 33 NotifyCreated();
43 } 34 }
44 35
45 BrowserDevToolsAgentHost::~BrowserDevToolsAgentHost() { 36 BrowserDevToolsAgentHost::~BrowserDevToolsAgentHost() {
46 } 37 }
47 38
48 void BrowserDevToolsAgentHost::Attach() { 39 void BrowserDevToolsAgentHost::Attach() {
49 session()->dispatcher()->setFallThroughForNotFound(true);
50 io_handler_.reset(new protocol::IOHandler(GetIOContext())); 40 io_handler_.reset(new protocol::IOHandler(GetIOContext()));
51 io_handler_->Wire(session()->dispatcher()); 41 io_handler_->Wire(session()->dispatcher());
52 42
43 memory_handler_.reset(new protocol::MemoryHandler());
44 memory_handler_->Wire(session()->dispatcher());
45
46 system_info_handler_.reset(new protocol::SystemInfoHandler());
47 system_info_handler_->Wire(session()->dispatcher());
48
49 tethering_handler_.reset(new protocol::TetheringHandler(
50 socket_callback_, tethering_task_runner_));
51 tethering_handler_->Wire(session()->dispatcher());
52
53 tracing_handler_.reset(new protocol::TracingHandler( 53 tracing_handler_.reset(new protocol::TracingHandler(
54 protocol::TracingHandler::Browser, 54 protocol::TracingHandler::Browser,
55 FrameTreeNode::kFrameTreeNodeInvalidId, 55 FrameTreeNode::kFrameTreeNodeInvalidId,
56 GetIOContext())); 56 GetIOContext()));
57 tracing_handler_->Wire(session()->dispatcher()); 57 tracing_handler_->Wire(session()->dispatcher());
58 } 58 }
59 59
60 void BrowserDevToolsAgentHost::Detach() { 60 void BrowserDevToolsAgentHost::Detach() {
61 io_handler_.reset(); 61 io_handler_.reset();
62 memory_handler_.reset();
63 system_info_handler_.reset();
64 tethering_handler_.reset();
62 tracing_handler_.reset(); 65 tracing_handler_.reset();
63 } 66 }
64 67
65 std::string BrowserDevToolsAgentHost::GetType() { 68 std::string BrowserDevToolsAgentHost::GetType() {
66 return kTypeBrowser; 69 return kTypeBrowser;
67 } 70 }
68 71
69 std::string BrowserDevToolsAgentHost::GetTitle() { 72 std::string BrowserDevToolsAgentHost::GetTitle() {
70 return ""; 73 return "";
71 } 74 }
72 75
73 GURL BrowserDevToolsAgentHost::GetURL() { 76 GURL BrowserDevToolsAgentHost::GetURL() {
74 return GURL(); 77 return GURL();
75 } 78 }
76 79
77 bool BrowserDevToolsAgentHost::Activate() { 80 bool BrowserDevToolsAgentHost::Activate() {
78 return false; 81 return false;
79 } 82 }
80 83
81 bool BrowserDevToolsAgentHost::Close() { 84 bool BrowserDevToolsAgentHost::Close() {
82 return false; 85 return false;
83 } 86 }
84 87
85 void BrowserDevToolsAgentHost::Reload() { 88 void BrowserDevToolsAgentHost::Reload() {
86 } 89 }
87 90
88 bool BrowserDevToolsAgentHost::DispatchProtocolMessage( 91 bool BrowserDevToolsAgentHost::DispatchProtocolMessage(
89 const std::string& message) { 92 const std::string& message) {
90 std::unique_ptr<base::Value> value = base::JSONReader::Read(message); 93 session()->dispatcher()->dispatch(protocol::StringUtil::parseJSON(message));
91 std::unique_ptr<protocol::Value> protocolValue =
92 protocol::toProtocolValue(value.get(), 1000);
93 if (session()->dispatcher()->dispatch(std::move(protocolValue)) ==
94 protocol::Response::kFallThrough) {
95 protocol_handler_->HandleMessage(session()->session_id(), std::move(value));
96 }
97 return true; 94 return true;
98 } 95 }
99 96
100 } // content 97 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698