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

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

Issue 12662019: Split the ProcessType enum into process types that content knows about (which will remain in src\co… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 (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/task_manager_worker_resource_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.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 "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/child_process_data.h" 16 #include "content/public/browser/child_process_data.h"
16 #include "content/public/browser/devtools_agent_host.h" 17 #include "content/public/browser/devtools_agent_host.h"
17 #include "content/public/browser/worker_service.h" 18 #include "content/public/browser/worker_service.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
23 24
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 &TaskManagerWorkerResourceProvider::StopObservingWorkers, 209 &TaskManagerWorkerResourceProvider::StopObservingWorkers,
209 this)); 210 this));
210 211
211 BrowserChildProcessObserver::Remove(this); 212 BrowserChildProcessObserver::Remove(this);
212 } 213 }
213 214
214 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostConnected( 215 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostConnected(
215 const content::ChildProcessData& data) { 216 const content::ChildProcessData& data) {
216 DCHECK(updating_); 217 DCHECK(updating_);
217 218
218 if (data.type != content::PROCESS_TYPE_WORKER) 219 if (data.process_type != content::PROCESS_TYPE_WORKER)
219 return; 220 return;
220 221
221 ProcessIdToWorkerResources::iterator it(launching_workers_.find(data.id)); 222 ProcessIdToWorkerResources::iterator it(launching_workers_.find(data.id));
222 if (it == launching_workers_.end()) 223 if (it == launching_workers_.end())
223 return; 224 return;
224 WorkerResourceList& resources = it->second; 225 WorkerResourceList& resources = it->second;
225 for (WorkerResourceList::iterator r = resources.begin(); 226 for (WorkerResourceList::iterator r = resources.begin();
226 r != resources.end(); ++r) { 227 r != resources.end(); ++r) {
227 (*r)->UpdateProcessHandle(data.handle); 228 (*r)->UpdateProcessHandle(data.handle);
228 task_manager_->AddResource(*r); 229 task_manager_->AddResource(*r);
229 } 230 }
230 launching_workers_.erase(it); 231 launching_workers_.erase(it);
231 } 232 }
232 233
233 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostDisconnected( 234 void TaskManagerWorkerResourceProvider::BrowserChildProcessHostDisconnected(
234 const content::ChildProcessData& data) { 235 const content::ChildProcessData& data) {
235 DCHECK(updating_); 236 DCHECK(updating_);
236 237
237 if (data.type != content::PROCESS_TYPE_WORKER) 238 if (data.process_type != content::PROCESS_TYPE_WORKER)
238 return; 239 return;
239 240
240 // Worker process may be destroyed before WorkerMsg_TerminateWorkerContex 241 // Worker process may be destroyed before WorkerMsg_TerminateWorkerContex
241 // message is handled and WorkerDestroyed is fired. In this case we won't 242 // message is handled and WorkerDestroyed is fired. In this case we won't
242 // get WorkerDestroyed notification and have to clear resources for such 243 // get WorkerDestroyed notification and have to clear resources for such
243 // workers here when the worker process has been destroyed. 244 // workers here when the worker process has been destroyed.
244 for (WorkerResourceList::iterator it = resources_.begin(); 245 for (WorkerResourceList::iterator it = resources_.begin();
245 it != resources_.end();) { 246 it != resources_.end();) {
246 if ((*it)->process_id() == data.id) { 247 if ((*it)->process_id() == data.id) {
247 task_manager_->RemoveResource(*it); 248 task_manager_->RemoveResource(*it);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 int process_id = resource->process_id(); 348 int process_id = resource->process_id();
348 launching_workers_[process_id].push_back(resource); 349 launching_workers_[process_id].push_back(resource);
349 } else { 350 } else {
350 task_manager_->AddResource(resource); 351 task_manager_->AddResource(resource);
351 } 352 }
352 } 353 }
353 354
354 void TaskManagerWorkerResourceProvider::DeleteAllResources() { 355 void TaskManagerWorkerResourceProvider::DeleteAllResources() {
355 STLDeleteElements(&resources_); 356 STLDeleteElements(&resources_);
356 } 357 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698