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 "chrome/browser/ui/webui/workers_ui.h" | 5 #include "chrome/browser/ui/webui/workers_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/debugger/devtools_window.h" | 14 #include "chrome/browser/debugger/devtools_window.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "content/browser/debugger/worker_devtools_manager.h" | 19 #include "content/public/browser/devtools_agent_host_registry.h" |
20 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
21 #include "content/browser/worker_host/worker_process_host.h" | 21 #include "content/browser/worker_host/worker_process_host.h" |
22 #include "content/browser/worker_host/worker_service.h" | 22 #include "content/browser/worker_host/worker_service.h" |
23 #include "content/browser/worker_host/worker_service_observer.h" | 23 #include "content/browser/worker_host/worker_service_observer.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "grit/workers_resources.h" | 25 #include "grit/workers_resources.h" |
26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::DevToolsAgentHost; |
| 30 using content::DevToolsAgentHostRegistry; |
29 | 31 |
30 static const char kWorkersDataFile[] = "workers_data.json"; | 32 static const char kWorkersDataFile[] = "workers_data.json"; |
31 | 33 |
32 static const char kOpenDevToolsCommand[] = "openDevTools"; | 34 static const char kOpenDevToolsCommand[] = "openDevTools"; |
33 static const char kTerminateWorkerCommand[] = "terminateWorker"; | 35 static const char kTerminateWorkerCommand[] = "terminateWorker"; |
34 | 36 |
35 static const char kWorkerProcessHostIdField[] = "workerProcessHostId"; | 37 static const char kWorkerProcessHostIdField[] = "workerProcessHostId"; |
36 static const char kWorkerRouteIdField[] = "workerRouteId"; | 38 static const char kWorkerRouteIdField[] = "workerRouteId"; |
37 static const char kUrlField[] = "url"; | 39 static const char kUrlField[] = "url"; |
38 static const char kNameField[] = "name"; | 40 static const char kNameField[] = "name"; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 CHECK(args->GetString(0, &worker_process_host_id_str)); | 136 CHECK(args->GetString(0, &worker_process_host_id_str)); |
135 CHECK(args->GetString(1, &worker_route_id_str)); | 137 CHECK(args->GetString(1, &worker_route_id_str)); |
136 CHECK(base::StringToInt(worker_process_host_id_str, | 138 CHECK(base::StringToInt(worker_process_host_id_str, |
137 &worker_process_host_id)); | 139 &worker_process_host_id)); |
138 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id)); | 140 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id)); |
139 | 141 |
140 Profile* profile = Profile::FromWebUI(web_ui_); | 142 Profile* profile = Profile::FromWebUI(web_ui_); |
141 if (!profile) | 143 if (!profile) |
142 return; | 144 return; |
143 DevToolsAgentHost* agent_host = | 145 DevToolsAgentHost* agent_host = |
144 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 146 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( |
145 worker_process_host_id, | 147 worker_process_host_id, |
146 worker_route_id); | 148 worker_route_id); |
147 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | 149 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); |
148 } | 150 } |
149 | 151 |
150 static void TerminateWorker(int worker_process_id, int worker_route_id) { | 152 static void TerminateWorker(int worker_process_id, int worker_route_id) { |
151 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); | 153 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); |
152 !iter.Done(); ++iter) { | 154 !iter.Done(); ++iter) { |
153 if (iter->id() == worker_process_id) { | 155 if (iter->id() == worker_process_id) { |
154 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); | 156 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 256 |
255 // Set up the chrome://workers/ source. | 257 // Set up the chrome://workers/ source. |
256 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 258 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
257 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 259 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
258 } | 260 } |
259 | 261 |
260 WorkersUI::~WorkersUI() { | 262 WorkersUI::~WorkersUI() { |
261 observer_->WorkersUIDestroyed(); | 263 observer_->WorkersUIDestroyed(); |
262 observer_ = NULL; | 264 observer_ = NULL; |
263 } | 265 } |
OLD | NEW |