| 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_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROV
IDER_H_ | |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROV
IDER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/string16.h" | |
| 12 #include "chrome/browser/task_manager/task_manager.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "content/public/common/process_type.h" | |
| 16 #include "ui/gfx/image/image_skia.h" | |
| 17 | |
| 18 namespace content { | |
| 19 class RenderViewHost; | |
| 20 } | |
| 21 | |
| 22 namespace extensions { | |
| 23 class Extension; | |
| 24 } | |
| 25 | |
| 26 class TaskManagerExtensionProcessResource : public TaskManager::Resource { | |
| 27 public: | |
| 28 explicit TaskManagerExtensionProcessResource( | |
| 29 content::RenderViewHost* render_view_host); | |
| 30 virtual ~TaskManagerExtensionProcessResource(); | |
| 31 | |
| 32 // TaskManager::Resource methods: | |
| 33 virtual string16 GetTitle() const OVERRIDE; | |
| 34 virtual string16 GetProfileName() const OVERRIDE; | |
| 35 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | |
| 36 virtual base::ProcessHandle GetProcess() const OVERRIDE; | |
| 37 virtual int GetUniqueChildProcessId() const OVERRIDE; | |
| 38 virtual Type GetType() const OVERRIDE; | |
| 39 virtual bool CanInspect() const OVERRIDE; | |
| 40 virtual void Inspect() const OVERRIDE; | |
| 41 virtual bool SupportNetworkUsage() const OVERRIDE; | |
| 42 virtual void SetSupportNetworkUsage() OVERRIDE; | |
| 43 virtual const extensions::Extension* GetExtension() const OVERRIDE; | |
| 44 | |
| 45 // Returns the pid of the extension process. | |
| 46 int process_id() const { return pid_; } | |
| 47 | |
| 48 // Returns true if the associated extension has a background page. | |
| 49 virtual bool IsBackground() const OVERRIDE; | |
| 50 | |
| 51 private: | |
| 52 // The icon painted for the extension process. | |
| 53 static gfx::ImageSkia* default_icon_; | |
| 54 | |
| 55 content::RenderViewHost* render_view_host_; | |
| 56 | |
| 57 // Cached data about the extension. | |
| 58 base::ProcessHandle process_handle_; | |
| 59 int pid_; | |
| 60 int unique_process_id_; | |
| 61 string16 title_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResource); | |
| 64 }; | |
| 65 | |
| 66 class TaskManagerExtensionProcessResourceProvider | |
| 67 : public TaskManager::ResourceProvider, | |
| 68 public content::NotificationObserver { | |
| 69 public: | |
| 70 explicit TaskManagerExtensionProcessResourceProvider( | |
| 71 TaskManager* task_manager); | |
| 72 | |
| 73 virtual TaskManager::Resource* GetResource(int origin_pid, | |
| 74 int render_process_host_id, | |
| 75 int routing_id) OVERRIDE; | |
| 76 virtual void StartUpdating() OVERRIDE; | |
| 77 virtual void StopUpdating() OVERRIDE; | |
| 78 | |
| 79 // content::NotificationObserver method: | |
| 80 virtual void Observe(int type, | |
| 81 const content::NotificationSource& source, | |
| 82 const content::NotificationDetails& details) OVERRIDE; | |
| 83 | |
| 84 private: | |
| 85 virtual ~TaskManagerExtensionProcessResourceProvider(); | |
| 86 | |
| 87 bool IsHandledByThisProvider(content::RenderViewHost* render_view_host); | |
| 88 void AddToTaskManager(content::RenderViewHost* render_view_host); | |
| 89 void RemoveFromTaskManager(content::RenderViewHost* render_view_host); | |
| 90 | |
| 91 TaskManager* task_manager_; | |
| 92 | |
| 93 // Maps the actual resources (content::RenderViewHost*) to the Task Manager | |
| 94 // resources. | |
| 95 typedef std::map<content::RenderViewHost*, | |
| 96 TaskManagerExtensionProcessResource*> ExtensionRenderViewHostMap; | |
| 97 ExtensionRenderViewHostMap resources_; | |
| 98 | |
| 99 // A scoped container for notification registries. | |
| 100 content::NotificationRegistrar registrar_; | |
| 101 | |
| 102 bool updating_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResourceProvider); | |
| 105 }; | |
| 106 | |
| 107 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_P
ROVIDER_H_ | |
| OLD | NEW |