Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / task_manager / renderer_resource.cc
blob8539663c596b35d732e315fe82829af58c95c25f
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/profiles/profile.h"
10 #include "chrome/browser/task_manager/resource_provider.h"
11 #include "chrome/browser/task_manager/task_manager_util.h"
12 #include "chrome/common/render_messages.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h"
16 namespace task_manager {
18 RendererResource::RendererResource(base::ProcessHandle process,
19 content::RenderViewHost* render_view_host)
20 : process_(process),
21 render_view_host_(render_view_host),
22 pending_stats_update_(false),
23 v8_memory_allocated_(0),
24 v8_memory_used_(0),
25 pending_v8_memory_allocated_update_(false) {
26 // We cache the process and pid as when a Tab/BackgroundContents is closed the
27 // process reference becomes NULL and the TaskManager still needs it.
28 pid_ = base::GetProcId(process_);
29 unique_process_id_ = render_view_host_->GetProcess()->GetID();
30 memset(&stats_, 0, sizeof(stats_));
33 RendererResource::~RendererResource() {
36 void RendererResource::Refresh() {
37 if (!pending_stats_update_) {
38 render_view_host_->Send(new ChromeViewMsg_GetCacheResourceStats);
39 pending_stats_update_ = true;
41 if (!pending_v8_memory_allocated_update_) {
42 render_view_host_->Send(new ChromeViewMsg_GetV8HeapStats);
43 pending_v8_memory_allocated_update_ = true;
47 blink::WebCache::ResourceTypeStats
48 RendererResource::GetWebCoreCacheStats() const {
49 return stats_;
52 size_t RendererResource::GetV8MemoryAllocated() const {
53 return v8_memory_allocated_;
56 size_t RendererResource::GetV8MemoryUsed() const {
57 return v8_memory_used_;
60 void RendererResource::NotifyResourceTypeStats(
61 const blink::WebCache::ResourceTypeStats& stats) {
62 stats_ = stats;
63 pending_stats_update_ = false;
66 void RendererResource::NotifyV8HeapStats(
67 size_t v8_memory_allocated, size_t v8_memory_used) {
68 v8_memory_allocated_ = v8_memory_allocated;
69 v8_memory_used_ = v8_memory_used;
70 pending_v8_memory_allocated_update_ = false;
73 base::string16 RendererResource::GetProfileName() const {
74 return util::GetProfileNameFromInfoCache(Profile::FromBrowserContext(
75 render_view_host_->GetProcess()->GetBrowserContext()));
78 base::ProcessHandle RendererResource::GetProcess() const {
79 return process_;
82 int RendererResource::GetUniqueChildProcessId() const {
83 return unique_process_id_;
86 Resource::Type RendererResource::GetType() const {
87 return RENDERER;
90 int RendererResource::GetRoutingID() const {
91 return render_view_host_->GetRoutingID();
94 bool RendererResource::ReportsCacheStats() const {
95 return true;
98 bool RendererResource::ReportsV8MemoryStats() const {
99 return true;
102 bool RendererResource::SupportNetworkUsage() const {
103 return true;
106 } // namespace task_manager