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

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

Issue 11418260: Make TaskManagerTabContentsResource explicitly handle prerendering and instant pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: instaaaaant Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_RESOURCE_PROVIDERS_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "chrome/browser/task_manager/task_manager.h" 14 #include "chrome/browser/task_manager/task_manager.h"
15 #include "content/public/browser/child_process_data.h" 15 #include "content/public/browser/child_process_data.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/common/process_type.h" 18 #include "content/public/common/process_type.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
20 20
21 class BackgroundContents; 21 class BackgroundContents;
22 class BalloonHost; 22 class BalloonHost;
23 class TabContents;
24 class Panel; 23 class Panel;
24 class Profile;
25 25
26 namespace content { 26 namespace content {
27 class RenderViewHost; 27 class RenderViewHost;
28 class WebContents;
28 } 29 }
29 30
30 namespace extensions { 31 namespace extensions {
31 class Extension; 32 class Extension;
32 } 33 }
33 34
34 // These file contains the resource providers used in the task manager. 35 // These file contains the resource providers used in the task manager.
35 36
36 // Base class for various types of render process resources that provides common 37 // Base class for various types of render process resources that provides common
37 // functionality like stats tracking. 38 // functionality like stats tracking.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool pending_fps_update_; 98 bool pending_fps_update_;
98 99
99 // We do a similar dance to gather the V8 memory usage in a process. 100 // We do a similar dance to gather the V8 memory usage in a process.
100 size_t v8_memory_allocated_; 101 size_t v8_memory_allocated_;
101 size_t v8_memory_used_; 102 size_t v8_memory_used_;
102 bool pending_v8_memory_allocated_update_; 103 bool pending_v8_memory_allocated_update_;
103 104
104 DISALLOW_COPY_AND_ASSIGN(TaskManagerRendererResource); 105 DISALLOW_COPY_AND_ASSIGN(TaskManagerRendererResource);
105 }; 106 };
106 107
108 // Tracks a single tab contents, prerendered page, or instant page.
107 class TaskManagerTabContentsResource : public TaskManagerRendererResource { 109 class TaskManagerTabContentsResource : public TaskManagerRendererResource {
108 public: 110 public:
109 explicit TaskManagerTabContentsResource(TabContents* tab_contents); 111 explicit TaskManagerTabContentsResource(content::WebContents* web_contents);
110 virtual ~TaskManagerTabContentsResource(); 112 virtual ~TaskManagerTabContentsResource();
111 113
112 // Called when the underlying tab_contents has been committed, and is thus no 114 // Called when the underlying web_contents has been committed and is no
113 // longer an Instant preview. 115 // longer an Instant preview.
114 void InstantCommitted(); 116 void InstantCommitted();
115 117
116 // TaskManager::Resource methods: 118 // TaskManager::Resource methods:
117 virtual Type GetType() const OVERRIDE; 119 virtual Type GetType() const OVERRIDE;
118 virtual string16 GetTitle() const OVERRIDE; 120 virtual string16 GetTitle() const OVERRIDE;
119 virtual string16 GetProfileName() const OVERRIDE; 121 virtual string16 GetProfileName() const OVERRIDE;
120 virtual gfx::ImageSkia GetIcon() const OVERRIDE; 122 virtual gfx::ImageSkia GetIcon() const OVERRIDE;
121 virtual content::WebContents* GetWebContents() const OVERRIDE; 123 virtual content::WebContents* GetWebContents() const OVERRIDE;
122 virtual const extensions::Extension* GetExtension() const OVERRIDE; 124 virtual const extensions::Extension* GetExtension() const OVERRIDE;
123 125
124 private: 126 private:
125 bool IsPrerendering() const;
126
127 // Returns true if contains content rendered by an extension. 127 // Returns true if contains content rendered by an extension.
128 bool HostsExtension() const; 128 bool HostsExtension() const;
129 129
130 static gfx::ImageSkia* prerender_icon_; 130 static gfx::ImageSkia* prerender_icon_;
131 TabContents* tab_contents_; 131 content::WebContents* web_contents_;
132 Profile* profile_;
132 bool is_instant_preview_; 133 bool is_instant_preview_;
133 134
134 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource); 135 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResource);
135 }; 136 };
136 137
138 // Provides resources for tab contents, prerendered pages, and instant pages.
137 class TaskManagerTabContentsResourceProvider 139 class TaskManagerTabContentsResourceProvider
138 : public TaskManager::ResourceProvider, 140 : public TaskManager::ResourceProvider,
139 public content::NotificationObserver { 141 public content::NotificationObserver {
140 public: 142 public:
141 explicit TaskManagerTabContentsResourceProvider(TaskManager* task_manager); 143 explicit TaskManagerTabContentsResourceProvider(TaskManager* task_manager);
142 144
143 virtual TaskManager::Resource* GetResource(int origin_pid, 145 virtual TaskManager::Resource* GetResource(int origin_pid,
144 int render_process_host_id, 146 int render_process_host_id,
145 int routing_id) OVERRIDE; 147 int routing_id) OVERRIDE;
146 virtual void StartUpdating() OVERRIDE; 148 virtual void StartUpdating() OVERRIDE;
147 virtual void StopUpdating() OVERRIDE; 149 virtual void StopUpdating() OVERRIDE;
148 150
149 // content::NotificationObserver method: 151 // content::NotificationObserver method:
150 virtual void Observe(int type, 152 virtual void Observe(int type,
151 const content::NotificationSource& source, 153 const content::NotificationSource& source,
152 const content::NotificationDetails& details) OVERRIDE; 154 const content::NotificationDetails& details) OVERRIDE;
153 155
154 private: 156 private:
155 virtual ~TaskManagerTabContentsResourceProvider(); 157 virtual ~TaskManagerTabContentsResourceProvider();
156 158
157 void Add(TabContents* tab_contents); 159 void Add(content::WebContents* web_contents);
158 void Remove(TabContents* tab_contents); 160 void Remove(content::WebContents* web_contents);
159 void Update(TabContents* tab_contents); 161 void InstantCommitted(content::WebContents* web_contents);
160 162
161 void AddToTaskManager(TabContents* tab_contents); 163 void AddToTaskManager(content::WebContents* web_contents);
162 164
163 // Whether we are currently reporting to the task manager. Used to ignore 165 // Whether we are currently reporting to the task manager. Used to ignore
164 // notifications sent after StopUpdating(). 166 // notifications sent after StopUpdating().
165 bool updating_; 167 bool updating_;
166 168
167 TaskManager* task_manager_; 169 TaskManager* task_manager_;
168 170
169 // Maps the actual resources (the TabContentses) to the Task Manager 171 // Maps the actual resources (the WebContentses) to the Task Manager
170 // resources. 172 // resources.
171 std::map<TabContents*, TaskManagerTabContentsResource*> resources_; 173 std::map<content::WebContents*, TaskManagerTabContentsResource*> resources_;
172 174
173 // A scoped container for notification registries. 175 // A scoped container for notification registries.
174 content::NotificationRegistrar registrar_; 176 content::NotificationRegistrar registrar_;
175 177
176 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResourceProvider); 178 DISALLOW_COPY_AND_ASSIGN(TaskManagerTabContentsResourceProvider);
177 }; 179 };
178 180
179 class TaskManagerPanelResource : public TaskManagerRendererResource { 181 class TaskManagerPanelResource : public TaskManagerRendererResource {
180 public: 182 public:
181 explicit TaskManagerPanelResource(Panel* panel); 183 explicit TaskManagerPanelResource(Panel* panel);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 TaskManagerGuestResource*> GuestResourceMap; 674 TaskManagerGuestResource*> GuestResourceMap;
673 GuestResourceMap resources_; 675 GuestResourceMap resources_;
674 676
675 // A scoped container for notification registries. 677 // A scoped container for notification registries.
676 content::NotificationRegistrar registrar_; 678 content::NotificationRegistrar registrar_;
677 679
678 DISALLOW_COPY_AND_ASSIGN(TaskManagerGuestResourceProvider); 680 DISALLOW_COPY_AND_ASSIGN(TaskManagerGuestResourceProvider);
679 }; 681 };
680 682
681 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_ 683 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RESOURCE_PROVIDERS_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | chrome/browser/task_manager/task_manager_resource_providers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698