| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/task_manager/resource_provider.h" | 9 #include "chrome/browser/task_manager/resource_provider.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 class RenderViewHost; | 12 class RenderViewHost; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace task_manager { | 15 namespace task_manager { |
| 16 | 16 |
| 17 // Base class for various types of render process resources that provides common | 17 // Base class for various types of render process resources that provides common |
| 18 // functionality like stats tracking. | 18 // functionality like stats tracking. |
| 19 class RendererResource : public Resource { | 19 class RendererResource : public Resource { |
| 20 public: | 20 public: |
| 21 RendererResource(base::ProcessHandle process, | 21 RendererResource(base::ProcessHandle process, |
| 22 content::RenderViewHost* render_view_host); | 22 content::RenderViewHost* render_view_host); |
| 23 virtual ~RendererResource(); | 23 ~RendererResource() override; |
| 24 | 24 |
| 25 // Resource methods: | 25 // Resource methods: |
| 26 virtual base::string16 GetProfileName() const override; | 26 base::string16 GetProfileName() const override; |
| 27 virtual base::ProcessHandle GetProcess() const override; | 27 base::ProcessHandle GetProcess() const override; |
| 28 virtual int GetUniqueChildProcessId() const override; | 28 int GetUniqueChildProcessId() const override; |
| 29 virtual Type GetType() const override; | 29 Type GetType() const override; |
| 30 virtual int GetRoutingID() const override; | 30 int GetRoutingID() const override; |
| 31 | 31 |
| 32 virtual bool ReportsCacheStats() const override; | 32 bool ReportsCacheStats() const override; |
| 33 virtual blink::WebCache::ResourceTypeStats GetWebCoreCacheStats() const | 33 blink::WebCache::ResourceTypeStats GetWebCoreCacheStats() const override; |
| 34 override; | 34 bool ReportsV8MemoryStats() const override; |
| 35 virtual bool ReportsV8MemoryStats() const override; | 35 size_t GetV8MemoryAllocated() const override; |
| 36 virtual size_t GetV8MemoryAllocated() const override; | 36 size_t GetV8MemoryUsed() const override; |
| 37 virtual size_t GetV8MemoryUsed() const override; | |
| 38 | 37 |
| 39 // RenderResources always provide the network usage. | 38 // RenderResources always provide the network usage. |
| 40 virtual bool SupportNetworkUsage() const override; | 39 bool SupportNetworkUsage() const override; |
| 41 virtual void SetSupportNetworkUsage() override { } | 40 void SetSupportNetworkUsage() override {} |
| 42 | 41 |
| 43 virtual void Refresh() override; | 42 void Refresh() override; |
| 44 | 43 |
| 45 virtual void NotifyResourceTypeStats( | 44 void NotifyResourceTypeStats( |
| 46 const blink::WebCache::ResourceTypeStats& stats) override; | 45 const blink::WebCache::ResourceTypeStats& stats) override; |
| 47 | 46 |
| 48 virtual void NotifyV8HeapStats(size_t v8_memory_allocated, | 47 void NotifyV8HeapStats(size_t v8_memory_allocated, |
| 49 size_t v8_memory_used) override; | 48 size_t v8_memory_used) override; |
| 50 | 49 |
| 51 content::RenderViewHost* render_view_host() const { | 50 content::RenderViewHost* render_view_host() const { |
| 52 return render_view_host_; | 51 return render_view_host_; |
| 53 } | 52 } |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 base::ProcessHandle process_; | 55 base::ProcessHandle process_; |
| 57 int pid_; | 56 int pid_; |
| 58 int unique_process_id_; | 57 int unique_process_id_; |
| 59 | 58 |
| 60 // RenderViewHost we use to fetch stats. | 59 // RenderViewHost we use to fetch stats. |
| 61 content::RenderViewHost* render_view_host_; | 60 content::RenderViewHost* render_view_host_; |
| 62 // The stats_ field holds information about resource usage in the renderer | 61 // The stats_ field holds information about resource usage in the renderer |
| 63 // process and so it is updated asynchronously by the Refresh() call. | 62 // process and so it is updated asynchronously by the Refresh() call. |
| 64 blink::WebCache::ResourceTypeStats stats_; | 63 blink::WebCache::ResourceTypeStats stats_; |
| 65 // This flag is true if we are waiting for the renderer to report its stats. | 64 // This flag is true if we are waiting for the renderer to report its stats. |
| 66 bool pending_stats_update_; | 65 bool pending_stats_update_; |
| 67 | 66 |
| 68 // We do a similar dance to gather the V8 memory usage in a process. | 67 // We do a similar dance to gather the V8 memory usage in a process. |
| 69 size_t v8_memory_allocated_; | 68 size_t v8_memory_allocated_; |
| 70 size_t v8_memory_used_; | 69 size_t v8_memory_used_; |
| 71 bool pending_v8_memory_allocated_update_; | 70 bool pending_v8_memory_allocated_update_; |
| 72 | 71 |
| 73 DISALLOW_COPY_AND_ASSIGN(RendererResource); | 72 DISALLOW_COPY_AND_ASSIGN(RendererResource); |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 } // namespace task_manager | 75 } // namespace task_manager |
| 77 | 76 |
| 78 #endif // CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ | 77 #endif // CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_ |
| OLD | NEW |