| 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_GUEST_RESOURCE_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_GUEST_RESOURCE_PROVIDER_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 "chrome/browser/task_manager/task_manager_render_resource.h" | |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 #include "content/public/browser/notification_registrar.h" | |
| 16 #include "ui/gfx/image/image_skia.h" | |
| 17 | |
| 18 namespace content { | |
| 19 class RenderViewHost; | |
| 20 class WebContents; | |
| 21 } | |
| 22 | |
| 23 namespace extensions { | |
| 24 class Extension; | |
| 25 } | |
| 26 | |
| 27 class TaskManagerGuestResource : public TaskManagerRendererResource { | |
| 28 public: | |
| 29 explicit TaskManagerGuestResource(content::RenderViewHost* render_view_host); | |
| 30 virtual ~TaskManagerGuestResource(); | |
| 31 | |
| 32 // TaskManager::Resource methods: | |
| 33 virtual Type GetType() const OVERRIDE; | |
| 34 virtual string16 GetTitle() const OVERRIDE; | |
| 35 virtual string16 GetProfileName() const OVERRIDE; | |
| 36 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | |
| 37 virtual content::WebContents* GetWebContents() const OVERRIDE; | |
| 38 virtual const extensions::Extension* GetExtension() const OVERRIDE; | |
| 39 | |
| 40 private: | |
| 41 DISALLOW_COPY_AND_ASSIGN(TaskManagerGuestResource); | |
| 42 }; | |
| 43 | |
| 44 class TaskManagerGuestResourceProvider | |
| 45 : public TaskManager::ResourceProvider, | |
| 46 public content::NotificationObserver { | |
| 47 public: | |
| 48 explicit TaskManagerGuestResourceProvider(TaskManager* task_manager); | |
| 49 | |
| 50 // TaskManager::ResourceProvider methods: | |
| 51 virtual TaskManager::Resource* GetResource(int origin_pid, | |
| 52 int render_process_host_id, | |
| 53 int routing_id) OVERRIDE; | |
| 54 virtual void StartUpdating() OVERRIDE; | |
| 55 virtual void StopUpdating() OVERRIDE; | |
| 56 | |
| 57 // content::NotificationObserver method: | |
| 58 virtual void Observe(int type, | |
| 59 const content::NotificationSource& source, | |
| 60 const content::NotificationDetails& details) OVERRIDE; | |
| 61 | |
| 62 private: | |
| 63 virtual ~TaskManagerGuestResourceProvider(); | |
| 64 | |
| 65 void Add(content::RenderViewHost* render_view_host); | |
| 66 void Remove(content::RenderViewHost* render_view_host); | |
| 67 | |
| 68 // Whether we are currently reporting to the task manager. Used to ignore | |
| 69 // notifications sent after StopUpdating(). | |
| 70 bool updating_; | |
| 71 | |
| 72 TaskManager* task_manager_; | |
| 73 | |
| 74 typedef std::map<content::RenderViewHost*, | |
| 75 TaskManagerGuestResource*> GuestResourceMap; | |
| 76 GuestResourceMap resources_; | |
| 77 | |
| 78 // A scoped container for notification registries. | |
| 79 content::NotificationRegistrar registrar_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(TaskManagerGuestResourceProvider); | |
| 82 }; | |
| 83 | |
| 84 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_GUEST_RESOURCE_PROVIDER_H_ | |
| OLD | NEW |