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" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "content/browser/devtools/devtools_agent_host_impl.h" | |
13 #include "content/browser/devtools/devtools_manager_impl.h" | 12 #include "content/browser/devtools/devtools_manager_impl.h" |
| 13 #include "content/browser/devtools/ipc_devtools_agent_host.h" |
14 #include "content/browser/devtools/worker_devtools_message_filter.h" | 14 #include "content/browser/devtools/worker_devtools_message_filter.h" |
15 #include "content/browser/worker_host/worker_service_impl.h" | 15 #include "content/browser/worker_host/worker_service_impl.h" |
16 #include "content/common/devtools_messages.h" | 16 #include "content/common/devtools_messages.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
19 #include "content/public/common/process_type.h" | 19 #include "content/public/common/process_type.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
23 | 23 |
(...skipping 25 matching lines...) Expand all Loading... |
49 : old_worker_id(id), | 49 : old_worker_id(id), |
50 worker_url(url), | 50 worker_url(url), |
51 worker_name(name) {} | 51 worker_name(name) {} |
52 WorkerId old_worker_id; | 52 WorkerId old_worker_id; |
53 GURL worker_url; | 53 GURL worker_url; |
54 string16 worker_name; | 54 string16 worker_name; |
55 }; | 55 }; |
56 | 56 |
57 | 57 |
58 class WorkerDevToolsManager::WorkerDevToolsAgentHost | 58 class WorkerDevToolsManager::WorkerDevToolsAgentHost |
59 : public DevToolsAgentHostImpl { | 59 : public IPCDevToolsAgentHost { |
60 public: | 60 public: |
61 explicit WorkerDevToolsAgentHost(WorkerId worker_id) | 61 explicit WorkerDevToolsAgentHost(WorkerId worker_id) |
62 : has_worker_id_(false) { | 62 : has_worker_id_(false) { |
63 SetWorkerId(worker_id, false); | 63 SetWorkerId(worker_id, false); |
64 AddRef(); // Balanced in ResetWorkerId. | 64 AddRef(); // Balanced in ResetWorkerId. |
65 } | 65 } |
66 | 66 |
67 void SetWorkerId(WorkerId worker_id, bool reattach) { | 67 void SetWorkerId(WorkerId worker_id, bool reattach) { |
68 worker_id_ = worker_id; | 68 worker_id_ = worker_id; |
69 has_worker_id_ = true; | 69 has_worker_id_ = true; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 static void ForwardToWorkerDevToolsAgent( | 112 static void ForwardToWorkerDevToolsAgent( |
113 int worker_process_id, | 113 int worker_process_id, |
114 int worker_route_id, | 114 int worker_route_id, |
115 IPC::Message* message) { | 115 IPC::Message* message) { |
116 WorkerDevToolsManager::GetInstance()->ForwardToWorkerDevToolsAgent( | 116 WorkerDevToolsManager::GetInstance()->ForwardToWorkerDevToolsAgent( |
117 worker_process_id, worker_route_id, *message); | 117 worker_process_id, worker_route_id, *message); |
118 } | 118 } |
119 | 119 |
120 // DevToolsAgentHostImpl implementation. | 120 // IPCDevToolsAgentHost implementation. |
121 virtual void SendMessageToAgent(IPC::Message* message) OVERRIDE { | 121 virtual void SendMessageToAgent(IPC::Message* message) OVERRIDE { |
122 if (!has_worker_id_) { | 122 if (!has_worker_id_) { |
123 delete message; | 123 delete message; |
124 return; | 124 return; |
125 } | 125 } |
126 BrowserThread::PostTask( | 126 BrowserThread::PostTask( |
127 BrowserThread::IO, FROM_HERE, | 127 BrowserThread::IO, FROM_HERE, |
128 base::Bind( | 128 base::Bind( |
129 &WorkerDevToolsAgentHost::ForwardToWorkerDevToolsAgent, | 129 &WorkerDevToolsAgentHost::ForwardToWorkerDevToolsAgent, |
130 worker_id_.first, | 130 worker_id_.first, |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 it->second->ConnectionFailed(); | 438 it->second->ConnectionFailed(); |
439 } | 439 } |
440 | 440 |
441 // static | 441 // static |
442 void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { | 442 void WorkerDevToolsManager::SendResumeToWorker(const WorkerId& id) { |
443 if (WorkerProcessHost* process = FindWorkerProcess(id.first)) | 443 if (WorkerProcessHost* process = FindWorkerProcess(id.first)) |
444 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); | 444 process->Send(new DevToolsAgentMsg_ResumeWorkerContext(id.second)); |
445 } | 445 } |
446 | 446 |
447 } // namespace content | 447 } // namespace content |
OLD | NEW |