renderer_resource.h revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
1a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// found in the LICENSE file. 4a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ 7a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 8a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)#include "base/basictypes.h" 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/task_manager/resource_provider.h" 10a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 11a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)namespace content { 12a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)class RenderViewHost; 13a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)} 14a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace task_manager { 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 17a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// Base class for various types of render process resources that provides common 18a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)// functionality like stats tracking. 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class RendererResource : public Resource { 20a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) public: 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) RendererResource(base::ProcessHandle process, 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) content::RenderViewHost* render_view_host); 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual ~RendererResource(); 24a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Resource methods: 26a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual base::ProcessHandle GetProcess() const OVERRIDE; 27a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual int GetUniqueChildProcessId() const OVERRIDE; 28a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual Type GetType() const OVERRIDE; 29a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual int GetRoutingID() const OVERRIDE; 30a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 31a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool ReportsCacheStats() const OVERRIDE; 32a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual WebKit::WebCache::ResourceTypeStats GetWebCoreCacheStats() const 33a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) OVERRIDE; 34a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool ReportsFPS() const OVERRIDE; 35a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual float GetFPS() const OVERRIDE; 36a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool ReportsV8MemoryStats() const OVERRIDE; 37a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual size_t GetV8MemoryAllocated() const OVERRIDE; 38a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual size_t GetV8MemoryUsed() const OVERRIDE; 39a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 40a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // RenderResources are always inspectable. 41a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool CanInspect() const OVERRIDE; 42a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void Inspect() const OVERRIDE; 43a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 44a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // RenderResources always provide the network usage. 45a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual bool SupportNetworkUsage() const OVERRIDE; 46a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void SetSupportNetworkUsage() OVERRIDE { } 47a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 48a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void Refresh() OVERRIDE; 49a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 50a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void NotifyResourceTypeStats( 51a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) const WebKit::WebCache::ResourceTypeStats& stats) OVERRIDE; 52a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 53a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void NotifyFPS(float fps) OVERRIDE; 54a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 55a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) virtual void NotifyV8HeapStats(size_t v8_memory_allocated, 56a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) size_t v8_memory_used) OVERRIDE; 57a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 58a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) content::RenderViewHost* render_view_host() const { 59a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) return render_view_host_; 60a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) } 61a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 62a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) private: 63a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) base::ProcessHandle process_; 64a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int pid_; 65a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) int unique_process_id_; 66a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 67a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // RenderViewHost we use to fetch stats. 68a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) content::RenderViewHost* render_view_host_; 69a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // The stats_ field holds information about resource usage in the renderer 70a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // process and so it is updated asynchronously by the Refresh() call. 71a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) WebKit::WebCache::ResourceTypeStats stats_; 72a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This flag is true if we are waiting for the renderer to report its stats. 73a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool pending_stats_update_; 74a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 75a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // The fps_ field holds the renderer frames per second. 76a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) float fps_; 77a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // This flag is true if we are waiting for the renderer to report its FPS. 78a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool pending_fps_update_; 79a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 80a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) // We do a similar dance to gather the V8 memory usage in a process. 81a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) size_t v8_memory_allocated_; 82a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) size_t v8_memory_used_; 83a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) bool pending_v8_memory_allocated_update_; 84a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RendererResource); 86a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles)}; 87a93a17c8d99d686bd4a1511e5504e5e6cc9fcadfTorne (Richard Coles) 8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace task_manager 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ 91