- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / task_manager / browser_process_resource_provider.h
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_BROWSER_PROCESS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_BROWSER_PROCESS_RESOURCE_PROVIDER_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/task_manager/resource_provider.h"
11 #include "content/public/browser/browser_child_process_observer.h"
12 #include "content/public/browser/child_process_data.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/common/process_type.h"
16
17 class TaskManager;
18
19 namespace content {
20 class RenderViewHost;
21 class WebContents;
22 }
23
24 namespace extensions {
25 class Extension;
26 }
27
28 namespace task_manager {
29
30 class BrowserProcessResource : public Resource {
31  public:
32   BrowserProcessResource();
33   virtual ~BrowserProcessResource();
34
35   // Resource methods:
36   virtual string16 GetTitle() const OVERRIDE;
37   virtual string16 GetProfileName() const OVERRIDE;
38   virtual gfx::ImageSkia GetIcon() const OVERRIDE;
39   virtual base::ProcessHandle GetProcess() const OVERRIDE;
40   virtual int GetUniqueChildProcessId() const OVERRIDE;
41   virtual Type GetType() const OVERRIDE;
42
43   virtual bool SupportNetworkUsage() const OVERRIDE;
44   virtual void SetSupportNetworkUsage() OVERRIDE;
45
46   virtual bool ReportsSqliteMemoryUsed() const OVERRIDE;
47   virtual size_t SqliteMemoryUsedBytes() const OVERRIDE;
48
49   virtual bool ReportsV8MemoryStats() const OVERRIDE;
50   virtual size_t GetV8MemoryAllocated() const OVERRIDE;
51   virtual size_t GetV8MemoryUsed() const OVERRIDE;
52
53  private:
54   base::ProcessHandle process_;
55   mutable string16 title_;
56
57   static gfx::ImageSkia* default_icon_;
58
59   DISALLOW_COPY_AND_ASSIGN(BrowserProcessResource);
60 };
61
62 class BrowserProcessResourceProvider : public ResourceProvider {
63  public:
64   explicit BrowserProcessResourceProvider(TaskManager* task_manager);
65
66   virtual Resource* GetResource(int origin_pid,
67                                 int render_process_host_id,
68                                 int routing_id) OVERRIDE;
69   virtual void StartUpdating() OVERRIDE;
70   virtual void StopUpdating() OVERRIDE;
71
72   // Whether we are currently reporting to the task manager. Used to ignore
73   // notifications sent after StopUpdating().
74   bool updating_;
75
76  private:
77   virtual ~BrowserProcessResourceProvider();
78
79   TaskManager* task_manager_;
80   BrowserProcessResource resource_;
81
82   DISALLOW_COPY_AND_ASSIGN(BrowserProcessResourceProvider);
83 };
84
85 }  // namespace task_manager
86
87 #endif  // CHROME_BROWSER_TASK_MANAGER_BROWSER_PROCESS_RESOURCE_PROVIDER_H_