| 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 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "chrome/browser/task_manager/task_manager.h" | 13 #include "chrome/browser/task_manager/task_manager.h" |
| 14 #include "content/browser/worker_host/worker_service_observer.h" | |
| 15 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/worker_service_observer.h" |
| 17 | 17 |
| 18 class TaskManagerSharedWorkerResource; | 18 class TaskManagerSharedWorkerResource; |
| 19 | 19 |
| 20 class TaskManagerWorkerResourceProvider | 20 class TaskManagerWorkerResourceProvider |
| 21 : public TaskManager::ResourceProvider, | 21 : public TaskManager::ResourceProvider, |
| 22 private WorkerServiceObserver, | 22 private content::WorkerServiceObserver, |
| 23 private content::NotificationObserver { | 23 private content::NotificationObserver { |
| 24 public: | 24 public: |
| 25 explicit TaskManagerWorkerResourceProvider(TaskManager* task_manager); | 25 explicit TaskManagerWorkerResourceProvider(TaskManager* task_manager); |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 class WorkerResourceListHolder; | 28 class WorkerResourceListHolder; |
| 29 typedef std::vector<TaskManagerSharedWorkerResource*> WorkerResourceList; | 29 typedef std::vector<TaskManagerSharedWorkerResource*> WorkerResourceList; |
| 30 typedef scoped_ptr<TaskManagerSharedWorkerResource> WorkerResourceHolder; | 30 typedef scoped_ptr<TaskManagerSharedWorkerResource> WorkerResourceHolder; |
| 31 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources; | 31 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources; |
| 32 | 32 |
| 33 virtual ~TaskManagerWorkerResourceProvider(); | 33 virtual ~TaskManagerWorkerResourceProvider(); |
| 34 | 34 |
| 35 // TaskManager::ResourceProvider implementation. | 35 // TaskManager::ResourceProvider implementation. |
| 36 virtual TaskManager::Resource* GetResource(int origin_pid, | 36 virtual TaskManager::Resource* GetResource(int origin_pid, |
| 37 int render_process_host_id, | 37 int render_process_host_id, |
| 38 int routing_id) OVERRIDE; | 38 int routing_id) OVERRIDE; |
| 39 virtual void StartUpdating() OVERRIDE; | 39 virtual void StartUpdating() OVERRIDE; |
| 40 virtual void StopUpdating() OVERRIDE; | 40 virtual void StopUpdating() OVERRIDE; |
| 41 | 41 |
| 42 // WorkerServiceObserver implementation. | 42 // content::WorkerServiceObserver implementation. |
| 43 virtual void WorkerCreated( | 43 virtual void WorkerCreated( |
| 44 WorkerProcessHost* process, | 44 WorkerProcessHost* process, |
| 45 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE; | 45 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE; |
| 46 virtual void WorkerDestroyed( | 46 virtual void WorkerDestroyed( |
| 47 WorkerProcessHost* process, | 47 WorkerProcessHost* process, |
| 48 int worker_route_id) OVERRIDE; | 48 int worker_route_id) OVERRIDE; |
| 49 virtual void WorkerContextStarted(WorkerProcessHost*, int) OVERRIDE {} | 49 virtual void WorkerContextStarted(WorkerProcessHost*, int) OVERRIDE {} |
| 50 | 50 |
| 51 // content::NotificationObserver implementation. | 51 // content::NotificationObserver implementation. |
| 52 virtual void Observe(int type, | 52 virtual void Observe(int type, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 // entries for worker processes which has not launched yet but for which we | 70 // entries for worker processes which has not launched yet but for which we |
| 71 // have already received WorkerCreated event. We don't add such workers to | 71 // have already received WorkerCreated event. We don't add such workers to |
| 72 // the task manager until the process is launched. | 72 // the task manager until the process is launched. |
| 73 ProcessIdToWorkerResources launching_workers_; | 73 ProcessIdToWorkerResources launching_workers_; |
| 74 content::NotificationRegistrar registrar_; | 74 content::NotificationRegistrar registrar_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(TaskManagerWorkerResourceProvider); | 76 DISALLOW_COPY_AND_ASSIGN(TaskManagerWorkerResourceProvider); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | 79 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ |
| OLD | NEW |