OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TAB_FIRST_RENDER_WATCHER_H_ | 5 #ifndef CHROME_BROWSER_TAB_RENDER_WATCHER_H_ |
6 #define CHROME_BROWSER_TAB_FIRST_RENDER_WATCHER_H_ | 6 #define CHROME_BROWSER_TAB_RENDER_WATCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 | 12 |
13 class RenderViewHost; | 13 class RenderViewHost; |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class WebContents; | 16 class WebContents; |
17 } | 17 } |
18 | 18 |
19 // This class watches given TabContent's loading and rendering state change. | 19 // This class watches given TabContent's loading and rendering state change. |
20 class TabFirstRenderWatcher : public content::NotificationObserver { | 20 class TabRenderWatcher : public content::NotificationObserver { |
21 public: | 21 public: |
22 class Delegate { | 22 class Delegate { |
23 public: | 23 public: |
24 virtual void OnRenderHostCreated(RenderViewHost* host) = 0; | 24 virtual void OnRenderHostCreated(RenderViewHost* host) = 0; |
25 virtual void OnTabMainFrameLoaded() = 0; | 25 virtual void OnTabMainFrameLoaded() = 0; |
26 virtual void OnTabMainFrameFirstRender() = 0; | 26 virtual void OnTabMainFrameRender() = 0; |
27 }; | 27 }; |
28 | 28 |
29 TabFirstRenderWatcher(content::WebContents* tab, Delegate* delegate); | 29 TabRenderWatcher(content::WebContents* tab, Delegate* delegate); |
30 | 30 |
31 private: | 31 private: |
32 // Overridden from content::NotificationObserver | 32 // Overridden from content::NotificationObserver |
33 virtual void Observe(int type, | 33 virtual void Observe(int type, |
34 const content::NotificationSource& source, | 34 const content::NotificationSource& source, |
35 const content::NotificationDetails& details) OVERRIDE; | 35 const content::NotificationDetails& details) OVERRIDE; |
36 | 36 |
37 enum State { | 37 // Has the renderer loaded the page yet? |
38 NONE, | 38 bool loaded_; |
39 LOADED, // Renderer loaded the page. | |
40 FIRST_PAINT, // 1st paint event after the page is loaded. | |
41 }; | |
42 State state_; | |
43 | 39 |
44 // WebContents that this class watches. | 40 // WebContents that this class watches. |
45 content::WebContents* web_contents_; | 41 content::WebContents* web_contents_; |
46 | 42 |
47 // Delegate to notify. | 43 // Delegate to notify. |
48 Delegate* delegate_; | 44 Delegate* delegate_; |
49 | 45 |
50 content::NotificationRegistrar registrar_; | 46 content::NotificationRegistrar registrar_; |
51 | 47 |
52 DISALLOW_COPY_AND_ASSIGN(TabFirstRenderWatcher); | 48 DISALLOW_COPY_AND_ASSIGN(TabRenderWatcher); |
53 }; | 49 }; |
54 | 50 |
55 #endif // CHROME_BROWSER_TAB_FIRST_RENDER_WATCHER_H_ | 51 #endif // CHROME_BROWSER_TAB_RENDER_WATCHER_H_ |
OLD | NEW |