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_BACKGROUND_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/task_manager/resource_provider.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 class BackgroundContents
;
19 namespace task_manager
{
21 class BackgroundContentsResource
;
23 class BackgroundContentsResourceProvider
24 : public ResourceProvider
,
25 public content::NotificationObserver
{
27 explicit BackgroundContentsResourceProvider(TaskManager
* task_manager
);
29 virtual Resource
* GetResource(int origin_pid
,
31 int route_id
) OVERRIDE
;
32 virtual void StartUpdating() OVERRIDE
;
33 virtual void StopUpdating() OVERRIDE
;
35 // content::NotificationObserver method:
36 virtual void Observe(int type
,
37 const content::NotificationSource
& source
,
38 const content::NotificationDetails
& details
) OVERRIDE
;
41 virtual ~BackgroundContentsResourceProvider();
43 void Add(BackgroundContents
* background_contents
,
44 const base::string16
& title
);
45 void Remove(BackgroundContents
* background_contents
);
47 void AddToTaskManager(BackgroundContents
* background_contents
,
48 const base::string16
& title
);
50 // Whether we are currently reporting to the task manager. Used to ignore
51 // notifications sent after StopUpdating().
54 TaskManager
* task_manager_
;
56 // Maps the actual resources (the BackgroundContents) to the Task Manager
58 typedef std::map
<BackgroundContents
*, BackgroundContentsResource
*>
62 // A scoped container for notification registries.
63 content::NotificationRegistrar registrar_
;
65 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsResourceProvider
);
68 } // namespace task_manager
70 #endif // CHROME_BROWSER_TASK_MANAGER_BACKGROUND_RESOURCE_PROVIDER_H_