| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // WebContentsInformation, which provides a list of WebContentses to track. | 31 // WebContentsInformation, which provides a list of WebContentses to track. |
| 32 // | 32 // |
| 33 // This ResourceProvider is instantiated several times by the task manager, each | 33 // This ResourceProvider is instantiated several times by the task manager, each |
| 34 // with a different implementation of WebContentsInformation. | 34 // with a different implementation of WebContentsInformation. |
| 35 class WebContentsResourceProvider : public ResourceProvider { | 35 class WebContentsResourceProvider : public ResourceProvider { |
| 36 public: | 36 public: |
| 37 WebContentsResourceProvider(TaskManager* task_manager, | 37 WebContentsResourceProvider(TaskManager* task_manager, |
| 38 scoped_ptr<WebContentsInformation> info); | 38 scoped_ptr<WebContentsInformation> info); |
| 39 | 39 |
| 40 // ResourceProvider implementation. | 40 // ResourceProvider implementation. |
| 41 virtual RendererResource* GetResource(int origin_pid, | 41 RendererResource* GetResource(int origin_pid, |
| 42 int child_id, | 42 int child_id, |
| 43 int route_id) override; | 43 int route_id) override; |
| 44 virtual void StartUpdating() override; | 44 void StartUpdating() override; |
| 45 virtual void StopUpdating() override; | 45 void StopUpdating() override; |
| 46 | 46 |
| 47 // Start observing |web_contents| for changes via WebContentsObserver, and | 47 // Start observing |web_contents| for changes via WebContentsObserver, and |
| 48 // add it to the task manager. | 48 // add it to the task manager. |
| 49 void OnWebContentsCreated(content::WebContents* web_contents); | 49 void OnWebContentsCreated(content::WebContents* web_contents); |
| 50 | 50 |
| 51 // Remove a TaskManagerWebContentsEntry from our tracking list, and delete it. | 51 // Remove a TaskManagerWebContentsEntry from our tracking list, and delete it. |
| 52 void DeleteEntry(content::WebContents* web_contents, | 52 void DeleteEntry(content::WebContents* web_contents, |
| 53 TaskManagerWebContentsEntry* entry); | 53 TaskManagerWebContentsEntry* entry); |
| 54 | 54 |
| 55 TaskManager* task_manager() { return task_manager_; } | 55 TaskManager* task_manager() { return task_manager_; } |
| 56 WebContentsInformation* info() { return info_.get(); } | 56 WebContentsInformation* info() { return info_.get(); } |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 virtual ~WebContentsResourceProvider(); | 59 ~WebContentsResourceProvider() override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 typedef std::map<content::WebContents*, TaskManagerWebContentsEntry*> | 62 typedef std::map<content::WebContents*, TaskManagerWebContentsEntry*> |
| 63 EntryMap; | 63 EntryMap; |
| 64 | 64 |
| 65 TaskManager* task_manager_; | 65 TaskManager* task_manager_; |
| 66 | 66 |
| 67 // For every WebContents we maintain an entry, which holds the task manager's | 67 // For every WebContents we maintain an entry, which holds the task manager's |
| 68 // RendererResources for that WebContents, and observes the WebContents for | 68 // RendererResources for that WebContents, and observes the WebContents for |
| 69 // changes. | 69 // changes. |
| 70 EntryMap entries_; | 70 EntryMap entries_; |
| 71 | 71 |
| 72 // The WebContentsInformation that informs us when a new WebContents* is | 72 // The WebContentsInformation that informs us when a new WebContents* is |
| 73 // created, and which serves as a RendererResource factory for our type. | 73 // created, and which serves as a RendererResource factory for our type. |
| 74 scoped_ptr<WebContentsInformation> info_; | 74 scoped_ptr<WebContentsInformation> info_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(WebContentsResourceProvider); | 76 DISALLOW_COPY_AND_ASSIGN(WebContentsResourceProvider); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace task_manager | 79 } // namespace task_manager |
| 80 | 80 |
| 81 #endif // CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ | 81 #endif // CHROME_BROWSER_TASK_MANAGER_WEB_CONTENTS_RESOURCE_PROVIDER_H_ |
| OLD | NEW |