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

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

Issue 577923002: [DevTools] Implement DevToolsManager::Observer which notifies about target updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-enumerate-to-dtm-delegate
Patch Set: fixed test flakiness Created 6 years, 2 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
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/embedded_worker_devtools_manager.h" 5 #include "content/browser/devtools/embedded_worker_devtools_manager.h"
6 6
7 #include "content/browser/devtools/devtools_manager.h"
7 #include "content/browser/devtools/devtools_protocol.h" 8 #include "content/browser/devtools/devtools_protocol.h"
8 #include "content/browser/devtools/devtools_protocol_constants.h" 9 #include "content/browser/devtools/devtools_protocol_constants.h"
9 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h" 10 #include "content/browser/devtools/embedded_worker_devtools_agent_host.h"
10 #include "content/browser/devtools/ipc_devtools_agent_host.h" 11 #include "content/browser/devtools/ipc_devtools_agent_host.h"
11 #include "content/browser/shared_worker/shared_worker_instance.h" 12 #include "content/browser/shared_worker/shared_worker_instance.h"
12 #include "content/common/devtools_messages.h" 13 #include "content/common/devtools_messages.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/worker_service.h" 16 #include "content/public/browser/worker_service.h"
16 #include "ipc/ipc_listener.h" 17 #include "ipc/ipc_listener.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 bool EmbeddedWorkerDevToolsManager::SharedWorkerCreated( 99 bool EmbeddedWorkerDevToolsManager::SharedWorkerCreated(
99 int worker_process_id, 100 int worker_process_id,
100 int worker_route_id, 101 int worker_route_id,
101 const SharedWorkerInstance& instance) { 102 const SharedWorkerInstance& instance) {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
103 const WorkerId id(worker_process_id, worker_route_id); 104 const WorkerId id(worker_process_id, worker_route_id);
104 AgentHostMap::iterator it = FindExistingSharedWorkerAgentHost(instance); 105 AgentHostMap::iterator it = FindExistingSharedWorkerAgentHost(instance);
105 if (it == workers_.end()) { 106 if (it == workers_.end()) {
106 workers_[id] = new EmbeddedWorkerDevToolsAgentHost(id, instance); 107 workers_[id] = new EmbeddedWorkerDevToolsAgentHost(id, instance);
108 DevToolsManager::GetInstance()->AgentHostChanged(workers_[id]);
107 return false; 109 return false;
108 } 110 }
109 WorkerRestarted(id, it); 111 WorkerRestarted(id, it);
110 return true; 112 return true;
111 } 113 }
112 114
113 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated( 115 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated(
114 int worker_process_id, 116 int worker_process_id,
115 int worker_route_id, 117 int worker_route_id,
116 const ServiceWorkerIdentifier& service_worker_id) { 118 const ServiceWorkerIdentifier& service_worker_id) {
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
118 const WorkerId id(worker_process_id, worker_route_id); 120 const WorkerId id(worker_process_id, worker_route_id);
119 AgentHostMap::iterator it = 121 AgentHostMap::iterator it =
120 FindExistingServiceWorkerAgentHost(service_worker_id); 122 FindExistingServiceWorkerAgentHost(service_worker_id);
121 if (it == workers_.end()) { 123 if (it == workers_.end()) {
122 workers_[id] = new EmbeddedWorkerDevToolsAgentHost( 124 workers_[id] = new EmbeddedWorkerDevToolsAgentHost(
123 id, service_worker_id, debug_service_worker_on_start_); 125 id, service_worker_id, debug_service_worker_on_start_);
126 DevToolsManager::GetInstance()->AgentHostChanged(workers_[id]);
124 return debug_service_worker_on_start_; 127 return debug_service_worker_on_start_;
125 } 128 }
126 WorkerRestarted(id, it); 129 WorkerRestarted(id, it);
127 return true; 130 return true;
128 } 131 }
129 132
130 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, 133 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id,
131 int worker_route_id) { 134 int worker_route_id) {
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
133 const WorkerId id(worker_process_id, worker_route_id); 136 const WorkerId id(worker_process_id, worker_route_id);
134 AgentHostMap::iterator it = workers_.find(id); 137 AgentHostMap::iterator it = workers_.find(id);
135 DCHECK(it != workers_.end()); 138 DCHECK(it != workers_.end());
136 it->second->WorkerDestroyed(); 139 scoped_refptr<EmbeddedWorkerDevToolsAgentHost> agent_host(it->second);
140 agent_host->WorkerDestroyed();
141 DevToolsManager::GetInstance()->AgentHostChanged(agent_host);
137 } 142 }
138 143
139 void EmbeddedWorkerDevToolsManager::WorkerReadyForInspection( 144 void EmbeddedWorkerDevToolsManager::WorkerReadyForInspection(
140 int worker_process_id, 145 int worker_process_id,
141 int worker_route_id) { 146 int worker_route_id) {
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
143 const WorkerId id(worker_process_id, worker_route_id); 148 const WorkerId id(worker_process_id, worker_route_id);
144 AgentHostMap::iterator it = workers_.find(id); 149 AgentHostMap::iterator it = workers_.find(id);
145 DCHECK(it != workers_.end()); 150 DCHECK(it != workers_.end());
146 it->second->WorkerReadyForInspection(); 151 it->second->WorkerReadyForInspection();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return result; 199 return result;
195 } 200 }
196 201
197 void EmbeddedWorkerDevToolsManager::WorkerRestarted( 202 void EmbeddedWorkerDevToolsManager::WorkerRestarted(
198 const WorkerId& id, 203 const WorkerId& id,
199 const AgentHostMap::iterator& it) { 204 const AgentHostMap::iterator& it) {
200 EmbeddedWorkerDevToolsAgentHost* agent_host = it->second; 205 EmbeddedWorkerDevToolsAgentHost* agent_host = it->second;
201 agent_host->WorkerRestarted(id); 206 agent_host->WorkerRestarted(id);
202 workers_.erase(it); 207 workers_.erase(it);
203 workers_[id] = agent_host; 208 workers_[id] = agent_host;
209 DevToolsManager::GetInstance()->AgentHostChanged(agent_host);
204 } 210 }
205 211
206 void EmbeddedWorkerDevToolsManager::ResetForTesting() { 212 void EmbeddedWorkerDevToolsManager::ResetForTesting() {
207 workers_.clear(); 213 workers_.clear();
208 } 214 }
209 215
210 } // namespace content 216 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_manager_unittest.cc ('k') | content/browser/devtools/render_view_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698