OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RENDER_RESOURCE_H_ | |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RENDER_RESOURCE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "chrome/browser/task_manager/task_manager.h" | |
10 #include "content/public/browser/render_view_host_observer.h" | |
11 | |
12 namespace content { | |
13 class RenderViewHost; | |
14 } | |
15 | |
16 // Base class for various types of render process resources that provides common | |
17 // functionality like stats tracking. | |
18 class TaskManagerRendererResource : public TaskManager::Resource, | |
19 public content::RenderViewHostObserver { | |
20 public: | |
21 TaskManagerRendererResource(base::ProcessHandle process, | |
22 content::RenderViewHost* render_view_host); | |
23 virtual ~TaskManagerRendererResource(); | |
24 | |
25 // TaskManager::Resource methods: | |
26 virtual base::ProcessHandle GetProcess() const OVERRIDE; | |
27 virtual int GetUniqueChildProcessId() const OVERRIDE; | |
28 virtual Type GetType() const OVERRIDE; | |
29 virtual int GetRoutingID() const OVERRIDE; | |
30 | |
31 virtual bool ReportsCacheStats() const OVERRIDE; | |
32 virtual WebKit::WebCache::ResourceTypeStats GetWebCoreCacheStats() const | |
33 OVERRIDE; | |
34 virtual bool ReportsFPS() const OVERRIDE; | |
35 virtual float GetFPS() const OVERRIDE; | |
36 virtual bool ReportsV8MemoryStats() const OVERRIDE; | |
37 virtual size_t GetV8MemoryAllocated() const OVERRIDE; | |
38 virtual size_t GetV8MemoryUsed() const OVERRIDE; | |
39 | |
40 // RenderResources are always inspectable. | |
41 virtual bool CanInspect() const OVERRIDE; | |
42 virtual void Inspect() const OVERRIDE; | |
43 | |
44 // RenderResources always provide the network usage. | |
45 virtual bool SupportNetworkUsage() const OVERRIDE; | |
46 virtual void SetSupportNetworkUsage() OVERRIDE { } | |
47 | |
48 virtual void Refresh() OVERRIDE; | |
49 | |
50 virtual void NotifyResourceTypeStats( | |
51 const WebKit::WebCache::ResourceTypeStats& stats) OVERRIDE; | |
52 | |
53 virtual void NotifyFPS(float fps) OVERRIDE; | |
54 | |
55 virtual void NotifyV8HeapStats(size_t v8_memory_allocated, | |
56 size_t v8_memory_used) OVERRIDE; | |
57 | |
58 // content::RenderViewHostObserver implementation. | |
59 virtual void RenderViewHostDestroyed( | |
60 content::RenderViewHost* render_view_host) OVERRIDE; | |
61 | |
62 content::RenderViewHost* render_view_host() const { | |
63 return render_view_host_; | |
64 } | |
65 | |
66 private: | |
67 base::ProcessHandle process_; | |
68 int pid_; | |
69 int unique_process_id_; | |
70 | |
71 // RenderViewHost we use to fetch stats. | |
72 content::RenderViewHost* render_view_host_; | |
73 // The stats_ field holds information about resource usage in the renderer | |
74 // process and so it is updated asynchronously by the Refresh() call. | |
75 WebKit::WebCache::ResourceTypeStats stats_; | |
76 // This flag is true if we are waiting for the renderer to report its stats. | |
77 bool pending_stats_update_; | |
78 | |
79 // The fps_ field holds the renderer frames per second. | |
80 float fps_; | |
81 // This flag is true if we are waiting for the renderer to report its FPS. | |
82 bool pending_fps_update_; | |
83 | |
84 // We do a similar dance to gather the V8 memory usage in a process. | |
85 size_t v8_memory_allocated_; | |
86 size_t v8_memory_used_; | |
87 bool pending_v8_memory_allocated_update_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(TaskManagerRendererResource); | |
90 }; | |
91 | |
92 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_RENDER_RESOURCE_H_ | |
OLD | NEW |