| 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" | 15 #include "content/browser/debugger/worker_devtools_manager.h" |
| 16 #include "content/browser/worker_host/worker_process_host.h" | 16 #include "content/browser/worker_host/worker_process_host.h" |
| 17 #include "content/browser/worker_host/worker_service.h" | 17 #include "content/browser/worker_host/worker_service.h" |
| 18 #include "content/browser/worker_host/worker_service_observer.h" | 18 #include "content/browser/worker_host/worker_service_observer.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.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 "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources_standard.h" | 24 #include "grit/theme_resources_standard.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 26 | 27 |
| 27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 28 | 29 |
| 29 // Objects of this class are created on the IO thread and then passed to the UI | 30 // Objects of this class are created on the IO thread and then passed to the UI |
| 30 // thread where they are passed to the task manager. All methods must be called | 31 // thread where they are passed to the task manager. All methods must be called |
| 31 // only on the UI thread. Destructor may be called on any thread. | 32 // only on the UI thread. Destructor may be called on any thread. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 &TaskManagerWorkerResourceProvider::NotifyWorkerDestroyed, | 231 &TaskManagerWorkerResourceProvider::NotifyWorkerDestroyed, |
| 231 this, process->id(), worker_route_id)); | 232 this, process->id(), worker_route_id)); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void TaskManagerWorkerResourceProvider::Observe( | 235 void TaskManagerWorkerResourceProvider::Observe( |
| 235 int type, | 236 int type, |
| 236 const content::NotificationSource& source, | 237 const content::NotificationSource& source, |
| 237 const content::NotificationDetails& details) { | 238 const content::NotificationDetails& details) { |
| 238 ChildProcessInfo* process_info = | 239 ChildProcessInfo* process_info = |
| 239 content::Details<ChildProcessInfo>(details).ptr(); | 240 content::Details<ChildProcessInfo>(details).ptr(); |
| 240 if (process_info->type() != ChildProcessInfo::WORKER_PROCESS) | 241 if (process_info->type() != content::PROCESS_TYPE_WORKER) |
| 241 return; | 242 return; |
| 242 if (type == content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED) { | 243 if (type == content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED) { |
| 243 ProcessIdToWorkerResources::iterator it = | 244 ProcessIdToWorkerResources::iterator it = |
| 244 launching_workers_.find(process_info->id()); | 245 launching_workers_.find(process_info->id()); |
| 245 if (it == launching_workers_.end()) | 246 if (it == launching_workers_.end()) |
| 246 return; | 247 return; |
| 247 WorkerResourceList& resources = it->second; | 248 WorkerResourceList& resources = it->second; |
| 248 for (WorkerResourceList::iterator r = resources.begin(); | 249 for (WorkerResourceList::iterator r = resources.begin(); |
| 249 r !=resources.end(); ++r) { | 250 r !=resources.end(); ++r) { |
| 250 (*r)->UpdateProcessInfo(*process_info); | 251 (*r)->UpdateProcessInfo(*process_info); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 resources_.erase(it); | 293 resources_.erase(it); |
| 293 return; | 294 return; |
| 294 } | 295 } |
| 295 } | 296 } |
| 296 } | 297 } |
| 297 | 298 |
| 298 void TaskManagerWorkerResourceProvider::StartObservingWorkers() { | 299 void TaskManagerWorkerResourceProvider::StartObservingWorkers() { |
| 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 300 | 301 |
| 301 scoped_ptr<WorkerResourceListHolder> holder(new WorkerResourceListHolder); | 302 scoped_ptr<WorkerResourceListHolder> holder(new WorkerResourceListHolder); |
| 302 BrowserChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS); | 303 BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_WORKER); |
| 303 for (; !iter.Done(); ++iter) { | 304 for (; !iter.Done(); ++iter) { |
| 304 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); | 305 WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter); |
| 305 const WorkerProcessHost::Instances& instances = worker->instances(); | 306 const WorkerProcessHost::Instances& instances = worker->instances(); |
| 306 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); | 307 for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); |
| 307 i != instances.end(); ++i) { | 308 i != instances.end(); ++i) { |
| 308 holder->resources()->push_back(new TaskManagerSharedWorkerResource( | 309 holder->resources()->push_back(new TaskManagerSharedWorkerResource( |
| 309 **iter, i->worker_route_id(), i->url(), i->name())); | 310 **iter, i->worker_route_id(), i->url(), i->name())); |
| 310 } | 311 } |
| 311 } | 312 } |
| 312 | 313 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 int process_id = resource->process_info().id(); | 345 int process_id = resource->process_info().id(); |
| 345 launching_workers_[process_id].push_back(resource); | 346 launching_workers_[process_id].push_back(resource); |
| 346 } else { | 347 } else { |
| 347 task_manager_->AddResource(resource); | 348 task_manager_->AddResource(resource); |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 | 351 |
| 351 void TaskManagerWorkerResourceProvider::DeleteAllResources() { | 352 void TaskManagerWorkerResourceProvider::DeleteAllResources() { |
| 352 STLDeleteElements(&resources_); | 353 STLDeleteElements(&resources_); |
| 353 } | 354 } |
| OLD | NEW |