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

Side by Side Diff: chrome/browser/task_manager/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
(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_BACKGROUND_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BACKGROUND_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 class BackgroundContents;
19
20 class TaskManagerBackgroundContentsResource
21 : public TaskManagerRendererResource {
22 public:
23 TaskManagerBackgroundContentsResource(
24 BackgroundContents* background_contents,
25 const string16& application_name);
26 virtual ~TaskManagerBackgroundContentsResource();
27
28 // TaskManager::Resource methods:
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
34 const string16& application_name() const { return application_name_; }
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,
50 public content::NotificationObserver {
51 public:
52 explicit TaskManagerBackgroundContentsResourceProvider(
53 TaskManager* task_manager);
54
55 virtual TaskManager::Resource* GetResource(int origin_pid,
56 int render_process_host_id,
57 int routing_id) OVERRIDE;
58 virtual void StartUpdating() OVERRIDE;
59 virtual void StopUpdating() OVERRIDE;
60
61 // content::NotificationObserver method:
62 virtual void Observe(int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) OVERRIDE;
65
66 private:
67 virtual ~TaskManagerBackgroundContentsResourceProvider();
68
69 void Add(BackgroundContents* background_contents, const string16& title);
70 void Remove(BackgroundContents* background_contents);
71
72 void AddToTaskManager(BackgroundContents* background_contents,
73 const string16& title);
74
75 // Whether we are currently reporting to the task manager. Used to ignore
76 // notifications sent after StopUpdating().
77 bool updating_;
78
79 TaskManager* task_manager_;
80
81 // Maps the actual resources (the BackgroundContents) to the Task Manager
82 // resources.
83 typedef std::map<BackgroundContents*, TaskManagerBackgroundContentsResource*>
84 Resources;
85 Resources resources_;
86
87 // A scoped container for notification registries.
88 content::NotificationRegistrar registrar_;
89
90 DISALLOW_COPY_AND_ASSIGN(TaskManagerBackgroundContentsResourceProvider);
91 };
92
93 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698