| OLD | NEW |
| (Empty) | |
| 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_TAB_CONTENTS_RESOURCE_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/task_manager/task_manager.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 WebContents; |
| 19 class NotificationSource; |
| 20 class NotificationDetails; |
| 21 } |
| 22 |
| 23 namespace task_manager { |
| 24 |
| 25 class TabContentsResource; |
| 26 |
| 27 // Provides resources for tab contents, prerendered pages, Instant pages, and |
| 28 // background printing pages. |
| 29 class TabContentsResourceProvider : public TaskManager::ResourceProvider, |
| 30 public content::NotificationObserver { |
| 31 public: |
| 32 explicit TabContentsResourceProvider(TaskManager* task_manager); |
| 33 |
| 34 virtual TaskManager::Resource* GetResource(int origin_pid, |
| 35 int render_process_host_id, |
| 36 int routing_id) OVERRIDE; |
| 37 virtual void StartUpdating() OVERRIDE; |
| 38 virtual void StopUpdating() OVERRIDE; |
| 39 |
| 40 // content::NotificationObserver method: |
| 41 virtual void Observe(int type, |
| 42 const content::NotificationSource& source, |
| 43 const content::NotificationDetails& details) OVERRIDE; |
| 44 |
| 45 private: |
| 46 virtual ~TabContentsResourceProvider(); |
| 47 |
| 48 void Add(content::WebContents* web_contents); |
| 49 void Remove(content::WebContents* web_contents); |
| 50 void InstantCommitted(content::WebContents* web_contents); |
| 51 |
| 52 void AddToTaskManager(content::WebContents* web_contents); |
| 53 |
| 54 // Whether we are currently reporting to the task manager. Used to ignore |
| 55 // notifications sent after StopUpdating(). |
| 56 bool updating_; |
| 57 |
| 58 TaskManager* task_manager_; |
| 59 |
| 60 // Maps the actual resources (the WebContentses) to the Task Manager |
| 61 // resources. |
| 62 std::map<content::WebContents*, TabContentsResource*> resources_; |
| 63 |
| 64 // A scoped container for notification registries. |
| 65 content::NotificationRegistrar registrar_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(TabContentsResourceProvider); |
| 68 }; |
| 69 |
| 70 } // namespace task_manager |
| 71 |
| 72 #endif // CHROME_BROWSER_TASK_MANAGER_TAB_CONTENTS_RESOURCE_PROVIDER_H_ |
| OLD | NEW |