OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BACKGROUND_RESOURCE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_ |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/task_manager/task_manager.h" | 12 #include "chrome/browser/task_manager/task_manager.h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 | 15 |
16 class BackgroundContents; | 16 class BackgroundContents; |
17 class TaskManagerBackgroundContentsResource; | |
18 | 17 |
19 class TaskManagerBackgroundContentsResourceProvider | 18 namespace task_manager { |
| 19 |
| 20 class BackgroundContentsResource; |
| 21 |
| 22 class BackgroundContentsResourceProvider |
20 : public TaskManager::ResourceProvider, | 23 : public TaskManager::ResourceProvider, |
21 public content::NotificationObserver { | 24 public content::NotificationObserver { |
22 public: | 25 public: |
23 explicit TaskManagerBackgroundContentsResourceProvider( | 26 explicit BackgroundContentsResourceProvider( |
24 TaskManager* task_manager); | 27 TaskManager* task_manager); |
25 | 28 |
26 virtual TaskManager::Resource* GetResource(int origin_pid, | 29 virtual TaskManager::Resource* GetResource(int origin_pid, |
27 int render_process_host_id, | 30 int render_process_host_id, |
28 int routing_id) OVERRIDE; | 31 int routing_id) OVERRIDE; |
29 virtual void StartUpdating() OVERRIDE; | 32 virtual void StartUpdating() OVERRIDE; |
30 virtual void StopUpdating() OVERRIDE; | 33 virtual void StopUpdating() OVERRIDE; |
31 | 34 |
32 // content::NotificationObserver method: | 35 // content::NotificationObserver method: |
33 virtual void Observe(int type, | 36 virtual void Observe(int type, |
34 const content::NotificationSource& source, | 37 const content::NotificationSource& source, |
35 const content::NotificationDetails& details) OVERRIDE; | 38 const content::NotificationDetails& details) OVERRIDE; |
36 | 39 |
37 private: | 40 private: |
38 virtual ~TaskManagerBackgroundContentsResourceProvider(); | 41 virtual ~BackgroundContentsResourceProvider(); |
39 | 42 |
40 void Add(BackgroundContents* background_contents, const string16& title); | 43 void Add(BackgroundContents* background_contents, const string16& title); |
41 void Remove(BackgroundContents* background_contents); | 44 void Remove(BackgroundContents* background_contents); |
42 | 45 |
43 void AddToTaskManager(BackgroundContents* background_contents, | 46 void AddToTaskManager(BackgroundContents* background_contents, |
44 const string16& title); | 47 const string16& title); |
45 | 48 |
46 // Whether we are currently reporting to the task manager. Used to ignore | 49 // Whether we are currently reporting to the task manager. Used to ignore |
47 // notifications sent after StopUpdating(). | 50 // notifications sent after StopUpdating(). |
48 bool updating_; | 51 bool updating_; |
49 | 52 |
50 TaskManager* task_manager_; | 53 TaskManager* task_manager_; |
51 | 54 |
52 // Maps the actual resources (the BackgroundContents) to the Task Manager | 55 // Maps the actual resources (the BackgroundContents) to the Task Manager |
53 // resources. | 56 // resources. |
54 typedef std::map<BackgroundContents*, TaskManagerBackgroundContentsResource*> | 57 typedef std::map<BackgroundContents*, BackgroundContentsResource*> |
55 Resources; | 58 Resources; |
56 Resources resources_; | 59 Resources resources_; |
57 | 60 |
58 // A scoped container for notification registries. | 61 // A scoped container for notification registries. |
59 content::NotificationRegistrar registrar_; | 62 content::NotificationRegistrar registrar_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResourceProvider); | 64 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsResourceProvider); |
62 }; | 65 }; |
63 | 66 |
64 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER
_H_ | 67 } // namespace task_manager |
| 68 |
| 69 #endif // CHROME_BROWSER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_ |
OLD | NEW |