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

Side by Side Diff: chrome/browser/ui/webui/workers_ui.cc

Issue 8549022: Define DevTools content API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jam's comments addressed Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | content/browser/debugger/devtools_agent_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/public/common/process_type.h" 24 #include "content/public/common/process_type.h"
25 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
26 #include "grit/workers_resources.h" 26 #include "grit/workers_resources.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 using content::DevToolsAgentHost;
31 using content::DevToolsAgentHostRegistry;
30 32
31 static const char kWorkersDataFile[] = "workers_data.json"; 33 static const char kWorkersDataFile[] = "workers_data.json";
32 34
33 static const char kOpenDevToolsCommand[] = "openDevTools"; 35 static const char kOpenDevToolsCommand[] = "openDevTools";
34 static const char kTerminateWorkerCommand[] = "terminateWorker"; 36 static const char kTerminateWorkerCommand[] = "terminateWorker";
35 37
36 static const char kWorkerProcessHostIdField[] = "workerProcessHostId"; 38 static const char kWorkerProcessHostIdField[] = "workerProcessHostId";
37 static const char kWorkerRouteIdField[] = "workerRouteId"; 39 static const char kWorkerRouteIdField[] = "workerRouteId";
38 static const char kUrlField[] = "url"; 40 static const char kUrlField[] = "url";
39 static const char kNameField[] = "name"; 41 static const char kNameField[] = "name";
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 CHECK(args->GetString(0, &worker_process_host_id_str)); 137 CHECK(args->GetString(0, &worker_process_host_id_str));
136 CHECK(args->GetString(1, &worker_route_id_str)); 138 CHECK(args->GetString(1, &worker_route_id_str));
137 CHECK(base::StringToInt(worker_process_host_id_str, 139 CHECK(base::StringToInt(worker_process_host_id_str,
138 &worker_process_host_id)); 140 &worker_process_host_id));
139 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id)); 141 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id));
140 142
141 Profile* profile = Profile::FromWebUI(web_ui_); 143 Profile* profile = Profile::FromWebUI(web_ui_);
142 if (!profile) 144 if (!profile)
143 return; 145 return;
144 DevToolsAgentHost* agent_host = 146 DevToolsAgentHost* agent_host =
145 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( 147 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker(
146 worker_process_host_id, 148 worker_process_host_id,
147 worker_route_id); 149 worker_route_id);
148 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); 150 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host);
149 } 151 }
150 152
151 static void TerminateWorker(int worker_process_id, int worker_route_id) { 153 static void TerminateWorker(int worker_process_id, int worker_route_id) {
152 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); 154 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER);
153 !iter.Done(); ++iter) { 155 !iter.Done(); ++iter) {
154 if (iter->id() == worker_process_id) { 156 if (iter->id() == worker_process_id) {
155 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); 157 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 257
256 // Set up the chrome://workers/ source. 258 // Set up the chrome://workers/ source.
257 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 259 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
258 profile->GetChromeURLDataManager()->AddDataSource(html_source); 260 profile->GetChromeURLDataManager()->AddDataSource(html_source);
259 } 261 }
260 262
261 WorkersUI::~WorkersUI() { 263 WorkersUI::~WorkersUI() {
262 observer_->WorkersUIDestroyed(); 264 observer_->WorkersUIDestroyed();
263 observer_ = NULL; 265 observer_ = NULL;
264 } 266 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/devtools_ui.cc ('k') | content/browser/debugger/devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698