Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / task_manager / extension_process_resource_provider.h
1 // Copyright 2014 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_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/task_manager/resource_provider.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 class TaskManager;
16
17 namespace content {
18 class RenderViewHost;
19 }
20
21 namespace task_manager {
22
23 class ExtensionProcessResource;
24
25 class ExtensionProcessResourceProvider
26     : public ResourceProvider,
27       public content::NotificationObserver {
28  public:
29   explicit ExtensionProcessResourceProvider(TaskManager* task_manager);
30
31   virtual Resource* GetResource(int origin_pid,
32                                 int child_id,
33                                 int route_id) OVERRIDE;
34   virtual void StartUpdating() OVERRIDE;
35   virtual void StopUpdating() OVERRIDE;
36
37   // content::NotificationObserver method:
38   virtual void Observe(int type,
39                        const content::NotificationSource& source,
40                        const content::NotificationDetails& details) OVERRIDE;
41
42  private:
43   virtual ~ExtensionProcessResourceProvider();
44
45   bool IsHandledByThisProvider(content::RenderViewHost* render_view_host);
46   void AddToTaskManager(content::RenderViewHost* render_view_host);
47   void RemoveFromTaskManager(content::RenderViewHost* render_view_host);
48
49   TaskManager* task_manager_;
50
51   // Maps the actual resources (content::RenderViewHost*) to the Task Manager
52   // resources.
53   typedef std::map<content::RenderViewHost*, ExtensionProcessResource*>
54       ExtensionRenderViewHostMap;
55   ExtensionRenderViewHostMap resources_;
56
57   // A scoped container for notification registries.
58   content::NotificationRegistrar registrar_;
59
60   bool updating_;
61
62   DISALLOW_COPY_AND_ASSIGN(ExtensionProcessResourceProvider);
63 };
64
65 }  // namespace task_manager
66
67 #endif  // CHROME_BROWSER_TASK_MANAGER_EXTENSION_PROCESS_RESOURCE_PROVIDER_H_