| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/task_manager/task_manager.h" |
| 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" |
| 14 |
| 15 namespace content { |
| 16 class RenderViewHost; |
| 17 } |
| 18 |
| 19 namespace task_manager { |
| 20 |
| 21 class ExtensionProcessResource; |
| 22 |
| 23 class ExtensionProcessResourceProvider |
| 24 : public TaskManager::ResourceProvider, |
| 25 public content::NotificationObserver { |
| 26 public: |
| 27 explicit ExtensionProcessResourceProvider(TaskManager* task_manager); |
| 28 |
| 29 virtual TaskManager::Resource* GetResource(int origin_pid, |
| 30 int render_process_host_id, |
| 31 int routing_id) OVERRIDE; |
| 32 virtual void StartUpdating() OVERRIDE; |
| 33 virtual void StopUpdating() OVERRIDE; |
| 34 |
| 35 // content::NotificationObserver method: |
| 36 virtual void Observe(int type, |
| 37 const content::NotificationSource& source, |
| 38 const content::NotificationDetails& details) OVERRIDE; |
| 39 |
| 40 private: |
| 41 virtual ~ExtensionProcessResourceProvider(); |
| 42 |
| 43 bool IsHandledByThisProvider(content::RenderViewHost* render_view_host); |
| 44 void AddToTaskManager(content::RenderViewHost* render_view_host); |
| 45 void RemoveFromTaskManager(content::RenderViewHost* render_view_host); |
| 46 |
| 47 TaskManager* task_manager_; |
| 48 |
| 49 // Maps the actual resources (content::RenderViewHost*) to the Task Manager |
| 50 // resources. |
| 51 typedef std::map<content::RenderViewHost*, ExtensionProcessResource*> |
| 52 ExtensionRenderViewHostMap; |
| 53 ExtensionRenderViewHostMap resources_; |
| 54 |
| 55 // A scoped container for notification registries. |
| 56 content::NotificationRegistrar registrar_; |
| 57 |
| 58 bool updating_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessResourceProvider); |
| 61 }; |
| 62 |
| 63 } // namespace task_manager |
| 64 |
| 65 #endif // CHROME_BROWSER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_ |
| OLD | NEW |