diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 01:57:53 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 01:57:53 +0000 |
commit | 4306c379b6950cd71d016d345beedc5884158af4 (patch) | |
tree | c99e60d36cb4f55469667b9855b91398e991d22d /chrome/browser/task_manager | |
parent | 5aa9c09bfbe70e1e87642c2333e54cffaa71838c (diff) | |
download | chromium_src-4306c379b6950cd71d016d345beedc5884158af4.zip chromium_src-4306c379b6950cd71d016d345beedc5884158af4.tar.gz chromium_src-4306c379b6950cd71d016d345beedc5884158af4.tar.bz2 |
Get rid of the ChildProcessInfo class. It was carrying unnecessary data, and the fact that some processes inherited from it was confusing. There's now a simpler struct, content::ChildProcessData. BrowserChildProcessHost uses composition instead of inheritence.
BUG=98716
Review URL: http://codereview.chromium.org/8770027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112597 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager')
3 files changed, 48 insertions, 55 deletions
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc index 8e1cc11..7b3658f 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager/task_manager_resource_providers.cc @@ -787,7 +787,7 @@ base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { } TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { - // Translate types to TaskManager::ResourceType, since ChildProcessInfo's type + // Translate types to TaskManager::ResourceType, since ChildProcessData's type // is not available for all TaskManager resources. switch (type_) { case content::PROCESS_TYPE_PLUGIN: @@ -924,7 +924,7 @@ void TaskManagerChildProcessResourceProvider::StartUpdating() { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( - &TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo, + &TaskManagerChildProcessResourceProvider::RetrieveChildProcessData, this)); } @@ -952,11 +952,8 @@ void TaskManagerChildProcessResourceProvider::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - content::Details<ChildProcessInfo> child_details(details); - ChildProcessData data; - data.type = child_details->type(); - data.name = child_details->name(); - data.handle = child_details->handle(); + content::ChildProcessData data = + *content::Details<content::ChildProcessData>(details).ptr(); switch (type) { case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: Add(data); @@ -971,7 +968,7 @@ void TaskManagerChildProcessResourceProvider::Observe( } void TaskManagerChildProcessResourceProvider::Add( - const ChildProcessData& child_process_data) { + const content::ChildProcessData& child_process_data) { if (!updating_) return; // Workers are handled by TaskManagerWorkerResourceProvider. @@ -988,14 +985,14 @@ void TaskManagerChildProcessResourceProvider::Add( } void TaskManagerChildProcessResourceProvider::Remove( - const ChildProcessData& child_process_data) { + const content::ChildProcessData& child_process_data) { if (!updating_) return; if (child_process_data.type == content::PROCESS_TYPE_WORKER) return; ChildProcessMap::iterator iter = resources_.find(child_process_data.handle); if (iter == resources_.end()) { - // ChildProcessInfo disconnection notifications are asynchronous, so we + // ChildProcessData disconnection notifications are asynchronous, so we // might be notified for a plugin we don't know anything about (if it was // closed before the task manager was shown and destroyed after that). return; @@ -1017,7 +1014,7 @@ void TaskManagerChildProcessResourceProvider::Remove( } void TaskManagerChildProcessResourceProvider::AddToTaskManager( - const ChildProcessData& child_process_data) { + const content::ChildProcessData& child_process_data) { TaskManagerChildProcessResource* resource = new TaskManagerChildProcessResource( child_process_data.type, @@ -1028,14 +1025,14 @@ void TaskManagerChildProcessResourceProvider::AddToTaskManager( task_manager_->AddResource(resource); } -// The ChildProcessInfo::Iterator has to be used from the IO thread. -void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() { - std::vector<ChildProcessData> child_processes; +// The ChildProcessData::Iterator has to be used from the IO thread. +void TaskManagerChildProcessResourceProvider::RetrieveChildProcessData() { + std::vector<content::ChildProcessData> child_processes; for (BrowserChildProcessHost::Iterator iter; !iter.Done(); ++iter) { // Only add processes which are already started, since we need their handle. if ((*iter)->handle() == base::kNullProcessHandle) continue; - ChildProcessData data; + content::ChildProcessData data; data.type = (*iter)->type(); data.name = (*iter)->name(); data.handle = (*iter)->handle(); @@ -1046,13 +1043,13 @@ void TaskManagerChildProcessResourceProvider::RetrieveChildProcessInfo() { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( - &TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived, + &TaskManagerChildProcessResourceProvider::ChildProcessDataRetreived, this, child_processes)); } // This is called on the UI thread. -void TaskManagerChildProcessResourceProvider::ChildProcessInfoRetreived( - const std::vector<ChildProcessData>& child_processes) { +void TaskManagerChildProcessResourceProvider::ChildProcessDataRetreived( + const std::vector<content::ChildProcessData>& child_processes) { for (size_t i = 0; i < child_processes.size(); ++i) Add(child_processes[i]); } diff --git a/chrome/browser/task_manager/task_manager_resource_providers.h b/chrome/browser/task_manager/task_manager_resource_providers.h index fea7e64..6999afb 100644 --- a/chrome/browser/task_manager/task_manager_resource_providers.h +++ b/chrome/browser/task_manager/task_manager_resource_providers.h @@ -13,6 +13,7 @@ #include "base/compiler_specific.h" #include "base/process_util.h" #include "chrome/browser/task_manager/task_manager.h" +#include "content/public/browser/child_process_data.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/common/process_type.h" @@ -288,27 +289,21 @@ class TaskManagerChildProcessResourceProvider const content::NotificationDetails& details) OVERRIDE; private: - struct ChildProcessData { - content::ProcessType type; - string16 name; - base::ProcessHandle handle; - }; - virtual ~TaskManagerChildProcessResourceProvider(); // Retrieves information about the running ChildProcessHosts (performed in the // IO thread). - virtual void RetrieveChildProcessInfo(); + virtual void RetrieveChildProcessData(); // Notifies the UI thread that the ChildProcessHosts information have been // retrieved. - virtual void ChildProcessInfoRetreived( - const std::vector<ChildProcessData>& child_processes); + virtual void ChildProcessDataRetreived( + const std::vector<content::ChildProcessData>& child_processes); - void Add(const ChildProcessData& child_process_data); - void Remove(const ChildProcessData& child_process_data); + void Add(const content::ChildProcessData& child_process_data); + void Remove(const content::ChildProcessData& child_process_data); - void AddToTaskManager(const ChildProcessData& child_process_data); + void AddToTaskManager(const content::ChildProcessData& child_process_data); TaskManager* task_manager_; @@ -316,7 +311,7 @@ class TaskManagerChildProcessResourceProvider // notifications sent after StopUpdating(). bool updating_; - // Maps the actual resources (the ChildProcessInfo) to the Task Manager + // Maps the actual resources (the ChildProcessData) to the Task Manager // resources. typedef std::map<base::ProcessHandle, TaskManagerChildProcessResource*> ChildProcessMap; diff --git a/chrome/browser/task_manager/task_manager_worker_resource_provider.cc b/chrome/browser/task_manager/task_manager_worker_resource_provider.cc index 734da89..5331486 100644 --- a/chrome/browser/task_manager/task_manager_worker_resource_provider.cc +++ b/chrome/browser/task_manager/task_manager_worker_resource_provider.cc @@ -16,10 +16,10 @@ #include "content/browser/worker_host/worker_service.h" #include "content/browser/worker_host/worker_service_observer.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/child_process_data.h" #include "content/public/browser/devtools_agent_host_registry.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" -#include "content/public/common/process_type.h" #include "grit/generated_resources.h" #include "grit/theme_resources_standard.h" #include "ui/base/l10n/l10n_util.h" @@ -34,15 +34,15 @@ using content::DevToolsAgentHostRegistry; // only on the UI thread. Destructor may be called on any thread. class TaskManagerSharedWorkerResource : public TaskManager::Resource { public: - TaskManagerSharedWorkerResource(const ChildProcessInfo& process_info, + TaskManagerSharedWorkerResource(const content::ChildProcessData& process_data, int routing_id, const GURL& url, const string16& name); virtual ~TaskManagerSharedWorkerResource(); bool Matches(int process_id, int routing_id) const; - void UpdateProcessInfo(const ChildProcessInfo& process_info); - const ChildProcessInfo& process_info() { return process_info_; } + void UpdateProcessData(const content::ChildProcessData& process_data); + const content::ChildProcessData& process_data() { return process_data_; } private: // TaskManager::Resource methods: @@ -57,7 +57,7 @@ class TaskManagerSharedWorkerResource : public TaskManager::Resource { virtual bool SupportNetworkUsage() const OVERRIDE; virtual void SetSupportNetworkUsage() OVERRIDE; - ChildProcessInfo process_info_; + content::ChildProcessData process_data_; int routing_id_; string16 title_; @@ -69,11 +69,11 @@ class TaskManagerSharedWorkerResource : public TaskManager::Resource { SkBitmap* TaskManagerSharedWorkerResource::default_icon_ = NULL; TaskManagerSharedWorkerResource::TaskManagerSharedWorkerResource( - const ChildProcessInfo& process_info, + const content::ChildProcessData& process_data, int routing_id, const GURL& url, const string16& name) - : process_info_(process_info), + : process_data_(process_data), routing_id_(routing_id) { title_ = UTF8ToUTF16(url.spec()); if (!name.empty()) @@ -85,12 +85,12 @@ TaskManagerSharedWorkerResource::~TaskManagerSharedWorkerResource() { bool TaskManagerSharedWorkerResource::Matches(int process_id, int routing_id) const { - return process_info_.id() == process_id && routing_id_ == routing_id; + return process_data_.id == process_id && routing_id_ == routing_id; } -void TaskManagerSharedWorkerResource::UpdateProcessInfo( - const ChildProcessInfo& process_info) { - process_info_ = process_info; +void TaskManagerSharedWorkerResource::UpdateProcessData( + const content::ChildProcessData& process_data) { + process_data_ = process_data; } string16 TaskManagerSharedWorkerResource::GetTitle() const { @@ -111,7 +111,7 @@ SkBitmap TaskManagerSharedWorkerResource::GetIcon() const { } base::ProcessHandle TaskManagerSharedWorkerResource::GetProcess() const { - return process_info_.handle(); + return process_data_.handle; } TaskManager::Resource::Type TaskManagerSharedWorkerResource::GetType() const { @@ -130,7 +130,7 @@ void TaskManagerSharedWorkerResource::Inspect() const { return; DevToolsAgentHost* agent_host = DevToolsAgentHostRegistry::GetDevToolsAgentHostForWorker( - process_info_.id(), + process_data_.id, routing_id_); DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); } @@ -217,7 +217,8 @@ void TaskManagerWorkerResourceProvider::WorkerCreated( WorkerProcessHost* process, const WorkerProcessHost::WorkerInstance& instance) { TaskManagerSharedWorkerResource* resource = - new TaskManagerSharedWorkerResource(*process, instance.worker_route_id(), + new TaskManagerSharedWorkerResource(process->data(), + instance.worker_route_id(), instance.url(), instance.name()); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -238,19 +239,19 @@ void TaskManagerWorkerResourceProvider::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { - ChildProcessInfo* process_info = - content::Details<ChildProcessInfo>(details).ptr(); - if (process_info->type() != content::PROCESS_TYPE_WORKER) + content::ChildProcessData* process_data = + content::Details<content::ChildProcessData>(details).ptr(); + if (process_data->type != content::PROCESS_TYPE_WORKER) return; if (type == content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED) { ProcessIdToWorkerResources::iterator it = - launching_workers_.find(process_info->id()); + launching_workers_.find(process_data->id); if (it == launching_workers_.end()) return; WorkerResourceList& resources = it->second; for (WorkerResourceList::iterator r = resources.begin(); r !=resources.end(); ++r) { - (*r)->UpdateProcessInfo(*process_info); + (*r)->UpdateProcessData(*process_data); task_manager_->AddResource(*r); } launching_workers_.erase(it); @@ -261,7 +262,7 @@ void TaskManagerWorkerResourceProvider::Observe( // workers here when the worker process has been destroyed. for (WorkerResourceList::iterator it = resources_.begin(); it !=resources_.end();) { - if ((*it)->process_info().id() == process_info->id()) { + if ((*it)->process_data().id == process_data->id) { task_manager_->RemoveResource(*it); delete *it; it = resources_.erase(it); @@ -269,7 +270,7 @@ void TaskManagerWorkerResourceProvider::Observe( ++it; } } - DCHECK(launching_workers_.find(process_info->id()) == + DCHECK(launching_workers_.find(process_data->id) == launching_workers_.end()); } } @@ -309,7 +310,7 @@ void TaskManagerWorkerResourceProvider::StartObservingWorkers() { for (WorkerProcessHost::Instances::const_iterator i = instances.begin(); i != instances.end(); ++i) { holder->resources()->push_back(new TaskManagerSharedWorkerResource( - **iter, i->worker_route_id(), i->url(), i->name())); + (*iter)->data(), i->worker_route_id(), i->url(), i->name())); } } @@ -343,8 +344,8 @@ void TaskManagerWorkerResourceProvider::AddResource( TaskManagerSharedWorkerResource* resource) { DCHECK(updating_); resources_.push_back(resource); - if (resource->process_info().handle() == base::kNullProcessHandle) { - int process_id = resource->process_info().id(); + if (resource->process_data().handle == base::kNullProcessHandle) { + int process_id = resource->process_data().id; launching_workers_[process_id].push_back(resource); } else { task_manager_->AddResource(resource); |