Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/task_manager/background_resource_provider.h

Issue 15196003: Create task_manager namespace and wrap classes related to TaskManager with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RendererResource Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/task_manager/task_manager_render_resource.h"
14 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
16 #include "ui/gfx/image/image_skia.h"
17 15
18 class BackgroundContents; 16 class BackgroundContents;
19 17
20 class TaskManagerBackgroundContentsResource 18 namespace task_manager {
21 : public TaskManagerRendererResource {
22 public:
23 TaskManagerBackgroundContentsResource(
24 BackgroundContents* background_contents,
25 const string16& application_name);
26 virtual ~TaskManagerBackgroundContentsResource();
27 19
28 // TaskManager::Resource methods: 20 class BackgroundContentsResource;
29 virtual string16 GetTitle() const OVERRIDE;
30 virtual string16 GetProfileName() const OVERRIDE;
31 virtual gfx::ImageSkia GetIcon() const OVERRIDE;
32 virtual bool IsBackground() const OVERRIDE;
33 21
34 const string16& application_name() const { return application_name_; } 22 class BackgroundContentsResourceProvider
35 private:
36 BackgroundContents* background_contents_;
37
38 string16 application_name_;
39
40 // The icon painted for BackgroundContents.
41 // TODO(atwilson): Use the favicon when there's a way to get the favicon for
42 // BackgroundContents.
43 static gfx::ImageSkia* default_icon_;
44
45 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResource);
46 };
47
48 class TaskManagerBackgroundContentsResourceProvider
49 : public TaskManager::ResourceProvider, 23 : public TaskManager::ResourceProvider,
50 public content::NotificationObserver { 24 public content::NotificationObserver {
51 public: 25 public:
52 explicit TaskManagerBackgroundContentsResourceProvider( 26 explicit BackgroundContentsResourceProvider(
53 TaskManager* task_manager); 27 TaskManager* task_manager);
54 28
55 virtual TaskManager::Resource* GetResource(int origin_pid, 29 virtual TaskManager::Resource* GetResource(int origin_pid,
56 int render_process_host_id, 30 int render_process_host_id,
57 int routing_id) OVERRIDE; 31 int routing_id) OVERRIDE;
58 virtual void StartUpdating() OVERRIDE; 32 virtual void StartUpdating() OVERRIDE;
59 virtual void StopUpdating() OVERRIDE; 33 virtual void StopUpdating() OVERRIDE;
60 34
61 // content::NotificationObserver method: 35 // content::NotificationObserver method:
62 virtual void Observe(int type, 36 virtual void Observe(int type,
63 const content::NotificationSource& source, 37 const content::NotificationSource& source,
64 const content::NotificationDetails& details) OVERRIDE; 38 const content::NotificationDetails& details) OVERRIDE;
65 39
66 private: 40 private:
67 virtual ~TaskManagerBackgroundContentsResourceProvider(); 41 virtual ~BackgroundContentsResourceProvider();
68 42
69 void Add(BackgroundContents* background_contents, const string16& title); 43 void Add(BackgroundContents* background_contents, const string16& title);
70 void Remove(BackgroundContents* background_contents); 44 void Remove(BackgroundContents* background_contents);
71 45
72 void AddToTaskManager(BackgroundContents* background_contents, 46 void AddToTaskManager(BackgroundContents* background_contents,
73 const string16& title); 47 const string16& title);
74 48
75 // 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
76 // notifications sent after StopUpdating(). 50 // notifications sent after StopUpdating().
77 bool updating_; 51 bool updating_;
78 52
79 TaskManager* task_manager_; 53 TaskManager* task_manager_;
80 54
81 // Maps the actual resources (the BackgroundContents) to the Task Manager 55 // Maps the actual resources (the BackgroundContents) to the Task Manager
82 // resources. 56 // resources.
83 typedef std::map<BackgroundContents*, TaskManagerBackgroundContentsResource*> 57 typedef std::map<BackgroundContents*, BackgroundContentsResource*>
84 Resources; 58 Resources;
85 Resources resources_; 59 Resources resources_;
86 60
87 // A scoped container for notification registries. 61 // A scoped container for notification registries.
88 content::NotificationRegistrar registrar_; 62 content::NotificationRegistrar registrar_;
89 63
90 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResourceProvider); 64 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsResourceProvider);
91 }; 65 };
92 66
93 #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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698