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

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

Issue 2500093002: [DevTools] Move IO and Tracing to new generator. (Closed)
Patch Set: works Created 4 years, 1 month 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/json/json_reader.h"
8 #include "base/guid.h" 9 #include "base/guid.h"
9 #include "content/browser/devtools/devtools_protocol_handler.h" 10 #include "content/browser/devtools/devtools_protocol_handler.h"
10 #include "content/browser/devtools/protocol/io_handler.h" 11 #include "content/browser/devtools/protocol/io_handler.h"
11 #include "content/browser/devtools/protocol/memory_handler.h" 12 #include "content/browser/devtools/protocol/memory_handler.h"
13 #include "content/browser/devtools/protocol/protocol.h"
12 #include "content/browser/devtools/protocol/system_info_handler.h" 14 #include "content/browser/devtools/protocol/system_info_handler.h"
13 #include "content/browser/devtools/protocol/tethering_handler.h" 15 #include "content/browser/devtools/protocol/tethering_handler.h"
14 #include "content/browser/devtools/protocol/tracing_handler.h" 16 #include "content/browser/devtools/protocol/tracing_handler.h"
15 #include "content/browser/frame_host/frame_tree_node.h" 17 #include "content/browser/frame_host/frame_tree_node.h"
16 18
17 namespace content { 19 namespace content {
18 20
19 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::CreateForBrowser( 21 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::CreateForBrowser(
20 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner, 22 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
21 const CreateServerSocketCallback& socket_callback) { 23 const CreateServerSocketCallback& socket_callback) {
22 return new BrowserDevToolsAgentHost(tethering_task_runner, socket_callback); 24 return new BrowserDevToolsAgentHost(tethering_task_runner, socket_callback);
23 } 25 }
24 26
25 BrowserDevToolsAgentHost::BrowserDevToolsAgentHost( 27 BrowserDevToolsAgentHost::BrowserDevToolsAgentHost(
26 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> tethering_task_runner,
27 const CreateServerSocketCallback& socket_callback) 29 const CreateServerSocketCallback& socket_callback)
28 : DevToolsAgentHostImpl(base::GenerateGUID()), 30 : DevToolsAgentHostImpl(base::GenerateGUID()),
29 io_handler_(new devtools::io::IOHandler(GetIOContext())), 31 io_handler_(new protocol::IOHandler(GetIOContext())),
30 memory_handler_(new devtools::memory::MemoryHandler()), 32 memory_handler_(new devtools::memory::MemoryHandler()),
31 system_info_handler_(new devtools::system_info::SystemInfoHandler()), 33 system_info_handler_(new devtools::system_info::SystemInfoHandler()),
32 tethering_handler_( 34 tethering_handler_(
33 new devtools::tethering::TetheringHandler(socket_callback, 35 new devtools::tethering::TetheringHandler(socket_callback,
34 tethering_task_runner)), 36 tethering_task_runner)),
35 tracing_handler_(new devtools::tracing::TracingHandler( 37 tracing_handler_(new protocol::TracingHandler(
36 devtools::tracing::TracingHandler::Browser, 38 protocol::TracingHandler::Browser,
37 FrameTreeNode::kFrameTreeNodeInvalidId, 39 FrameTreeNode::kFrameTreeNodeInvalidId,
38 GetIOContext())), 40 GetIOContext())),
39 protocol_handler_(new DevToolsProtocolHandler(this)) { 41 protocol_handler_(new DevToolsProtocolHandler(this)),
42 protocol_dispatcher_(new protocol::UberDispatcher(this, true)) {
40 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher(); 43 DevToolsProtocolDispatcher* dispatcher = protocol_handler_->dispatcher();
41 dispatcher->SetIOHandler(io_handler_.get()); 44 io_handler_->Wire(protocol_dispatcher_.get());
42 dispatcher->SetMemoryHandler(memory_handler_.get()); 45 dispatcher->SetMemoryHandler(memory_handler_.get());
43 dispatcher->SetSystemInfoHandler(system_info_handler_.get()); 46 dispatcher->SetSystemInfoHandler(system_info_handler_.get());
44 dispatcher->SetTetheringHandler(tethering_handler_.get()); 47 dispatcher->SetTetheringHandler(tethering_handler_.get());
45 dispatcher->SetTracingHandler(tracing_handler_.get()); 48 tracing_handler_->Wire(protocol_dispatcher_.get());
46 NotifyCreated(); 49 NotifyCreated();
47 } 50 }
48 51
49 BrowserDevToolsAgentHost::~BrowserDevToolsAgentHost() { 52 BrowserDevToolsAgentHost::~BrowserDevToolsAgentHost() {
50 } 53 }
51 54
52 void BrowserDevToolsAgentHost::Attach() { 55 void BrowserDevToolsAgentHost::Attach() {
53 } 56 }
54 57
55 void BrowserDevToolsAgentHost::Detach() { 58 void BrowserDevToolsAgentHost::Detach() {
(...skipping 17 matching lines...) Expand all
73 76
74 bool BrowserDevToolsAgentHost::Close() { 77 bool BrowserDevToolsAgentHost::Close() {
75 return false; 78 return false;
76 } 79 }
77 80
78 void BrowserDevToolsAgentHost::Reload() { 81 void BrowserDevToolsAgentHost::Reload() {
79 } 82 }
80 83
81 bool BrowserDevToolsAgentHost::DispatchProtocolMessage( 84 bool BrowserDevToolsAgentHost::DispatchProtocolMessage(
82 const std::string& message) { 85 const std::string& message) {
83 protocol_handler_->HandleMessage(session_id(), message); 86 std::unique_ptr<base::Value> value = base::JSONReader::Read(message);
87 if (protocol_dispatcher_->dispatch(
88 protocol::toProtocolValue(value.get(), 1000)) ==
89 protocol::Response::kFallThrough) {
90 protocol_handler_->HandleMessage(session_id(), std::move(value));
91 }
84 return true; 92 return true;
85 } 93 }
86 94
87 } // content 95 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698