Index: blimp/engine/session/page_load_tracker.h |
diff --git a/blimp/engine/session/page_load_tracker.h b/blimp/engine/session/page_load_tracker.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..43b455c4b1604e97b5350408cae3d32b44a894f8 |
--- /dev/null |
+++ b/blimp/engine/session/page_load_tracker.h |
@@ -0,0 +1,64 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |
+#define BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |
+ |
+#include "base/containers/small_map.h" |
+#include "base/macros.h" |
+#include "content/public/browser/render_frame_host.h" |
+#include "content/public/browser/render_widget_host.h" |
+ |
+namespace blimp { |
+namespace engine { |
+ |
+class PageLoadTrackerClient { |
+ public: |
+ virtual ~PageLoadTrackerClient() {} |
+ |
+ virtual void SendPageLoadStatusUpdate(bool load_status) = 0; |
+}; |
+ |
+class PageLoadTracker { |
+ public: |
+ explicit PageLoadTracker(PageLoadTrackerClient* client); |
+ ~PageLoadTracker(); |
+ |
+ void DidStartProvisionalLoadForFrame( |
+ content::RenderFrameHost* render_frame_host); |
+ |
+ void DidFinishLoad(content::RenderFrameHost* render_frame_host); |
+ |
+ void DidFailLoad(content::RenderFrameHost* render_frame_host); |
+ |
+ void DidFirstPaintAfterLoad(content::RenderWidgetHost* render_widget_host); |
+ |
+ private: |
+ struct LoadStatus { |
+ // Set to true on receiving a notification from the renderer that the load |
+ // finished. See WebContentsObserver::DidFinishLoad. |
+ bool page_loaded = false; |
+ |
+ // Set to true on receiving a notification from the renderer that the first |
+ // paint after a navigation was performed. |
+ // See WebContentsObserver::DidFirstPaintAfterLoad. |
+ bool did_first_paint = false; |
+ |
+ bool Loaded() const; |
+ }; |
+ |
+ typedef base::SmallMap<std::map<content::RenderWidgetHost*, LoadStatus>> |
+ RenderWidgetLoadStatusMap; |
+ |
+ RenderWidgetLoadStatusMap render_widget_load_status_; |
+ |
+ PageLoadTrackerClient* client_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
+}; |
+ |
+} // namespace engine |
+} // namespace blimp |
+ |
+#endif // BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |