OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |
| 6 #define BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |
| 7 |
| 8 #include "base/containers/small_map.h" |
| 9 #include "base/macros.h" |
| 10 #include "content/public/browser/render_frame_host.h" |
| 11 #include "content/public/browser/render_widget_host.h" |
| 12 |
| 13 namespace blimp { |
| 14 namespace engine { |
| 15 |
| 16 class PageLoadTrackerClient { |
| 17 public: |
| 18 virtual ~PageLoadTrackerClient() {} |
| 19 |
| 20 virtual void SendPageLoadStatusUpdate(bool load_status) = 0; |
| 21 }; |
| 22 |
| 23 class PageLoadTracker { |
| 24 public: |
| 25 explicit PageLoadTracker(PageLoadTrackerClient* client); |
| 26 ~PageLoadTracker(); |
| 27 |
| 28 void DidStartProvisionalLoadForFrame( |
| 29 content::RenderFrameHost* render_frame_host); |
| 30 |
| 31 void DidFinishLoad(content::RenderFrameHost* render_frame_host); |
| 32 |
| 33 void DidFailLoad(content::RenderFrameHost* render_frame_host); |
| 34 |
| 35 void DidFirstPaintAfterLoad(content::RenderWidgetHost* render_widget_host); |
| 36 |
| 37 private: |
| 38 struct LoadStatus { |
| 39 // Set to true on receiving a notification from the renderer that the load |
| 40 // finished. See WebContentsObserver::DidFinishLoad. |
| 41 bool page_loaded = false; |
| 42 |
| 43 // Set to true on receiving a notification from the renderer that the first |
| 44 // paint after a navigation was performed. |
| 45 // See WebContentsObserver::DidFirstPaintAfterLoad. |
| 46 bool did_first_paint = false; |
| 47 |
| 48 bool Loaded() const; |
| 49 }; |
| 50 |
| 51 typedef base::SmallMap<std::map<content::RenderWidgetHost*, LoadStatus>> |
| 52 RenderWidgetLoadStatusMap; |
| 53 |
| 54 RenderWidgetLoadStatusMap render_widget_load_status_; |
| 55 |
| 56 PageLoadTrackerClient* client_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
| 59 }; |
| 60 |
| 61 } // namespace engine |
| 62 } // namespace blimp |
| 63 |
| 64 #endif // BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |
OLD | NEW |