QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / chrome / browser / task_manager / renderer_resource.cc
blob51f0dc15f8a5dc958810616c98249c1326d06504
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/task_manager/renderer_resource.h"
7 #include "base/basictypes.h"
8 #include "chrome/browser/devtools/devtools_window.h"
9 #include "chrome/browser/process_resource_usage.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/task_manager/resource_provider.h"
12 #include "chrome/browser/task_manager/task_manager_util.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/common/service_registry.h"
17 namespace task_manager {
19 RendererResource::RendererResource(base::ProcessHandle process,
20 content::RenderViewHost* render_view_host)
21 : process_(process), render_view_host_(render_view_host) {
22 // We cache the process and pid as when a Tab/BackgroundContents is closed the
23 // process reference becomes NULL and the TaskManager still needs it.
24 unique_process_id_ = render_view_host_->GetProcess()->GetID();
25 ResourceUsageReporterPtr service;
26 content::ServiceRegistry* service_registry =
27 render_view_host_->GetProcess()->GetServiceRegistry();
28 if (service_registry)
29 service_registry->ConnectToRemoteService(mojo::GetProxy(&service));
30 process_resource_usage_.reset(new ProcessResourceUsage(service.Pass()));
33 RendererResource::~RendererResource() {
36 void RendererResource::Refresh() {
37 process_resource_usage_->Refresh(base::Closure());
40 blink::WebCache::ResourceTypeStats
41 RendererResource::GetWebCoreCacheStats() const {
42 return process_resource_usage_->GetWebCoreCacheStats();
45 size_t RendererResource::GetV8MemoryAllocated() const {
46 return process_resource_usage_->GetV8MemoryAllocated();
49 size_t RendererResource::GetV8MemoryUsed() const {
50 return process_resource_usage_->GetV8MemoryUsed();
53 base::string16 RendererResource::GetProfileName() const {
54 return util::GetProfileNameFromInfoCache(Profile::FromBrowserContext(
55 render_view_host_->GetProcess()->GetBrowserContext()));
58 base::ProcessHandle RendererResource::GetProcess() const {
59 return process_;
62 int RendererResource::GetUniqueChildProcessId() const {
63 return unique_process_id_;
66 Resource::Type RendererResource::GetType() const {
67 return RENDERER;
70 int RendererResource::GetRoutingID() const {
71 return render_view_host_->GetRoutingID();
74 bool RendererResource::ReportsCacheStats() const {
75 return true;
78 bool RendererResource::ReportsV8MemoryStats() const {
79 return true;
82 bool RendererResource::SupportNetworkUsage() const {
83 return true;
86 } // namespace task_manager