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_NOTIFICATION_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_NOTIFICATION_RESOURCE_PROVIDER_H_
11 #include "base/basictypes.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"
19 namespace task_manager
{
21 class NotificationResource
;
23 class NotificationResourceProvider
: public ResourceProvider
,
24 public content::NotificationObserver
{
26 static NotificationResourceProvider
* Create(TaskManager
* task_manager
);
28 // ResourceProvider interface
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 interface
36 virtual void Observe(int type
,
37 const content::NotificationSource
& source
,
38 const content::NotificationDetails
& details
) OVERRIDE
;
41 explicit NotificationResourceProvider(TaskManager
* task_manager
);
42 virtual ~NotificationResourceProvider();
44 void AddToTaskManager(BalloonHost
* balloon_host
);
45 void RemoveFromTaskManager(BalloonHost
* balloon_host
);
47 TaskManager
* task_manager_
;
49 // Maps the actual resources (BalloonHost*) to the Task Manager resources.
50 std::map
<BalloonHost
*, NotificationResource
*> resources_
;
52 // A scoped container for notification registries.
53 content::NotificationRegistrar registrar_
;
57 DISALLOW_COPY_AND_ASSIGN(NotificationResourceProvider
);
60 } // namespace task_manager
62 #endif // CHROME_BROWSER_TASK_MANAGER_NOTIFICATION_RESOURCE_PROVIDER_H_