Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / task_manager / web_contents_resource_provider.h
blob4d3d365f3d9707d8a85f6d089652c6178e44980a
1 // Copyright 2014 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_WEB_CONTENTS_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/task_manager/renderer_resource.h"
13 #include "chrome/browser/task_manager/resource_provider.h"
15 class TaskManager;
17 namespace content {
18 class RenderFrameHost;
19 class SiteInstance;
20 class WebContents;
23 namespace task_manager {
25 class RendererResource;
26 class TaskManagerWebContentsEntry;
27 class WebContentsInformation;
29 // Provides resources to the task manager on behalf of a chrome service that
30 // owns WebContentses. The chrome service is parameterized as a
31 // WebContentsInformation, which provides a list of WebContentses to track.
33 // This ResourceProvider is instantiated several times by the task manager, each
34 // with a different implementation of WebContentsInformation.
35 class WebContentsResourceProvider : public ResourceProvider {
36 public:
37 WebContentsResourceProvider(TaskManager* task_manager,
38 scoped_ptr<WebContentsInformation> info);
40 // ResourceProvider implementation.
41 RendererResource* GetResource(int origin_pid,
42 int child_id,
43 int route_id) override;
44 void StartUpdating() override;
45 void StopUpdating() override;
47 // Start observing |web_contents| for changes via WebContentsObserver, and
48 // add it to the task manager.
49 void OnWebContentsCreated(content::WebContents* web_contents);
51 // Remove a TaskManagerWebContentsEntry from our tracking list, and delete it.
52 void DeleteEntry(content::WebContents* web_contents,
53 TaskManagerWebContentsEntry* entry);
55 TaskManager* task_manager() { return task_manager_; }
56 WebContentsInformation* info() { return info_.get(); }
58 protected:
59 ~WebContentsResourceProvider() override;
61 private:
62 typedef std::map<content::WebContents*, TaskManagerWebContentsEntry*>
63 EntryMap;
65 TaskManager* task_manager_;
67 // For every WebContents we maintain an entry, which holds the task manager's
68 // RendererResources for that WebContents, and observes the WebContents for
69 // changes.
70 EntryMap entries_;
72 // The WebContentsInformation that informs us when a new WebContents* is
73 // created, and which serves as a RendererResource factory for our type.
74 scoped_ptr<WebContentsInformation> info_;
76 DISALLOW_COPY_AND_ASSIGN(WebContentsResourceProvider);
79 } // namespace task_manager
81 #endif // CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_