| 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/task_manager/task_manager_worker_resource_provider.h" | 5 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/debugger/devtools_window.h" | 12 #include "chrome/browser/debugger/devtools_window.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "content/browser/browser_child_process_host.h" | 14 #include "content/browser/browser_child_process_host.h" |
| 15 #include "content/browser/debugger/worker_devtools_manager.h" | |
| 16 #include "content/browser/worker_host/worker_process_host.h" | 15 #include "content/browser/worker_host/worker_process_host.h" |
| 17 #include "content/browser/worker_host/worker_service.h" | 16 #include "content/browser/worker_host/worker_service.h" |
| 18 #include "content/browser/worker_host/worker_service_observer.h" | 17 #include "content/browser/worker_host/worker_service_observer.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/devtools_agent_host_registry.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
| 22 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
| 23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 24 #include "grit/theme_resources_standard.h" | 24 #include "grit/theme_resources_standard.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.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 // Objects of this class are created on the IO thread and then passed to the UI | 32 // Objects of this class are created on the IO thread and then passed to the UI |
| 31 // thread where they are passed to the task manager. All methods must be called | 33 // thread where they are passed to the task manager. All methods must be called |
| 32 // only on the UI thread. Destructor may be called on any thread. | 34 // only on the UI thread. Destructor may be called on any thread. |
| 33 class TaskManagerSharedWorkerResource : public TaskManager::Resource { | 35 class TaskManagerSharedWorkerResource : public TaskManager::Resource { |
| 34 public: | 36 public: |
| 35 TaskManagerSharedWorkerResource(const ChildProcessInfo& process_info, | 37 TaskManagerSharedWorkerResource(const ChildProcessInfo& process_info, |
| 36 int routing_id, const GURL& url, | 38 int routing_id, const GURL& url, |
| 37 const string16& name); | 39 const string16& name); |
| 38 virtual ~TaskManagerSharedWorkerResource(); | 40 virtual ~TaskManagerSharedWorkerResource(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return true; | 122 return true; |
| 121 } | 123 } |
| 122 | 124 |
| 123 void TaskManagerSharedWorkerResource::Inspect() const { | 125 void TaskManagerSharedWorkerResource::Inspect() const { |
| 124 // TODO(yurys): would be better to get profile from one of the tabs connected | 126 // TODO(yurys): would be better to get profile from one of the tabs connected |
| 125 // to the worker. | 127 // to the worker. |
| 126 Profile* profile = ProfileManager::GetLastUsedProfile(); | 128 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 127 if (!profile) | 129 if (!profile) |
| 128 return; | 130 return; |
| 129 DevToolsAgentHost* agent_host = | 131 DevToolsAgentHost* agent_host = |
| 130 WorkerDevToolsManager::GetDevToolsAgentHostForWorker( | 132 DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( |
| 131 process_info_.id(), | 133 process_info_.id(), |
| 132 routing_id_); | 134 routing_id_); |
| 133 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | 135 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); |
| 134 } | 136 } |
| 135 | 137 |
| 136 bool TaskManagerSharedWorkerResource::SupportNetworkUsage() const { | 138 bool TaskManagerSharedWorkerResource::SupportNetworkUsage() const { |
| 137 return false; | 139 return false; |
| 138 } | 140 } |
| 139 | 141 |
| 140 void TaskManagerSharedWorkerResource::SetSupportNetworkUsage() { | 142 void TaskManagerSharedWorkerResource::SetSupportNetworkUsage() { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 int process_id = resource->process_info().id(); | 347 int process_id = resource->process_info().id(); |
| 346 launching_workers_[process_id].push_back(resource); | 348 launching_workers_[process_id].push_back(resource); |
| 347 } else { | 349 } else { |
| 348 task_manager_->AddResource(resource); | 350 task_manager_->AddResource(resource); |
| 349 } | 351 } |
| 350 } | 352 } |
| 351 | 353 |
| 352 void TaskManagerWorkerResourceProvider::DeleteAllResources() { | 354 void TaskManagerWorkerResourceProvider::DeleteAllResources() { |
| 353 STLDeleteElements(&resources_); | 355 STLDeleteElements(&resources_); |
| 354 } | 356 } |
| OLD | NEW |