Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / task_manager / renderer_resource.h
blob384c1593787a4b6722133fab6ce82e7621a249aa
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 #ifndef CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_
6 #define CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_
8 #include "base/basictypes.h"
9 #include "chrome/browser/task_manager/resource_provider.h"
11 namespace content {
12 class RenderViewHost;
15 namespace task_manager {
17 // Base class for various types of render process resources that provides common
18 // functionality like stats tracking.
19 class RendererResource : public Resource {
20 public:
21 RendererResource(base::ProcessHandle process,
22 content::RenderViewHost* render_view_host);
23 ~RendererResource() override;
25 // Resource methods:
26 base::string16 GetProfileName() const override;
27 base::ProcessHandle GetProcess() const override;
28 int GetUniqueChildProcessId() const override;
29 Type GetType() const override;
30 int GetRoutingID() const override;
32 bool ReportsCacheStats() const override;
33 blink::WebCache::ResourceTypeStats GetWebCoreCacheStats() const override;
34 bool ReportsV8MemoryStats() const override;
35 size_t GetV8MemoryAllocated() const override;
36 size_t GetV8MemoryUsed() const override;
38 // RenderResources always provide the network usage.
39 bool SupportNetworkUsage() const override;
40 void SetSupportNetworkUsage() override {}
42 void Refresh() override;
44 void NotifyResourceTypeStats(
45 const blink::WebCache::ResourceTypeStats& stats) override;
47 void NotifyV8HeapStats(size_t v8_memory_allocated,
48 size_t v8_memory_used) override;
50 content::RenderViewHost* render_view_host() const {
51 return render_view_host_;
54 private:
55 base::ProcessHandle process_;
56 int pid_;
57 int unique_process_id_;
59 // RenderViewHost we use to fetch stats.
60 content::RenderViewHost* render_view_host_;
61 // The stats_ field holds information about resource usage in the renderer
62 // process and so it is updated asynchronously by the Refresh() call.
63 blink::WebCache::ResourceTypeStats stats_;
64 // This flag is true if we are waiting for the renderer to report its stats.
65 bool pending_stats_update_;
67 // We do a similar dance to gather the V8 memory usage in a process.
68 size_t v8_memory_allocated_;
69 size_t v8_memory_used_;
70 bool pending_v8_memory_allocated_update_;
72 DISALLOW_COPY_AND_ASSIGN(RendererResource);
75 } // namespace task_manager
77 #endif // CHROME_BROWSER_TASK_MANAGER_RENDERER_RESOURCE_H_