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_TAB_CONTENTS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_H_
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"
19 class NotificationSource
;
20 class NotificationDetails
;
23 namespace task_manager
{
25 class TabContentsResource
;
27 // Provides resources for tab contents, prerendered pages, Instant pages, and
28 // background printing pages.
29 class TabContentsResourceProvider
: public ResourceProvider
,
30 public content::NotificationObserver
{
32 explicit TabContentsResourceProvider(TaskManager
* task_manager
);
34 virtual Resource
* GetResource(int origin_pid
,
36 int route_id
) OVERRIDE
;
37 virtual void StartUpdating() OVERRIDE
;
38 virtual void StopUpdating() OVERRIDE
;
40 // content::NotificationObserver method:
41 virtual void Observe(int type
,
42 const content::NotificationSource
& source
,
43 const content::NotificationDetails
& details
) OVERRIDE
;
46 virtual ~TabContentsResourceProvider();
48 void Add(content::WebContents
* web_contents
);
49 void Remove(content::WebContents
* web_contents
);
51 void AddToTaskManager(content::WebContents
* web_contents
);
53 // Whether we are currently reporting to the task manager. Used to ignore
54 // notifications sent after StopUpdating().
57 TaskManager
* task_manager_
;
59 // Maps the actual resources (the WebContentses) to the Task Manager
61 std::map
<content::WebContents
*, TabContentsResource
*> resources_
;
63 // A scoped container for notification registries.
64 content::NotificationRegistrar registrar_
;
66 DISALLOW_COPY_AND_ASSIGN(TabContentsResourceProvider
);
69 } // namespace task_manager
71 #endif // CHROME_BROWSER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_H_