Index: chrome/browser/task_manager/child_process_resource_provider.cc |
diff --git a/chrome/browser/task_manager/child_process_resource_provider.cc b/chrome/browser/task_manager/child_process_resource_provider.cc |
index bf74138859e5f6f83281fd1ff163b236542c0d3f..e8408356e5f2165bc283f84c8a85f22d1b03abbf 100644 |
--- a/chrome/browser/task_manager/child_process_resource_provider.cc |
+++ b/chrome/browser/task_manager/child_process_resource_provider.cc |
@@ -15,6 +15,7 @@ |
#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/process_resource_usage.h" |
#include "grit/theme_resources.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -22,16 +23,19 @@ |
using content::BrowserChildProcessHostIterator; |
using content::BrowserThread; |
+using content::ProcessResourceUsage; |
using content::WebContents; |
namespace task_manager { |
class ChildProcessResource : public Resource { |
public: |
- ChildProcessResource(int process_type, |
- const base::string16& name, |
- base::ProcessHandle handle, |
- int unique_process_id); |
+ ChildProcessResource( |
+ int process_type, |
+ const base::string16& name, |
+ base::ProcessHandle handle, |
+ int unique_process_id, |
+ const scoped_refptr<ProcessResourceUsage>& resource_usage); |
~ChildProcessResource() override; |
// Resource methods: |
@@ -43,6 +47,10 @@ class ChildProcessResource : public Resource { |
Type GetType() const override; |
bool SupportNetworkUsage() const override; |
void SetSupportNetworkUsage() override; |
+ void Refresh() override; |
+ bool ReportsV8MemoryStats() const override; |
+ size_t GetV8MemoryAllocated() const override; |
+ size_t GetV8MemoryUsed() const override; |
// Returns the pid of the child process. |
int process_id() const { return pid_; } |
@@ -59,6 +67,7 @@ class ChildProcessResource : public Resource { |
int unique_process_id_; |
mutable base::string16 title_; |
bool network_usage_support_; |
+ scoped_refptr<ProcessResourceUsage> resource_usage_; |
// The icon painted for the child processs. |
// TODO(jcampan): we should have plugin specific icons for well-known |
@@ -74,12 +83,14 @@ ChildProcessResource::ChildProcessResource( |
int process_type, |
const base::string16& name, |
base::ProcessHandle handle, |
- int unique_process_id) |
+ int unique_process_id, |
+ const scoped_refptr<ProcessResourceUsage>& resource_usage) |
: process_type_(process_type), |
name_(name), |
handle_(handle), |
unique_process_id_(unique_process_id), |
- network_usage_support_(false) { |
+ network_usage_support_(false), |
+ resource_usage_(resource_usage) { |
ncarter (slow)
2015/05/01 21:37:58
Can you come up with a TaskManagerBrowserTest for
|
// We cache the process id because it's not cheap to calculate, and it won't |
// be available when we get the plugin disconnected notification. |
pid_ = base::GetProcId(handle); |
@@ -200,6 +211,29 @@ base::string16 ChildProcessResource::GetLocalizedTitle() const { |
return title; |
} |
+void ChildProcessResource::Refresh() { |
+ if (resource_usage_) |
+ resource_usage_->Refresh(); |
+} |
+ |
+bool ChildProcessResource::ReportsV8MemoryStats() const { |
+ if (resource_usage_) |
+ return resource_usage_->ReportsV8MemoryStats(); |
+ return false; |
+} |
+ |
+size_t ChildProcessResource::GetV8MemoryAllocated() const { |
+ if (resource_usage_) |
+ return resource_usage_->GetV8MemoryAllocated(); |
+ return 0; |
+} |
+ |
+size_t ChildProcessResource::GetV8MemoryUsed() const { |
+ if (resource_usage_) |
+ return resource_usage_->GetV8MemoryUsed(); |
+ return 0; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// ChildProcessResourceProvider class |
//////////////////////////////////////////////////////////////////////////////// |
@@ -295,12 +329,10 @@ void ChildProcessResourceProvider:: |
void ChildProcessResourceProvider::AddToTaskManager( |
const content::ChildProcessData& child_process_data) { |
- ChildProcessResource* resource = |
- new ChildProcessResource( |
- child_process_data.process_type, |
- child_process_data.name, |
- child_process_data.handle, |
- child_process_data.id); |
+ ChildProcessResource* resource = new ChildProcessResource( |
+ child_process_data.process_type, child_process_data.name, |
+ child_process_data.handle, child_process_data.id, |
+ child_process_data.process_resource_usage); |
resources_[child_process_data.handle] = resource; |
pid_to_resources_[resource->process_id()] = resource; |
task_manager_->AddResource(resource); |