| Index: chrome/browser/task_manager/child_process_resource_provider.cc
|
| diff --git a/chrome/browser/task_manager/task_manager_child_process_resource_provider.cc b/chrome/browser/task_manager/child_process_resource_provider.cc
|
| similarity index 72%
|
| rename from chrome/browser/task_manager/task_manager_child_process_resource_provider.cc
|
| rename to chrome/browser/task_manager/child_process_resource_provider.cc
|
| index 45ef2cd10f13af637e48ddafe5c8ede57e2b9084..92d52b0cc8ae010b868cd9e71af28f3813071cfb 100644
|
| --- a/chrome/browser/task_manager/task_manager_child_process_resource_provider.cc
|
| +++ b/chrome/browser/task_manager/child_process_resource_provider.cc
|
| @@ -2,19 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/task_manager/task_manager_child_process_resource_provider.h"
|
| +#include "chrome/browser/task_manager/child_process_resource_provider.h"
|
| +
|
| +#include <vector>
|
|
|
| -#include "base/basictypes.h"
|
| #include "base/i18n/rtl.h"
|
| #include "base/string16.h"
|
| -#include "base/utf_string_conversions.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/chrome_process_type.h"
|
| #include "content/public/browser/browser_child_process_host_iterator.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/child_process_data.h"
|
| #include "content/public/browser/notification_service.h"
|
| -#include "content/public/browser/web_contents.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -25,12 +24,53 @@ using content::BrowserChildProcessHostIterator;
|
| using content::BrowserThread;
|
| using content::WebContents;
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// TaskManagerChildProcessResource class
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -gfx::ImageSkia* TaskManagerChildProcessResource::default_icon_ = NULL;
|
| -
|
| -TaskManagerChildProcessResource::TaskManagerChildProcessResource(
|
| +namespace task_manager {
|
| +
|
| +class ChildProcessResource : public TaskManager::Resource {
|
| + public:
|
| + ChildProcessResource(int process_type,
|
| + const string16& name,
|
| + base::ProcessHandle handle,
|
| + int unique_process_id);
|
| + virtual ~ChildProcessResource();
|
| +
|
| + // TaskManager::Resource methods:
|
| + virtual string16 GetTitle() const OVERRIDE;
|
| + virtual string16 GetProfileName() const OVERRIDE;
|
| + virtual gfx::ImageSkia GetIcon() const OVERRIDE;
|
| + virtual base::ProcessHandle GetProcess() const OVERRIDE;
|
| + virtual int GetUniqueChildProcessId() const OVERRIDE;
|
| + virtual Type GetType() const OVERRIDE;
|
| + virtual bool SupportNetworkUsage() const OVERRIDE;
|
| + virtual void SetSupportNetworkUsage() OVERRIDE;
|
| +
|
| + // Returns the pid of the child process.
|
| + int process_id() const { return pid_; }
|
| +
|
| + private:
|
| + // Returns a localized title for the child process. For example, a plugin
|
| + // process would be "Plug-in: Flash" when name is "Flash".
|
| + string16 GetLocalizedTitle() const;
|
| +
|
| + int process_type_;
|
| + string16 name_;
|
| + base::ProcessHandle handle_;
|
| + int pid_;
|
| + int unique_process_id_;
|
| + mutable string16 title_;
|
| + bool network_usage_support_;
|
| +
|
| + // The icon painted for the child processs.
|
| + // TODO(jcampan): we should have plugin specific icons for well-known
|
| + // plugins.
|
| + static gfx::ImageSkia* default_icon_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChildProcessResource);
|
| +};
|
| +
|
| +gfx::ImageSkia* ChildProcessResource::default_icon_ = NULL;
|
| +
|
| +ChildProcessResource::ChildProcessResource(
|
| int process_type,
|
| const string16& name,
|
| base::ProcessHandle handle,
|
| @@ -50,34 +90,34 @@ TaskManagerChildProcessResource::TaskManagerChildProcessResource(
|
| }
|
| }
|
|
|
| -TaskManagerChildProcessResource::~TaskManagerChildProcessResource() {
|
| +ChildProcessResource::~ChildProcessResource() {
|
| }
|
|
|
| // TaskManagerResource methods:
|
| -string16 TaskManagerChildProcessResource::GetTitle() const {
|
| +string16 ChildProcessResource::GetTitle() const {
|
| if (title_.empty())
|
| title_ = GetLocalizedTitle();
|
|
|
| return title_;
|
| }
|
|
|
| -string16 TaskManagerChildProcessResource::GetProfileName() const {
|
| +string16 ChildProcessResource::GetProfileName() const {
|
| return string16();
|
| }
|
|
|
| -gfx::ImageSkia TaskManagerChildProcessResource::GetIcon() const {
|
| +gfx::ImageSkia ChildProcessResource::GetIcon() const {
|
| return *default_icon_;
|
| }
|
|
|
| -base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const {
|
| +base::ProcessHandle ChildProcessResource::GetProcess() const {
|
| return handle_;
|
| }
|
|
|
| -int TaskManagerChildProcessResource::GetUniqueChildProcessId() const {
|
| +int ChildProcessResource::GetUniqueChildProcessId() const {
|
| return unique_process_id_;
|
| }
|
|
|
| -TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const {
|
| +TaskManager::Resource::Type ChildProcessResource::GetType() const {
|
| // Translate types to TaskManager::ResourceType, since ChildProcessData's type
|
| // is not available for all TaskManager resources.
|
| switch (process_type_) {
|
| @@ -103,15 +143,15 @@ TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const {
|
| }
|
| }
|
|
|
| -bool TaskManagerChildProcessResource::SupportNetworkUsage() const {
|
| +bool ChildProcessResource::SupportNetworkUsage() const {
|
| return network_usage_support_;
|
| }
|
|
|
| -void TaskManagerChildProcessResource::SetSupportNetworkUsage() {
|
| +void ChildProcessResource::SetSupportNetworkUsage() {
|
| network_usage_support_ = true;
|
| }
|
|
|
| -string16 TaskManagerChildProcessResource::GetLocalizedTitle() const {
|
| +string16 ChildProcessResource::GetLocalizedTitle() const {
|
| string16 title = name_;
|
| if (title.empty()) {
|
| switch (process_type_) {
|
| @@ -169,20 +209,19 @@ string16 TaskManagerChildProcessResource::GetLocalizedTitle() const {
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// TaskManagerChildProcessResourceProvider class
|
| +// ChildProcessResourceProvider class
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -TaskManagerChildProcessResourceProvider::
|
| - TaskManagerChildProcessResourceProvider(TaskManager* task_manager)
|
| +ChildProcessResourceProvider::
|
| + ChildProcessResourceProvider(TaskManager* task_manager)
|
| : task_manager_(task_manager),
|
| updating_(false) {
|
| }
|
|
|
| -TaskManagerChildProcessResourceProvider::
|
| - ~TaskManagerChildProcessResourceProvider() {
|
| +ChildProcessResourceProvider::~ChildProcessResourceProvider() {
|
| }
|
|
|
| -TaskManager::Resource* TaskManagerChildProcessResourceProvider::GetResource(
|
| +TaskManager::Resource* ChildProcessResourceProvider::GetResource(
|
| int origin_pid,
|
| int render_process_host_id,
|
| int routing_id) {
|
| @@ -193,7 +232,7 @@ TaskManager::Resource* TaskManagerChildProcessResourceProvider::GetResource(
|
| return NULL;
|
| }
|
|
|
| -void TaskManagerChildProcessResourceProvider::StartUpdating() {
|
| +void ChildProcessResourceProvider::StartUpdating() {
|
| DCHECK(!updating_);
|
| updating_ = true;
|
|
|
| @@ -201,13 +240,13 @@ void TaskManagerChildProcessResourceProvider::StartUpdating() {
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| base::Bind(
|
| - &TaskManagerChildProcessResourceProvider::RetrieveChildProcessData,
|
| + &ChildProcessResourceProvider::RetrieveChildProcessData,
|
| this));
|
|
|
| BrowserChildProcessObserver::Add(this);
|
| }
|
|
|
| -void TaskManagerChildProcessResourceProvider::StopUpdating() {
|
| +void ChildProcessResourceProvider::StopUpdating() {
|
| DCHECK(updating_);
|
| updating_ = false;
|
|
|
| @@ -220,7 +259,7 @@ void TaskManagerChildProcessResourceProvider::StopUpdating() {
|
| BrowserChildProcessObserver::Remove(this);
|
| }
|
|
|
| -void TaskManagerChildProcessResourceProvider::BrowserChildProcessHostConnected(
|
| +void ChildProcessResourceProvider::BrowserChildProcessHostConnected(
|
| const content::ChildProcessData& data) {
|
| DCHECK(updating_);
|
|
|
| @@ -237,8 +276,9 @@ void TaskManagerChildProcessResourceProvider::BrowserChildProcessHostConnected(
|
| AddToTaskManager(data);
|
| }
|
|
|
| -void TaskManagerChildProcessResourceProvider::
|
| -BrowserChildProcessHostDisconnected(const content::ChildProcessData& data) {
|
| +void ChildProcessResourceProvider::
|
| + BrowserChildProcessHostDisconnected(
|
| + const content::ChildProcessData& data) {
|
| DCHECK(updating_);
|
|
|
| if (data.process_type == content::PROCESS_TYPE_WORKER)
|
| @@ -251,7 +291,7 @@ BrowserChildProcessHostDisconnected(const content::ChildProcessData& data) {
|
| return;
|
| }
|
| // Remove the resource from the Task Manager.
|
| - TaskManagerChildProcessResource* resource = iter->second;
|
| + ChildProcessResource* resource = iter->second;
|
| task_manager_->RemoveResource(resource);
|
| // Remove it from the provider.
|
| resources_.erase(iter);
|
| @@ -266,10 +306,10 @@ BrowserChildProcessHostDisconnected(const content::ChildProcessData& data) {
|
| delete resource;
|
| }
|
|
|
| -void TaskManagerChildProcessResourceProvider::AddToTaskManager(
|
| +void ChildProcessResourceProvider::AddToTaskManager(
|
| const content::ChildProcessData& child_process_data) {
|
| - TaskManagerChildProcessResource* resource =
|
| - new TaskManagerChildProcessResource(
|
| + ChildProcessResource* resource =
|
| + new ChildProcessResource(
|
| child_process_data.process_type,
|
| child_process_data.name,
|
| child_process_data.handle,
|
| @@ -280,7 +320,7 @@ void TaskManagerChildProcessResourceProvider::AddToTaskManager(
|
| }
|
|
|
| // The ChildProcessData::Iterator has to be used from the IO thread.
|
| -void TaskManagerChildProcessResourceProvider::RetrieveChildProcessData() {
|
| +void ChildProcessResourceProvider::RetrieveChildProcessData() {
|
| std::vector<content::ChildProcessData> child_processes;
|
| for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
|
| // Only add processes which are already started, since we need their handle.
|
| @@ -295,18 +335,20 @@ void TaskManagerChildProcessResourceProvider::RetrieveChildProcessData() {
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(
|
| - &TaskManagerChildProcessResourceProvider::ChildProcessDataRetreived,
|
| + &ChildProcessResourceProvider::ChildProcessDataRetreived,
|
| this, child_processes));
|
| }
|
|
|
| // This is called on the UI thread.
|
| -void TaskManagerChildProcessResourceProvider::ChildProcessDataRetreived(
|
| +void ChildProcessResourceProvider::ChildProcessDataRetreived(
|
| const std::vector<content::ChildProcessData>& child_processes) {
|
| for (size_t i = 0; i < child_processes.size(); ++i)
|
| AddToTaskManager(child_processes[i]);
|
|
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_TASK_MANAGER_CHILD_PROCESSES_DATA_READY,
|
| - content::Source<TaskManagerChildProcessResourceProvider>(this),
|
| + content::Source<ChildProcessResourceProvider>(this),
|
| content::NotificationService::NoDetails());
|
| }
|
| +
|
| +} // namespace task_manager
|
|
|