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

Side by Side Diff: chrome/browser/task_manager/worker_resource_provider.cc

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: Rebase 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
« no previous file with comments | « chrome/browser/task_manager/worker_resource_provider.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" 5 #include "chrome/browser/task_manager/worker_resource_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/devtools/devtools_window.h" 12 #include "chrome/browser/devtools/devtools_window.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/chrome_process_type.h" 14 #include "chrome/common/chrome_process_type.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/child_process_data.h" 16 #include "content/public/browser/child_process_data.h"
17 #include "content/public/browser/devtools_agent_host.h" 17 #include "content/public/browser/devtools_agent_host.h"
18 #include "content/public/browser/worker_service.h" 18 #include "content/public/browser/worker_service.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
24 24
25 using content::BrowserThread; 25 using content::BrowserThread;
26 using content::DevToolsAgentHost; 26 using content::DevToolsAgentHost;
27 using content::WorkerService; 27 using content::WorkerService;
28 28
29 //////////////////////////////////////////////////////////////////////////////// 29 namespace task_manager {
30 // TaskManagerSharedWorkerResource class
31 ////////////////////////////////////////////////////////////////////////////////
32 30
33 // Objects of this class are created on the IO thread and then passed to the UI 31 // Objects of this class are created on the IO thread and then passed to the UI
34 // thread where they are passed to the task manager. All methods must be called 32 // thread where they are passed to the task manager. All methods must be called
35 // only on the UI thread. Destructor may be called on any thread. 33 // only on the UI thread. Destructor may be called on any thread.
36 class TaskManagerSharedWorkerResource : public TaskManager::Resource { 34 class SharedWorkerResource : public TaskManager::Resource {
37 public: 35 public:
38 TaskManagerSharedWorkerResource(const GURL& url, 36 SharedWorkerResource(const GURL& url,
39 const string16& name, 37 const string16& name,
40 int process_id, 38 int process_id,
41 int routing_id, 39 int routing_id,
42 base::ProcessHandle process_handle); 40 base::ProcessHandle process_handle);
43 virtual ~TaskManagerSharedWorkerResource(); 41 virtual ~SharedWorkerResource();
44 42
45 bool Matches(int process_id, int routing_id) const; 43 bool Matches(int process_id, int routing_id) const;
46 44
47 void UpdateProcessHandle(base::ProcessHandle handle); 45 void UpdateProcessHandle(base::ProcessHandle handle);
48 base::ProcessHandle handle() const { return handle_; } 46 base::ProcessHandle handle() const { return handle_; }
49 int process_id() const { return process_id_; } 47 int process_id() const { return process_id_; }
50 48
51 private: 49 private:
52 // TaskManager::Resource methods: 50 // TaskManager::Resource methods:
53 virtual string16 GetTitle() const OVERRIDE; 51 virtual string16 GetTitle() const OVERRIDE;
54 virtual string16 GetProfileName() const OVERRIDE; 52 virtual string16 GetProfileName() const OVERRIDE;
55 virtual gfx::ImageSkia GetIcon() const OVERRIDE; 53 virtual gfx::ImageSkia GetIcon() const OVERRIDE;
56 virtual base::ProcessHandle GetProcess() const OVERRIDE; 54 virtual base::ProcessHandle GetProcess() const OVERRIDE;
57 virtual int GetUniqueChildProcessId() const OVERRIDE; 55 virtual int GetUniqueChildProcessId() const OVERRIDE;
58 virtual Type GetType() const OVERRIDE; 56 virtual Type GetType() const OVERRIDE;
59 virtual bool CanInspect() const OVERRIDE; 57 virtual bool CanInspect() const OVERRIDE;
60 virtual void Inspect() const OVERRIDE; 58 virtual void Inspect() const OVERRIDE;
61 59
62 virtual bool SupportNetworkUsage() const OVERRIDE; 60 virtual bool SupportNetworkUsage() const OVERRIDE;
63 virtual void SetSupportNetworkUsage() OVERRIDE; 61 virtual void SetSupportNetworkUsage() OVERRIDE;
64 62
65 int process_id_; 63 int process_id_;
66 int routing_id_; 64 int routing_id_;
67 string16 title_; 65 string16 title_;
68 base::ProcessHandle handle_; 66 base::ProcessHandle handle_;
69 67
70 static gfx::ImageSkia* default_icon_; 68 static gfx::ImageSkia* default_icon_;
71 69
72 DISALLOW_COPY_AND_ASSIGN(TaskManagerSharedWorkerResource); 70 DISALLOW_COPY_AND_ASSIGN(SharedWorkerResource);
73 }; 71 };
74 72
75 gfx::ImageSkia* TaskManagerSharedWorkerResource::default_icon_ = NULL; 73 gfx::ImageSkia* SharedWorkerResource::default_icon_ = NULL;
76 74
77 TaskManagerSharedWorkerResource::TaskManagerSharedWorkerResource( 75 SharedWorkerResource::SharedWorkerResource(
78 const GURL& url, 76 const GURL& url,
79 const string16& name, 77 const string16& name,
80 int process_id, 78 int process_id,
81 int routing_id, 79 int routing_id,
82 base::ProcessHandle process_handle) 80 base::ProcessHandle process_handle)
83 : process_id_(process_id), 81 : process_id_(process_id),
84 routing_id_(routing_id), 82 routing_id_(routing_id),
85 handle_(process_handle) { 83 handle_(process_handle) {
86 title_ = UTF8ToUTF16(url.spec()); 84 title_ = UTF8ToUTF16(url.spec());
87 if (!name.empty()) 85 if (!name.empty())
88 title_ += ASCIIToUTF16(" (") + name + ASCIIToUTF16(")"); 86 title_ += ASCIIToUTF16(" (") + name + ASCIIToUTF16(")");
89 } 87 }
90 88
91 TaskManagerSharedWorkerResource::~TaskManagerSharedWorkerResource() { 89 SharedWorkerResource::~SharedWorkerResource() {
92 } 90 }
93 91
94 bool TaskManagerSharedWorkerResource::Matches(int process_id, 92 bool SharedWorkerResource::Matches(int process_id,
95 int routing_id) const { 93 int routing_id) const {
96 return process_id_ == process_id && routing_id_ == routing_id; 94 return process_id_ == process_id && routing_id_ == routing_id;
97 } 95 }
98 96
99 void TaskManagerSharedWorkerResource::UpdateProcessHandle( 97 void SharedWorkerResource::UpdateProcessHandle(base::ProcessHandle handle) {
100 base::ProcessHandle handle) {
101 handle_ = handle; 98 handle_ = handle;
102 } 99 }
103 100
104 string16 TaskManagerSharedWorkerResource::GetTitle() const { 101 string16 SharedWorkerResource::GetTitle() const {
105 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title_); 102 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title_);
106 } 103 }
107 104
108 string16 TaskManagerSharedWorkerResource::GetProfileName() const { 105 string16 SharedWorkerResource::GetProfileName() const {
109 return string16(); 106 return string16();
110 } 107 }
111 108
112 gfx::ImageSkia TaskManagerSharedWorkerResource::GetIcon() const { 109 gfx::ImageSkia SharedWorkerResource::GetIcon() const {
113 if (!default_icon_) { 110 if (!default_icon_) {
114 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 111 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
115 default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON); 112 default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGINS_FAVICON);
116 // TODO(jabdelmalek): use different icon for web workers. 113 // TODO(jabdelmalek): use different icon for web workers.
117 } 114 }
118 return *default_icon_; 115 return *default_icon_;
119 } 116 }
120 117
121 base::ProcessHandle TaskManagerSharedWorkerResource::GetProcess() const { 118 base::ProcessHandle SharedWorkerResource::GetProcess() const {
122 return handle_; 119 return handle_;
123 } 120 }
124 121
125 int TaskManagerSharedWorkerResource::GetUniqueChildProcessId() const { 122 int SharedWorkerResource::GetUniqueChildProcessId() const {
126 return process_id_; 123 return process_id_;
127 } 124 }
128 125
129 TaskManager::Resource::Type TaskManagerSharedWorkerResource::GetType() const { 126 TaskManager::Resource::Type SharedWorkerResource::GetType() const {
130 return WORKER; 127 return WORKER;
131 } 128 }
132 129
133 bool TaskManagerSharedWorkerResource::CanInspect() const { 130 bool SharedWorkerResource::CanInspect() const {
134 return true; 131 return true;
135 } 132 }
136 133
137 void TaskManagerSharedWorkerResource::Inspect() const { 134 void SharedWorkerResource::Inspect() const {
138 // TODO(yurys): would be better to get profile from one of the tabs connected 135 // TODO(yurys): would be better to get profile from one of the tabs connected
139 // to the worker. 136 // to the worker.
140 Profile* profile = ProfileManager::GetLastUsedProfile(); 137 Profile* profile = ProfileManager::GetLastUsedProfile();
141 if (!profile) 138 if (!profile)
142 return; 139 return;
143 scoped_refptr<DevToolsAgentHost> agent_host( 140 scoped_refptr<DevToolsAgentHost> agent_host(
144 DevToolsAgentHost::GetForWorker(process_id_, routing_id_)); 141 DevToolsAgentHost::GetForWorker(process_id_, routing_id_));
145 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); 142 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host);
146 } 143 }
147 144
148 bool TaskManagerSharedWorkerResource::SupportNetworkUsage() const { 145 bool SharedWorkerResource::SupportNetworkUsage() const {
149 return false; 146 return false;
150 } 147 }
151 148
152 void TaskManagerSharedWorkerResource::SetSupportNetworkUsage() { 149 void SharedWorkerResource::SetSupportNetworkUsage() {
153 } 150 }
154 151
155 152
156 // This class is needed to ensure that all resources in WorkerResourceList are 153 // This class is needed to ensure that all resources in WorkerResourceList are
157 // deleted if corresponding task is posted to but not executed on the UI 154 // deleted if corresponding task is posted to but not executed on the UI
158 // thread. 155 // thread.
159 class TaskManagerWorkerResourceProvider::WorkerResourceListHolder { 156 class WorkerResourceProvider::WorkerResourceListHolder {
160 public: 157 public:
161 WorkerResourceListHolder() { 158 WorkerResourceListHolder() {
162 } 159 }
163 160
164 ~WorkerResourceListHolder() { 161 ~WorkerResourceListHolder() {
165 STLDeleteElements(&resources_); 162 STLDeleteElements(&resources_);
166 } 163 }
167 164
168 WorkerResourceList* resources() { 165 WorkerResourceList* resources() {
169 return &resources_; 166 return &resources_;
170 } 167 }
171 168
172 private: 169 private:
173 WorkerResourceList resources_; 170 WorkerResourceList resources_;
174 }; 171 };
175 172
176 173
177 TaskManagerWorkerResourceProvider:: 174 WorkerResourceProvider::
178 TaskManagerWorkerResourceProvider(TaskManager* task_manager) 175 WorkerResourceProvider(TaskManager* task_manager)
179 : updating_(false), 176 : updating_(false),
180 task_manager_(task_manager) { 177 task_manager_(task_manager) {
181 } 178 }
182 179
183 TaskManagerWorkerResourceProvider::~TaskManagerWorkerResourceProvider() { 180 WorkerResourceProvider::~WorkerResourceProvider() {
184 DeleteAllResources(); 181 DeleteAllResources();
185 } 182 }
186 183
187 TaskManager::Resource* TaskManagerWorkerResourceProvider::GetResource( 184 TaskManager::Resource* WorkerResourceProvider::GetResource(
188 int origin_pid, 185 int origin_pid,
189 int render_process_host_id, 186 int render_process_host_id,
190 int routing_id) { 187 int routing_id) {
191 return NULL; 188 return NULL;
192 } 189 }
193 190
194 void TaskManagerWorkerResourceProvider::StartUpdating() { 191 void WorkerResourceProvider::StartUpdating() {
195 DCHECK(!updating_); 192 DCHECK(!updating_);
196 updating_ = true; 193 updating_ = true;
197 // Get existing workers. 194 // Get existing workers.
198 BrowserThread::PostTask( 195 BrowserThread::PostTask(
199 BrowserThread::IO, FROM_HERE, base::Bind( 196 BrowserThread::IO, FROM_HERE, base::Bind(
200 &TaskManagerWorkerResourceProvider::StartObservingWorkers, 197 &WorkerResourceProvider::StartObservingWorkers,
201 this)); 198 this));
202 199
203 BrowserChildProcessObserver::Add(this); 200 BrowserChildProcessObserver::Add(this);
204 } 201 }
205 202
206 void TaskManagerWorkerResourceProvider::StopUpdating() { 203 void WorkerResourceProvider::StopUpdating() {
207 DCHECK(updating_); 204 DCHECK(updating_);
208 updating_ = false; 205 updating_ = false;
209 launching_workers_.clear(); 206 launching_workers_.clear();
210 DeleteAllResources(); 207 DeleteAllResources();
211 BrowserThread::PostTask( 208 BrowserThread::PostTask(
212 BrowserThread::IO, FROM_HERE, base::Bind( 209 BrowserThread::IO, FROM_HERE, base::Bind(
213 &TaskManagerWorkerResourceProvider::StopObservingWorkers, 210 &WorkerResourceProvider::StopObservingWorkers,
214 this)); 211 this));
215 212
216 BrowserChildProcessObserver::Remove(this); 213 BrowserChildProcessObserver::Remove(this);
217 } 214 }
218 215
219 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostConnected( 216 void WorkerResourceProvider::BrowserChildProcessHostConnected(
220 const content::ChildProcessData& data) { 217 const content::ChildProcessData& data) {
221 DCHECK(updating_); 218 DCHECK(updating_);
222 219
223 if (data.process_type != content::PROCESS_TYPE_WORKER) 220 if (data.process_type != content::PROCESS_TYPE_WORKER)
224 return; 221 return;
225 222
226 ProcessIdToWorkerResources::iterator it(launching_workers_.find(data.id)); 223 ProcessIdToWorkerResources::iterator it(launching_workers_.find(data.id));
227 if (it == launching_workers_.end()) 224 if (it == launching_workers_.end())
228 return; 225 return;
229 WorkerResourceList& resources = it->second; 226 WorkerResourceList& resources = it->second;
230 for (WorkerResourceList::iterator r = resources.begin(); 227 for (WorkerResourceList::iterator r = resources.begin();
231 r != resources.end(); ++r) { 228 r != resources.end(); ++r) {
232 (*r)->UpdateProcessHandle(data.handle); 229 (*r)->UpdateProcessHandle(data.handle);
233 task_manager_->AddResource(*r); 230 task_manager_->AddResource(*r);
234 } 231 }
235 launching_workers_.erase(it); 232 launching_workers_.erase(it);
236 } 233 }
237 234
238 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostDisconnected( 235 void WorkerResourceProvider::BrowserChildProcessHostDisconnected(
239 const content::ChildProcessData& data) { 236 const content::ChildProcessData& data) {
240 DCHECK(updating_); 237 DCHECK(updating_);
241 238
242 if (data.process_type != content::PROCESS_TYPE_WORKER) 239 if (data.process_type != content::PROCESS_TYPE_WORKER)
243 return; 240 return;
244 241
245 // Worker process may be destroyed before WorkerMsg_TerminateWorkerContex 242 // Worker process may be destroyed before WorkerMsg_TerminateWorkerContex
246 // message is handled and WorkerDestroyed is fired. In this case we won't 243 // message is handled and WorkerDestroyed is fired. In this case we won't
247 // get WorkerDestroyed notification and have to clear resources for such 244 // get WorkerDestroyed notification and have to clear resources for such
248 // workers here when the worker process has been destroyed. 245 // workers here when the worker process has been destroyed.
249 for (WorkerResourceList::iterator it = resources_.begin(); 246 for (WorkerResourceList::iterator it = resources_.begin();
250 it != resources_.end();) { 247 it != resources_.end();) {
251 if ((*it)->process_id() == data.id) { 248 if ((*it)->process_id() == data.id) {
252 task_manager_->RemoveResource(*it); 249 task_manager_->RemoveResource(*it);
253 delete *it; 250 delete *it;
254 it = resources_.erase(it); 251 it = resources_.erase(it);
255 } else { 252 } else {
256 ++it; 253 ++it;
257 } 254 }
258 } 255 }
259 DCHECK(!ContainsKey(launching_workers_, data.id)); 256 DCHECK(!ContainsKey(launching_workers_, data.id));
260 } 257 }
261 258
262 void TaskManagerWorkerResourceProvider::WorkerCreated( 259 void WorkerResourceProvider::WorkerCreated(
263 const GURL& url, 260 const GURL& url,
264 const string16& name, 261 const string16& name,
265 int process_id, 262 int process_id,
266 int route_id) { 263 int route_id) {
267 TaskManagerSharedWorkerResource* resource = 264 SharedWorkerResource* resource = new SharedWorkerResource(
268 new TaskManagerSharedWorkerResource( 265 url, name, process_id, route_id, base::kNullProcessHandle);
269 url, name, process_id, route_id, base::kNullProcessHandle);
270 BrowserThread::PostTask( 266 BrowserThread::PostTask(
271 BrowserThread::UI, FROM_HERE, 267 BrowserThread::UI, FROM_HERE,
272 base::Bind(&TaskManagerWorkerResourceProvider::NotifyWorkerCreated, 268 base::Bind(&WorkerResourceProvider::NotifyWorkerCreated,
273 this, base::Owned(new WorkerResourceHolder(resource)))); 269 this, base::Owned(new WorkerResourceHolder(resource))));
274 } 270 }
275 271
276 void TaskManagerWorkerResourceProvider::WorkerDestroyed(int process_id, 272 void WorkerResourceProvider::WorkerDestroyed(int process_id, int route_id) {
277 int route_id) {
278 BrowserThread::PostTask( 273 BrowserThread::PostTask(
279 BrowserThread::UI, FROM_HERE, base::Bind( 274 BrowserThread::UI, FROM_HERE, base::Bind(
280 &TaskManagerWorkerResourceProvider::NotifyWorkerDestroyed, 275 &WorkerResourceProvider::NotifyWorkerDestroyed,
281 this, process_id, route_id)); 276 this, process_id, route_id));
282 } 277 }
283 278
284 void TaskManagerWorkerResourceProvider::NotifyWorkerCreated( 279 void WorkerResourceProvider::NotifyWorkerCreated(
285 WorkerResourceHolder* resource_holder) { 280 WorkerResourceHolder* resource_holder) {
286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
287 if (!updating_) 282 if (!updating_)
288 return; 283 return;
289 AddResource(resource_holder->release()); 284 AddResource(resource_holder->release());
290 } 285 }
291 286
292 void TaskManagerWorkerResourceProvider::NotifyWorkerDestroyed( 287 void WorkerResourceProvider::NotifyWorkerDestroyed(
293 int process_id, int routing_id) { 288 int process_id, int routing_id) {
294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
295 if (!updating_) 290 if (!updating_)
296 return; 291 return;
297 for (WorkerResourceList::iterator it = resources_.begin(); 292 for (WorkerResourceList::iterator it = resources_.begin();
298 it !=resources_.end(); ++it) { 293 it !=resources_.end(); ++it) {
299 if ((*it)->Matches(process_id, routing_id)) { 294 if ((*it)->Matches(process_id, routing_id)) {
300 task_manager_->RemoveResource(*it); 295 task_manager_->RemoveResource(*it);
301 delete *it; 296 delete *it;
302 resources_.erase(it); 297 resources_.erase(it);
303 return; 298 return;
304 } 299 }
305 } 300 }
306 } 301 }
307 302
308 void TaskManagerWorkerResourceProvider::StartObservingWorkers() { 303 void WorkerResourceProvider::StartObservingWorkers() {
309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
310 305
311 scoped_ptr<WorkerResourceListHolder> holder(new WorkerResourceListHolder); 306 scoped_ptr<WorkerResourceListHolder> holder(new WorkerResourceListHolder);
312 std::vector<WorkerService::WorkerInfo> worker_info = 307 std::vector<WorkerService::WorkerInfo> worker_info =
313 WorkerService::GetInstance()->GetWorkers(); 308 WorkerService::GetInstance()->GetWorkers();
314 309
315 for (size_t i = 0; i < worker_info.size(); ++i) { 310 for (size_t i = 0; i < worker_info.size(); ++i) {
316 holder->resources()->push_back(new TaskManagerSharedWorkerResource( 311 holder->resources()->push_back(new SharedWorkerResource(
317 worker_info[i].url, worker_info[i].name, worker_info[i].process_id, 312 worker_info[i].url, worker_info[i].name, worker_info[i].process_id,
318 worker_info[i].route_id, worker_info[i].handle)); 313 worker_info[i].route_id, worker_info[i].handle));
319 } 314 }
320 315
321 BrowserThread::PostTask( 316 BrowserThread::PostTask(
322 BrowserThread::UI, FROM_HERE, 317 BrowserThread::UI, FROM_HERE,
323 base::Bind( 318 base::Bind(
324 &TaskManagerWorkerResourceProvider::AddWorkerResourceList, 319 &WorkerResourceProvider::AddWorkerResourceList,
325 this, base::Owned(holder.release()))); 320 this, base::Owned(holder.release())));
326 321
327 WorkerService::GetInstance()->AddObserver(this); 322 WorkerService::GetInstance()->AddObserver(this);
328 } 323 }
329 324
330 void TaskManagerWorkerResourceProvider::StopObservingWorkers() { 325 void WorkerResourceProvider::StopObservingWorkers() {
331 WorkerService::GetInstance()->RemoveObserver(this); 326 WorkerService::GetInstance()->RemoveObserver(this);
332 } 327 }
333 328
334 void TaskManagerWorkerResourceProvider::AddWorkerResourceList( 329 void WorkerResourceProvider::AddWorkerResourceList(
335 WorkerResourceListHolder* resource_list_holder) { 330 WorkerResourceListHolder* resource_list_holder) {
336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
337 if (!updating_) 332 if (!updating_)
338 return; 333 return;
339 WorkerResourceList* resources = resource_list_holder->resources(); 334 WorkerResourceList* resources = resource_list_holder->resources();
340 for (WorkerResourceList::iterator it = resources->begin(); 335 for (WorkerResourceList::iterator it = resources->begin();
341 it !=resources->end(); ++it) { 336 it !=resources->end(); ++it) {
342 AddResource(*it); 337 AddResource(*it);
343 } 338 }
344 resources->clear(); 339 resources->clear();
345 } 340 }
346 341
347 void TaskManagerWorkerResourceProvider::AddResource( 342 void WorkerResourceProvider::AddResource(SharedWorkerResource* resource) {
348 TaskManagerSharedWorkerResource* resource) {
349 DCHECK(updating_); 343 DCHECK(updating_);
350 resources_.push_back(resource); 344 resources_.push_back(resource);
351 if (resource->handle() == base::kNullProcessHandle) { 345 if (resource->handle() == base::kNullProcessHandle) {
352 int process_id = resource->process_id(); 346 int process_id = resource->process_id();
353 launching_workers_[process_id].push_back(resource); 347 launching_workers_[process_id].push_back(resource);
354 } else { 348 } else {
355 task_manager_->AddResource(resource); 349 task_manager_->AddResource(resource);
356 } 350 }
357 } 351 }
358 352
359 void TaskManagerWorkerResourceProvider::DeleteAllResources() { 353 void WorkerResourceProvider::DeleteAllResources() {
360 STLDeleteElements(&resources_); 354 STLDeleteElements(&resources_);
361 } 355 }
356
357 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/worker_resource_provider.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698