Chromium Code Reviews| 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/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/common/devtools_messages.h" | 24 #include "content/common/devtools_messages.h" |
| 25 #include "content/common/worker_messages.h" | |
| 26 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 27 #include "grit/workers_resources.h" | 26 #include "grit/workers_resources.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 29 | 28 |
| 30 using content::BrowserThread; | 29 using content::BrowserThread; |
| 31 | 30 |
| 32 static const char kWorkersDataFile[] = "workers_data.json"; | 31 static const char kWorkersDataFile[] = "workers_data.json"; |
| 33 | 32 |
| 34 static const char kOpenDevToolsCommand[] = "openDevTools"; | 33 static const char kOpenDevToolsCommand[] = "openDevTools"; |
| 35 static const char kTerminateWorkerCommand[] = "terminateWorker"; | 34 static const char kTerminateWorkerCommand[] = "terminateWorker"; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 145 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( |
| 147 worker_process_host_id, | 146 worker_process_host_id, |
| 148 worker_route_id); | 147 worker_route_id); |
| 149 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | 148 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); |
| 150 } | 149 } |
| 151 | 150 |
| 152 static void TerminateWorker(int worker_process_id, int worker_route_id) { | 151 static void TerminateWorker(int worker_process_id, int worker_route_id) { |
| 153 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); | 152 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); |
| 154 !iter.Done(); ++iter) { | 153 !iter.Done(); ++iter) { |
| 155 if (iter->id() == worker_process_id) { | 154 if (iter->id() == worker_process_id) { |
| 156 (*iter)->Send(new WorkerMsg_TerminateWorkerContext(worker_route_id)); | 155 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
|
ananta
2011/11/12 00:10:15
Please fix indent.
| |
| 156 worker->TerminateWorker(worker_route_id); | |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 void WorkersDOMHandler::HandleTerminateWorker(const ListValue* args) { | 162 void WorkersDOMHandler::HandleTerminateWorker(const ListValue* args) { |
| 163 std::string worker_process_host_id_str; | 163 std::string worker_process_host_id_str; |
| 164 std::string worker_route_id_str; | 164 std::string worker_route_id_str; |
| 165 int worker_process_host_id; | 165 int worker_process_host_id; |
| 166 int worker_route_id; | 166 int worker_route_id; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 | 255 |
| 256 // Set up the chrome://workers/ source. | 256 // Set up the chrome://workers/ source. |
| 257 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 257 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
| 258 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 258 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
| 259 } | 259 } |
| 260 | 260 |
| 261 WorkersUI::~WorkersUI() { | 261 WorkersUI::~WorkersUI() { |
| 262 observer_->WorkersUIDestroyed(); | 262 observer_->WorkersUIDestroyed(); |
| 263 observer_ = NULL; | 263 observer_ = NULL; |
| 264 } | 264 } |
| OLD | NEW |