| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_manager.h" | 5 #include "content/browser/devtools/worker_devtools_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // Called on the UI thread. | 25 // Called on the UI thread. |
| 26 // static | 26 // static |
| 27 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker( | 27 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker( |
| 28 int worker_process_id, | 28 int worker_process_id, |
| 29 int worker_route_id) { | 29 int worker_route_id) { |
| 30 return WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 30 return WorkerDevToolsManager::GetDevToolsAgentHostForWorker( |
| 31 worker_process_id, | 31 worker_process_id, |
| 32 worker_route_id); | 32 worker_route_id); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Called on the UI thread. | |
| 36 // static | |
| 37 bool DevToolsAgentHost::HasForWorker( | |
| 38 int worker_process_id, | |
| 39 int worker_route_id) { | |
| 40 return WorkerDevToolsManager::HasDevToolsAgentHostForWorker( | |
| 41 worker_process_id, | |
| 42 worker_route_id); | |
| 43 } | |
| 44 | |
| 45 namespace { | 35 namespace { |
| 46 | 36 |
| 47 typedef std::map<WorkerDevToolsManager::WorkerId, | 37 typedef std::map<WorkerDevToolsManager::WorkerId, |
| 48 WorkerDevToolsManager::WorkerDevToolsAgentHost*> AgentHosts; | 38 WorkerDevToolsManager::WorkerDevToolsAgentHost*> AgentHosts; |
| 49 base::LazyInstance<AgentHosts>::Leaky g_agent_map = LAZY_INSTANCE_INITIALIZER; | 39 base::LazyInstance<AgentHosts>::Leaky g_agent_map = LAZY_INSTANCE_INITIALIZER; |
| 50 base::LazyInstance<AgentHosts>::Leaky g_orphan_map = LAZY_INSTANCE_INITIALIZER; | 40 base::LazyInstance<AgentHosts>::Leaky g_orphan_map = LAZY_INSTANCE_INITIALIZER; |
| 51 | 41 |
| 52 } // namespace | 42 } // namespace |
| 53 | 43 |
| 54 struct WorkerDevToolsManager::TerminatedInspectedWorker { | 44 struct WorkerDevToolsManager::TerminatedInspectedWorker { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DevToolsAgentHost* WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 215 DevToolsAgentHost* WorkerDevToolsManager::GetDevToolsAgentHostForWorker( |
| 226 int worker_process_id, | 216 int worker_process_id, |
| 227 int worker_route_id) { | 217 int worker_route_id) { |
| 228 WorkerId id(worker_process_id, worker_route_id); | 218 WorkerId id(worker_process_id, worker_route_id); |
| 229 AgentHosts::iterator it = g_agent_map.Get().find(id); | 219 AgentHosts::iterator it = g_agent_map.Get().find(id); |
| 230 if (it == g_agent_map.Get().end()) | 220 if (it == g_agent_map.Get().end()) |
| 231 return new WorkerDevToolsAgentHost(id); | 221 return new WorkerDevToolsAgentHost(id); |
| 232 return it->second; | 222 return it->second; |
| 233 } | 223 } |
| 234 | 224 |
| 235 // static | |
| 236 bool WorkerDevToolsManager::HasDevToolsAgentHostForWorker( | |
| 237 int worker_process_id, | |
| 238 int worker_route_id) { | |
| 239 WorkerId id(worker_process_id, worker_route_id); | |
| 240 return g_agent_map.Get().find(id) != g_agent_map.Get().end(); | |
| 241 } | |
| 242 | |
| 243 WorkerDevToolsManager::WorkerDevToolsManager() { | 225 WorkerDevToolsManager::WorkerDevToolsManager() { |
| 244 } | 226 } |
| 245 | 227 |
| 246 WorkerDevToolsManager::~WorkerDevToolsManager() { | 228 WorkerDevToolsManager::~WorkerDevToolsManager() { |
| 247 } | 229 } |
| 248 | 230 |
| 249 void WorkerDevToolsManager::WorkerCreated( | 231 void WorkerDevToolsManager::WorkerCreated( |
| 250 WorkerProcessHost* worker, | 232 WorkerProcessHost* worker, |
| 251 const WorkerProcessHost::WorkerInstance& instance) { | 233 const WorkerProcessHost::WorkerInstance& instance) { |
| 252 for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); | 234 for (TerminatedInspectedWorkers::iterator it = terminated_workers_.begin(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); | 438 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); |
| 457 } | 439 } |
| 458 | 440 |
| 459 WorkerDevToolsManager::WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { | 441 WorkerDevToolsManager::WorkerDevToolsAgentHost::~WorkerDevToolsAgentHost() { |
| 460 DetachedClientHosts::RemovePendingWorkerData(worker_id_); | 442 DetachedClientHosts::RemovePendingWorkerData(worker_id_); |
| 461 g_agent_map.Get().erase(worker_id_); | 443 g_agent_map.Get().erase(worker_id_); |
| 462 g_orphan_map.Get().erase(worker_id_); | 444 g_orphan_map.Get().erase(worker_id_); |
| 463 } | 445 } |
| 464 | 446 |
| 465 } // namespace content | 447 } // namespace content |
| OLD | NEW |