Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / task_manager / tab_contents_resource_provider.h
blobda2bb82cc597ce7cc3f5949467c3f25d115deb93
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_
8 #include <map>
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"
15 class TaskManager;
17 namespace content {
18 class WebContents;
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 {
31 public:
32 explicit TabContentsResourceProvider(TaskManager* task_manager);
34 virtual Resource* GetResource(int origin_pid,
35 int child_id,
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;
45 private:
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().
55 bool updating_;
57 TaskManager* task_manager_;
59 // Maps the actual resources (the WebContentses) to the Task Manager
60 // resources.
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_