ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / browser / devtools / worker_devtools_manager.cc
blobad21c9ac973c5fb2524de0fc5587a9d7c3c535e2
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
3 // found in the LICENSE file.
5 #include "content/browser/devtools/worker_devtools_manager.h"
7 #include "content/browser/devtools/devtools_manager.h"
8 #include "content/browser/devtools/service_worker_devtools_manager.h"
9 #include "content/browser/devtools/shared_worker_devtools_manager.h"
10 #include "content/browser/devtools/worker_devtools_agent_host.h"
11 #include "content/public/browser/browser_thread.h"
13 namespace content {
15 // Called on the UI thread.
16 // static
17 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker(
18 int worker_process_id,
19 int worker_route_id) {
20 if (scoped_refptr<DevToolsAgentHost> host =
21 SharedWorkerDevToolsManager::GetInstance()
22 ->GetDevToolsAgentHostForWorker(worker_process_id, worker_route_id)) {
23 return host;
25 return ServiceWorkerDevToolsManager::GetInstance()
26 ->GetDevToolsAgentHostForWorker(worker_process_id, worker_route_id);
29 DevToolsAgentHostImpl*
30 WorkerDevToolsManager::GetDevToolsAgentHostForWorker(int worker_process_id,
31 int worker_route_id) {
32 AgentHostMap::iterator it = workers_.find(
33 WorkerId(worker_process_id, worker_route_id));
34 return it == workers_.end() ? NULL : it->second;
37 void WorkerDevToolsManager::AddAllAgentHosts(DevToolsAgentHost::List* result) {
38 for (auto& worker : workers_) {
39 if (!worker.second->IsTerminated())
40 result->push_back(worker.second);
44 void WorkerDevToolsManager::WorkerDestroyed(int worker_process_id,
45 int worker_route_id) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 const WorkerId id(worker_process_id, worker_route_id);
48 AgentHostMap::iterator it = workers_.find(id);
49 DCHECK(it != workers_.end());
50 scoped_refptr<WorkerDevToolsAgentHost> agent_host(it->second);
51 agent_host->WorkerDestroyed();
52 DevToolsManager::GetInstance()->AgentHostChanged(agent_host);
55 void WorkerDevToolsManager::WorkerReadyForInspection(int worker_process_id,
56 int worker_route_id) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 const WorkerId id(worker_process_id, worker_route_id);
59 AgentHostMap::iterator it = workers_.find(id);
60 DCHECK(it != workers_.end());
61 it->second->WorkerReadyForInspection();
64 WorkerDevToolsManager::WorkerDevToolsManager() {
67 WorkerDevToolsManager::~WorkerDevToolsManager() {
70 void WorkerDevToolsManager::RemoveInspectedWorkerData(WorkerId id) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 workers_.erase(id);
75 void WorkerDevToolsManager::WorkerRestarted(const WorkerId& id,
76 const AgentHostMap::iterator& it) {
77 WorkerDevToolsAgentHost* agent_host = it->second;
78 agent_host->WorkerRestarted(id);
79 workers_.erase(it);
80 workers_[id] = agent_host;
81 DevToolsManager::GetInstance()->AgentHostChanged(agent_host);
84 } // namespace content