OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | |
7 | |
8 #include <map> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "chrome/browser/task_manager/task_manager.h" | |
13 #include "content/public/browser/browser_child_process_observer.h" | |
14 #include "content/public/browser/worker_service_observer.h" | |
15 | |
16 class TaskManagerSharedWorkerResource; | |
17 | |
18 class TaskManagerWorkerResourceProvider | |
19 : public TaskManager::ResourceProvider, | |
20 public content::BrowserChildProcessObserver, | |
21 private content::WorkerServiceObserver { | |
22 public: | |
23 explicit TaskManagerWorkerResourceProvider(TaskManager* task_manager); | |
24 | |
25 private: | |
26 class WorkerResourceListHolder; | |
27 typedef std::vector<TaskManagerSharedWorkerResource*> WorkerResourceList; | |
28 typedef scoped_ptr<TaskManagerSharedWorkerResource> WorkerResourceHolder; | |
29 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources; | |
30 | |
31 virtual ~TaskManagerWorkerResourceProvider(); | |
32 | |
33 // TaskManager::ResourceProvider implementation. | |
34 virtual TaskManager::Resource* GetResource(int origin_pid, | |
35 int render_process_host_id, | |
36 int routing_id) OVERRIDE; | |
37 virtual void StartUpdating() OVERRIDE; | |
38 virtual void StopUpdating() OVERRIDE; | |
39 | |
40 // content::BrowserChildProcessObserver implementation. | |
41 virtual void BrowserChildProcessHostConnected( | |
42 const content::ChildProcessData& data) OVERRIDE; | |
43 virtual void BrowserChildProcessHostDisconnected( | |
44 const content::ChildProcessData& data) OVERRIDE; | |
45 | |
46 // content::WorkerServiceObserver implementation. | |
47 virtual void WorkerCreated(const GURL& url, | |
48 const string16& name, | |
49 int process_id, | |
50 int route_id) OVERRIDE; | |
51 virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE; | |
52 | |
53 void NotifyWorkerCreated(WorkerResourceHolder* resource_holder); | |
54 void NotifyWorkerDestroyed(int process_id, int routing_id); | |
55 | |
56 void StartObservingWorkers(); | |
57 void StopObservingWorkers(); | |
58 | |
59 void AddWorkerResourceList(WorkerResourceListHolder* resource_list_holder); | |
60 void AddResource(TaskManagerSharedWorkerResource* resource); | |
61 void DeleteAllResources(); | |
62 | |
63 bool updating_; | |
64 TaskManager* task_manager_; | |
65 WorkerResourceList resources_; | |
66 // Map from worker process id to the list of its workers. This list contains | |
67 // entries for worker processes which has not launched yet but for which we | |
68 // have already received WorkerCreated event. We don't add such workers to | |
69 // the task manager until the process is launched. | |
70 ProcessIdToWorkerResources launching_workers_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(TaskManagerWorkerResourceProvider); | |
73 }; | |
74 | |
75 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ | |
OLD | NEW |