Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1660)

Side by Side Diff: chrome/browser/task_manager/worker_resource_provider.h

Issue 15196003: Create task_manager namespace and wrap classes related to TaskManager with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_WORKER_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/task_manager/task_manager.h" 12 #include "chrome/browser/task_manager/task_manager.h"
13 #include "content/public/browser/browser_child_process_observer.h" 13 #include "content/public/browser/browser_child_process_observer.h"
14 #include "content/public/browser/worker_service_observer.h" 14 #include "content/public/browser/worker_service_observer.h"
15 15
16 class TaskManagerSharedWorkerResource; 16 namespace task_manager {
17 17
18 class TaskManagerWorkerResourceProvider 18 class SharedWorkerResource;
19
20 class WorkerResourceProvider
19 : public TaskManager::ResourceProvider, 21 : public TaskManager::ResourceProvider,
20 public content::BrowserChildProcessObserver, 22 public content::BrowserChildProcessObserver,
21 private content::WorkerServiceObserver { 23 private content::WorkerServiceObserver {
22 public: 24 public:
23 explicit TaskManagerWorkerResourceProvider(TaskManager* task_manager); 25 explicit WorkerResourceProvider(TaskManager* task_manager);
24 26
25 private: 27 private:
26 class WorkerResourceListHolder; 28 class WorkerResourceListHolder;
27 typedef std::vector<TaskManagerSharedWorkerResource*> WorkerResourceList; 29 typedef std::vector<SharedWorkerResource*> WorkerResourceList;
28 typedef scoped_ptr<TaskManagerSharedWorkerResource> WorkerResourceHolder; 30 typedef scoped_ptr<SharedWorkerResource> WorkerResourceHolder;
29 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources; 31 typedef std::map<int, WorkerResourceList> ProcessIdToWorkerResources;
30 32
31 virtual ~TaskManagerWorkerResourceProvider(); 33 virtual ~WorkerResourceProvider();
32 34
33 // TaskManager::ResourceProvider implementation. 35 // TaskManager::ResourceProvider implementation.
34 virtual TaskManager::Resource* GetResource(int origin_pid, 36 virtual TaskManager::Resource* GetResource(int origin_pid,
35 int render_process_host_id, 37 int render_process_host_id,
36 int routing_id) OVERRIDE; 38 int routing_id) OVERRIDE;
37 virtual void StartUpdating() OVERRIDE; 39 virtual void StartUpdating() OVERRIDE;
38 virtual void StopUpdating() OVERRIDE; 40 virtual void StopUpdating() OVERRIDE;
39 41
40 // content::BrowserChildProcessObserver implementation. 42 // content::BrowserChildProcessObserver implementation.
41 virtual void BrowserChildProcessHostConnected( 43 virtual void BrowserChildProcessHostConnected(
42 const content::ChildProcessData& data) OVERRIDE; 44 const content::ChildProcessData& data) OVERRIDE;
43 virtual void BrowserChildProcessHostDisconnected( 45 virtual void BrowserChildProcessHostDisconnected(
44 const content::ChildProcessData& data) OVERRIDE; 46 const content::ChildProcessData& data) OVERRIDE;
45 47
46 // content::WorkerServiceObserver implementation. 48 // content::WorkerServiceObserver implementation.
47 virtual void WorkerCreated(const GURL& url, 49 virtual void WorkerCreated(const GURL& url,
48 const string16& name, 50 const string16& name,
49 int process_id, 51 int process_id,
50 int route_id) OVERRIDE; 52 int route_id) OVERRIDE;
51 virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE; 53 virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE;
52 54
53 void NotifyWorkerCreated(WorkerResourceHolder* resource_holder); 55 void NotifyWorkerCreated(WorkerResourceHolder* resource_holder);
54 void NotifyWorkerDestroyed(int process_id, int routing_id); 56 void NotifyWorkerDestroyed(int process_id, int routing_id);
55 57
56 void StartObservingWorkers(); 58 void StartObservingWorkers();
57 void StopObservingWorkers(); 59 void StopObservingWorkers();
58 60
59 void AddWorkerResourceList(WorkerResourceListHolder* resource_list_holder); 61 void AddWorkerResourceList(WorkerResourceListHolder* resource_list_holder);
60 void AddResource(TaskManagerSharedWorkerResource* resource); 62 void AddResource(SharedWorkerResource* resource);
61 void DeleteAllResources(); 63 void DeleteAllResources();
62 64
63 bool updating_; 65 bool updating_;
64 TaskManager* task_manager_; 66 TaskManager* task_manager_;
65 WorkerResourceList resources_; 67 WorkerResourceList resources_;
66 // Map from worker process id to the list of its workers. This list contains 68 // 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 69 // 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 70 // have already received WorkerCreated event. We don't add such workers to
69 // the task manager until the process is launched. 71 // the task manager until the process is launched.
70 ProcessIdToWorkerResources launching_workers_; 72 ProcessIdToWorkerResources launching_workers_;
71 73
72 DISALLOW_COPY_AND_ASSIGN(TaskManagerWorkerResourceProvider); 74 DISALLOW_COPY_AND_ASSIGN(WorkerResourceProvider);
73 }; 75 };
74 76
75 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_ 77 } // namespace task_manager
78
79 #endif // CHROME_BROWSER_TASK_MANAGER_WORKER_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698