| 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_NOTIFICATION_RESOURCE_PROVIDER_
H_ | |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_NOTIFICATION_RESOURCE_PROVIDER_
H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/string16.h" | |
| 13 #include "chrome/browser/task_manager/task_manager.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 class BalloonHost; | |
| 19 | |
| 20 class TaskManagerNotificationResource : public TaskManager::Resource { | |
| 21 public: | |
| 22 explicit TaskManagerNotificationResource(BalloonHost* balloon_host); | |
| 23 virtual ~TaskManagerNotificationResource(); | |
| 24 | |
| 25 // TaskManager::Resource interface | |
| 26 virtual string16 GetTitle() const OVERRIDE; | |
| 27 virtual string16 GetProfileName() const OVERRIDE; | |
| 28 virtual gfx::ImageSkia GetIcon() const OVERRIDE; | |
| 29 virtual base::ProcessHandle GetProcess() const OVERRIDE; | |
| 30 virtual int GetUniqueChildProcessId() const OVERRIDE; | |
| 31 virtual Type GetType() const OVERRIDE; | |
| 32 virtual bool CanInspect() const OVERRIDE; | |
| 33 virtual void Inspect() const OVERRIDE; | |
| 34 virtual bool SupportNetworkUsage() const OVERRIDE; | |
| 35 virtual void SetSupportNetworkUsage() OVERRIDE { } | |
| 36 | |
| 37 private: | |
| 38 // The icon painted for notifications. . | |
| 39 static gfx::ImageSkia* default_icon_; | |
| 40 | |
| 41 // Non-owned pointer to the balloon host. | |
| 42 BalloonHost* balloon_host_; | |
| 43 | |
| 44 // Cached data about the balloon host. | |
| 45 base::ProcessHandle process_handle_; | |
| 46 int pid_; | |
| 47 int unique_process_id_; | |
| 48 string16 title_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(TaskManagerNotificationResource); | |
| 51 }; | |
| 52 | |
| 53 class TaskManagerNotificationResourceProvider | |
| 54 : public TaskManager::ResourceProvider, | |
| 55 public content::NotificationObserver { | |
| 56 public: | |
| 57 static TaskManagerNotificationResourceProvider* Create( | |
| 58 TaskManager* task_manager); | |
| 59 | |
| 60 // TaskManager::ResourceProvider interface | |
| 61 virtual TaskManager::Resource* GetResource(int origin_pid, | |
| 62 int render_process_host_id, | |
| 63 int routing_id) OVERRIDE; | |
| 64 virtual void StartUpdating() OVERRIDE; | |
| 65 virtual void StopUpdating() OVERRIDE; | |
| 66 | |
| 67 // content::NotificationObserver interface | |
| 68 virtual void Observe(int type, | |
| 69 const content::NotificationSource& source, | |
| 70 const content::NotificationDetails& details) OVERRIDE; | |
| 71 | |
| 72 private: | |
| 73 explicit TaskManagerNotificationResourceProvider(TaskManager* task_manager); | |
| 74 virtual ~TaskManagerNotificationResourceProvider(); | |
| 75 | |
| 76 void AddToTaskManager(BalloonHost* balloon_host); | |
| 77 void RemoveFromTaskManager(BalloonHost* balloon_host); | |
| 78 | |
| 79 TaskManager* task_manager_; | |
| 80 | |
| 81 // Maps the actual resources (BalloonHost*) to the Task Manager resources. | |
| 82 std::map<BalloonHost*, TaskManagerNotificationResource*> resources_; | |
| 83 | |
| 84 // A scoped container for notification registries. | |
| 85 content::NotificationRegistrar registrar_; | |
| 86 | |
| 87 bool updating_; | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(TaskManagerNotificationResourceProvider); | |
| 90 }; | |
| 91 | |
| 92 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_NOTIFICATION_RESOURCE_PROVID
ER_H_ | |
| OLD | NEW |