OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H_ |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H_ |
7 | 7 |
8 #include "chrome/browser/task_management/providers/task.h" | 8 #include "chrome/browser/task_management/providers/task.h" |
| 9 #include "components/favicon/core/favicon_driver_observer.h" |
9 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
10 | 11 |
11 class ProcessResourceUsage; | 12 class ProcessResourceUsage; |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 class RenderProcessHost; | 15 class RenderProcessHost; |
15 class WebContents; | 16 class WebContents; |
16 } // namespace content | 17 } // namespace content |
17 | 18 |
18 namespace task_management { | 19 namespace task_management { |
19 | 20 |
20 // Defines an abstract base class for various types of renderer process tasks | 21 // Defines an abstract base class for various types of renderer process tasks |
21 // such as background contents, tab contents, ... etc. | 22 // such as background contents, tab contents, ... etc. |
22 class RendererTask : public Task { | 23 class RendererTask : public Task, |
| 24 public favicon::FaviconDriverObserver { |
23 public: | 25 public: |
24 RendererTask(const base::string16& title, | 26 RendererTask(const base::string16& title, |
25 const gfx::ImageSkia* icon, | 27 const gfx::ImageSkia* icon, |
26 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
27 content::RenderProcessHost* render_process_host); | 29 content::RenderProcessHost* render_process_host); |
28 ~RendererTask() override; | 30 ~RendererTask() override; |
29 | 31 |
30 // An abstract method that will be called when the event | 32 // An abstract method that will be called when the event |
31 // WebContentsObserver::DidNavigateMainFrame() occurs. This gives the | 33 // WebContentsObserver::DidNavigateMainFrame() occurs. This gives the |
32 // freedom to concrete tasks to adjust the title however they need to before | 34 // freedom to concrete tasks to adjust the title however they need to before |
33 // they set it. | 35 // they set it. |
34 virtual void UpdateTitle() = 0; | 36 virtual void UpdateTitle() = 0; |
35 | 37 |
36 // An abstract method that will be called when the event | 38 // An abstract method that will be called when the event |
37 // WebContentsObserver::DocumentOnLoadCompletedInMainFrame() occurs, so that | 39 // FaviconDriverObserver::OnFaviconUpdated() occurs, so that concrete tasks |
38 // concrete tasks can update their favicons. | 40 // can update their favicons. |
39 virtual void UpdateFavicon() = 0; | 41 virtual void UpdateFavicon() = 0; |
40 | 42 |
41 // task_management::Task: | 43 // task_management::Task: |
42 void Activate() override; | 44 void Activate() override; |
43 void Refresh(const base::TimeDelta& update_interval, | 45 void Refresh(const base::TimeDelta& update_interval, |
44 int64 refresh_flags) override; | 46 int64 refresh_flags) override; |
45 Type GetType() const override; | 47 Type GetType() const override; |
46 int GetChildProcessUniqueID() const override; | 48 int GetChildProcessUniqueID() const override; |
47 base::string16 GetProfileName() const override; | 49 base::string16 GetProfileName() const override; |
48 int64 GetV8MemoryAllocated() const override; | 50 int64 GetV8MemoryAllocated() const override; |
49 int64 GetV8MemoryUsed() const override; | 51 int64 GetV8MemoryUsed() const override; |
50 bool ReportsWebCacheStats() const override; | 52 bool ReportsWebCacheStats() const override; |
51 blink::WebCache::ResourceTypeStats GetWebCacheStats() const override; | 53 blink::WebCache::ResourceTypeStats GetWebCacheStats() const override; |
52 | 54 |
| 55 // favicon::FaviconDriverObserver: |
| 56 void OnFaviconAvailable(const gfx::Image& image) override; |
| 57 void OnFaviconUpdated(favicon::FaviconDriver* favicon_driver, |
| 58 bool icon_url_changed) override; |
| 59 |
53 protected: | 60 protected: |
54 // Returns the title of the given |web_contents|. | 61 // Returns the title of the given |web_contents|. |
55 static base::string16 GetTitleFromWebContents( | 62 static base::string16 GetTitleFromWebContents( |
56 content::WebContents* web_contents); | 63 content::WebContents* web_contents); |
57 | 64 |
58 // Returns the favicon of the given |web_contents| if any, and returns | 65 // Returns the favicon of the given |web_contents| if any, and returns |
59 // |nullptr| otherwise. | 66 // |nullptr| otherwise. |
60 static const gfx::ImageSkia* GetFaviconFromWebContents( | 67 static const gfx::ImageSkia* GetFaviconFromWebContents( |
61 content::WebContents* web_contents); | 68 content::WebContents* web_contents); |
62 | 69 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // The profile name associated with the browser context of the render view | 103 // The profile name associated with the browser context of the render view |
97 // host. | 104 // host. |
98 const base::string16 profile_name_; | 105 const base::string16 profile_name_; |
99 | 106 |
100 DISALLOW_COPY_AND_ASSIGN(RendererTask); | 107 DISALLOW_COPY_AND_ASSIGN(RendererTask); |
101 }; | 108 }; |
102 | 109 |
103 } // namespace task_management | 110 } // namespace task_management |
104 | 111 |
105 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H
_ | 112 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_WEB_CONTENTS_RENDERER_TASK_H
_ |
OLD | NEW |