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

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

Issue 8760011: Move the ProcessType enum out to its own file. This is in preparation for getting rid of ChildPro... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac 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/about_ui.cc ('k') | chrome/test/automation/proxy_launcher.cc » ('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/browser/debugger/worker_devtools_manager.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 "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
25 #include "grit/workers_resources.h" 26 #include "grit/workers_resources.h"
26 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
27 28
28 using content::BrowserThread; 29 using content::BrowserThread;
29 30
30 static const char kWorkersDataFile[] = "workers_data.json"; 31 static const char kWorkersDataFile[] = "workers_data.json";
31 32
32 static const char kOpenDevToolsCommand[] = "openDevTools"; 33 static const char kOpenDevToolsCommand[] = "openDevTools";
33 static const char kTerminateWorkerCommand[] = "terminateWorker"; 34 static const char kTerminateWorkerCommand[] = "terminateWorker";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int request_id) { 78 int request_id) {
78 if (path == kWorkersDataFile) { 79 if (path == kWorkersDataFile) {
79 SendSharedWorkersData(request_id); 80 SendSharedWorkersData(request_id);
80 } else { 81 } else {
81 ChromeWebUIDataSource::StartDataRequest(path, is_incognito, request_id); 82 ChromeWebUIDataSource::StartDataRequest(path, is_incognito, request_id);
82 } 83 }
83 } 84 }
84 85
85 void WorkersUIHTMLSource::SendSharedWorkersData(int request_id) { 86 void WorkersUIHTMLSource::SendSharedWorkersData(int request_id) {
86 ListValue workers_list; 87 ListValue workers_list;
87 BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); 88 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER);
88 for (; !iter.Done(); ++iter) { 89 for (; !iter.Done(); ++iter) {
89 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); 90 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
90 const WorkerProcessHost::Instances& instances = worker->instances(); 91 const WorkerProcessHost::Instances& instances = worker->instances();
91 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); 92 for (WorkerProcessHost::Instances::const_iterator i = instances.begin();
92 i != instances.end(); ++i) { 93 i != instances.end(); ++i) {
93 workers_list.Append(BuildWorkerData(worker, *i)); 94 workers_list.Append(BuildWorkerData(worker, *i));
94 } 95 }
95 } 96 }
96 97
97 std::string json_string; 98 std::string json_string;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!profile) 142 if (!profile)
142 return; 143 return;
143 DevToolsAgentHost* agent_host = 144 DevToolsAgentHost* agent_host =
144 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( 145 WorkerDevToolsManager::GetDevToolsAgentHostForWorker(
145 worker_process_host_id, 146 worker_process_host_id,
146 worker_route_id); 147 worker_route_id);
147 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); 148 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host);
148 } 149 }
149 150
150 static void TerminateWorker(int worker_process_id, int worker_route_id) { 151 static void TerminateWorker(int worker_process_id, int worker_route_id) {
151 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); 152 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER);
152 !iter.Done(); ++iter) { 153 !iter.Done(); ++iter) {
153 if (iter->id() == worker_process_id) { 154 if (iter->id() == worker_process_id) {
154 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); 155 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
155 worker->TerminateWorker(worker_route_id); 156 worker->TerminateWorker(worker_route_id);
156 return; 157 return;
157 } 158 }
158 } 159 }
159 } 160 }
160 161
161 void WorkersDOMHandler::HandleTerminateWorker(const ListValue* args) { 162 void WorkersDOMHandler::HandleTerminateWorker(const ListValue* args) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 255
255 // Set up the chrome://workers/ source. 256 // Set up the chrome://workers/ source.
256 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 257 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
257 profile->GetChromeURLDataManager()->AddDataSource(html_source); 258 profile->GetChromeURLDataManager()->AddDataSource(html_source);
258 } 259 }
259 260
260 WorkersUI::~WorkersUI() { 261 WorkersUI::~WorkersUI() {
261 observer_->WorkersUIDestroyed(); 262 observer_->WorkersUIDestroyed();
262 observer_ = NULL; 263 observer_ = NULL;
263 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/about_ui.cc ('k') | chrome/test/automation/proxy_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698