Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / task_manager / renderer_resource.cc
blob0c1f40c9cbc000b9c38b66535fb07399fc1fc220
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 "chrome/common/render_messages.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/common/service_registry.h"
18 namespace task_manager {
20 RendererResource::RendererResource(base::ProcessHandle process,
21 content::RenderViewHost* render_view_host)
22 : process_(process), render_view_host_(render_view_host) {
23 // We cache the process and pid as when a Tab/BackgroundContents is closed the
24 // process reference becomes NULL and the TaskManager still needs it.
25 unique_process_id_ = render_view_host_->GetProcess()->GetID();
26 ResourceUsageReporterPtr service;
27 content::ServiceRegistry* service_registry =
28 render_view_host_->GetProcess()->GetServiceRegistry();
29 if (service_registry)
30 service_registry->ConnectToRemoteService(mojo::GetProxy(&service));
31 process_resource_usage_.reset(new ProcessResourceUsage(service.Pass()));
34 RendererResource::~RendererResource() {
37 void RendererResource::Refresh() {
38 process_resource_usage_->Refresh(base::Closure());
41 blink::WebCache::ResourceTypeStats
42 RendererResource::GetWebCoreCacheStats() const {
43 return process_resource_usage_->GetWebCoreCacheStats();
46 size_t RendererResource::GetV8MemoryAllocated() const {
47 return process_resource_usage_->GetV8MemoryAllocated();
50 size_t RendererResource::GetV8MemoryUsed() const {
51 return process_resource_usage_->GetV8MemoryUsed();
54 base::string16 RendererResource::GetProfileName() const {
55 return util::GetProfileNameFromInfoCache(Profile::FromBrowserContext(
56 render_view_host_->GetProcess()->GetBrowserContext()));
59 base::ProcessHandle RendererResource::GetProcess() const {
60 return process_;
63 int RendererResource::GetUniqueChildProcessId() const {
64 return unique_process_id_;
67 Resource::Type RendererResource::GetType() const {
68 return RENDERER;
71 int RendererResource::GetRoutingID() const {
72 return render_view_host_->GetRoutingID();
75 bool RendererResource::ReportsCacheStats() const {
76 return true;
79 bool RendererResource::ReportsV8MemoryStats() const {
80 return true;
83 bool RendererResource::SupportNetworkUsage() const {
84 return true;
87 } // namespace task_manager