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

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

Issue 2933243002: [DevTools] Make DevToolsSession own it's DevToolsMessageChunkProcessor (Closed)
Patch Set: addressed comments Created 3 years, 6 months 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
« no previous file with comments | « content/browser/devtools/worker_devtools_agent_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/worker_devtools_agent_host.h" 5 #include "content/browser/devtools/worker_devtools_agent_host.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "content/browser/devtools/devtools_session.h" 9 #include "content/browser/devtools/devtools_session.h"
10 #include "content/browser/devtools/protocol/inspector_handler.h" 10 #include "content/browser/devtools/protocol/inspector_handler.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 int call_id = 0; 58 int call_id = 0;
59 std::string method; 59 std::string method;
60 if (session->Dispatch(message, &call_id, &method) != 60 if (session->Dispatch(message, &call_id, &method) !=
61 protocol::Response::kFallThrough) { 61 protocol::Response::kFallThrough) {
62 return true; 62 return true;
63 } 63 }
64 64
65 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { 65 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) {
66 host->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend( 66 host->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(
67 worker_id_.second, session->session_id(), call_id, method, message)); 67 worker_id_.second, session->session_id(), call_id, method, message));
68 session->waiting_messages()[call_id] = {method, message};
68 } 69 }
69 return true; 70 return true;
70 } 71 }
71 72
72 bool WorkerDevToolsAgentHost::OnMessageReceived( 73 bool WorkerDevToolsAgentHost::OnMessageReceived(
73 const IPC::Message& msg) { 74 const IPC::Message& msg) {
74 DCHECK_CURRENTLY_ON(BrowserThread::UI); 75 DCHECK_CURRENTLY_ON(BrowserThread::UI);
75 bool handled = true; 76 bool handled = true;
76 IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgentHost, msg) 77 IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgentHost, msg)
77 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, 78 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend,
(...skipping 17 matching lines...) Expand all
95 return state_ == WORKER_INSPECTED || state_ == WORKER_UNINSPECTED || 96 return state_ == WORKER_INSPECTED || state_ == WORKER_UNINSPECTED ||
96 state_ == WORKER_READY_FOR_DEBUG_ON_START; 97 state_ == WORKER_READY_FOR_DEBUG_ON_START;
97 } 98 }
98 99
99 void WorkerDevToolsAgentHost::WorkerReadyForInspection() { 100 void WorkerDevToolsAgentHost::WorkerReadyForInspection() {
100 if (state_ == WORKER_PAUSED_FOR_REATTACH) { 101 if (state_ == WORKER_PAUSED_FOR_REATTACH) {
101 DCHECK(IsAttached()); 102 DCHECK(IsAttached());
102 state_ = WORKER_INSPECTED; 103 state_ = WORKER_INSPECTED;
103 AttachToWorker(); 104 AttachToWorker();
104 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) { 105 if (RenderProcessHost* host = RenderProcessHost::FromID(worker_id_.first)) {
105 host->Send(new DevToolsAgentMsg_Reattach( 106 host->Send(new DevToolsAgentMsg_Reattach(worker_id_.second, GetId(),
106 worker_id_.second, GetId(), session()->session_id(), 107 session()->session_id(),
107 chunk_processor_.state_cookie())); 108 session()->state_cookie()));
109 for (const auto& pair : session()->waiting_messages()) {
110 int call_id = pair.first;
111 const DevToolsSession::Message& message = pair.second;
112 host->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend(
113 worker_id_.second, session()->session_id(), call_id, message.method,
114 message.message));
115 }
108 } 116 }
109 OnAttachedStateChanged(true); 117 OnAttachedStateChanged(true);
110 } else if (state_ == WORKER_PAUSED_FOR_DEBUG_ON_START) { 118 } else if (state_ == WORKER_PAUSED_FOR_DEBUG_ON_START) {
111 state_ = WORKER_READY_FOR_DEBUG_ON_START; 119 state_ = WORKER_READY_FOR_DEBUG_ON_START;
112 } 120 }
113 } 121 }
114 122
115 void WorkerDevToolsAgentHost::WorkerRestarted(WorkerId worker_id) { 123 void WorkerDevToolsAgentHost::WorkerRestarted(WorkerId worker_id) {
116 DCHECK_EQ(WORKER_TERMINATED, state_); 124 DCHECK_EQ(WORKER_TERMINATED, state_);
117 state_ = IsAttached() ? WORKER_PAUSED_FOR_REATTACH : WORKER_UNINSPECTED; 125 state_ = IsAttached() ? WORKER_PAUSED_FOR_REATTACH : WORKER_UNINSPECTED;
(...skipping 12 matching lines...) Expand all
130 state_ = WORKER_TERMINATED; 138 state_ = WORKER_TERMINATED;
131 Release(); // Balanced in WorkerCreated(). 139 Release(); // Balanced in WorkerCreated().
132 } 140 }
133 141
134 bool WorkerDevToolsAgentHost::IsTerminated() { 142 bool WorkerDevToolsAgentHost::IsTerminated() {
135 return state_ == WORKER_TERMINATED; 143 return state_ == WORKER_TERMINATED;
136 } 144 }
137 145
138 WorkerDevToolsAgentHost::WorkerDevToolsAgentHost(WorkerId worker_id) 146 WorkerDevToolsAgentHost::WorkerDevToolsAgentHost(WorkerId worker_id)
139 : DevToolsAgentHostImpl(base::GenerateGUID()), 147 : DevToolsAgentHostImpl(base::GenerateGUID()),
140 chunk_processor_(base::Bind(&WorkerDevToolsAgentHost::SendMessageToClient,
141 base::Unretained(this))),
142 state_(WORKER_UNINSPECTED), 148 state_(WORKER_UNINSPECTED),
143 worker_id_(worker_id) { 149 worker_id_(worker_id) {
144 WorkerCreated(); 150 WorkerCreated();
145 } 151 }
146 152
147 WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { 153 WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() {
148 DCHECK_EQ(WORKER_TERMINATED, state_); 154 DCHECK_EQ(WORKER_TERMINATED, state_);
149 } 155 }
150 156
151 void WorkerDevToolsAgentHost::OnAttachedStateChanged(bool attached) { 157 void WorkerDevToolsAgentHost::OnAttachedStateChanged(bool attached) {
(...skipping 10 matching lines...) Expand all
162 } 168 }
163 169
164 void WorkerDevToolsAgentHost::WorkerCreated() { 170 void WorkerDevToolsAgentHost::WorkerCreated() {
165 AddRef(); // Balanced in WorkerDestroyed() 171 AddRef(); // Balanced in WorkerDestroyed()
166 } 172 }
167 173
168 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( 174 void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend(
169 const DevToolsMessageChunk& message) { 175 const DevToolsMessageChunk& message) {
170 if (!IsAttached()) 176 if (!IsAttached())
171 return; 177 return;
172 178 session()->ReceiveMessageChunk(message);
173 chunk_processor_.ProcessChunkedMessageFromAgent(message);
174 } 179 }
175 180
176 } // namespace content 181 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/worker_devtools_agent_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698