| 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/cancelable_callback.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 #include "content/public/browser/web_contents_observer.h" |  | 
| 13 |  | 
| 14 namespace blimp { |  | 
| 15 namespace engine { |  | 
| 16 |  | 
| 17 enum class PageLoadStatus { LOADING, LOADED }; |  | 
| 18 |  | 
| 19 class PageLoadTrackerClient { |  | 
| 20  public: |  | 
| 21   virtual ~PageLoadTrackerClient() {} |  | 
| 22 |  | 
| 23   // Called when a navigation status update should be sent to the client. |  | 
| 24   // |load_status| indicates the status of the navigation. An update with a |  | 
| 25   // |LOADING| value is sent each time a new navigation is initiated. This |  | 
| 26   // update will be followed by a |LOADED| value when the navigation either |  | 
| 27   // successfully finishes or fails. |  | 
| 28   virtual void SendPageLoadStatusUpdate(PageLoadStatus load_status) = 0; |  | 
| 29 }; |  | 
| 30 |  | 
| 31 // Tracks the page load status for a tab using load and paint notifications |  | 
| 32 // from the renderer. |  | 
| 33 class PageLoadTracker : public content::WebContentsObserver { |  | 
| 34  public: |  | 
| 35   explicit PageLoadTracker(content::WebContents* web_contents, |  | 
| 36                            PageLoadTrackerClient* client); |  | 
| 37   ~PageLoadTracker() override; |  | 
| 38 |  | 
| 39  private: |  | 
| 40   // content::WebContentsObserver implementation. |  | 
| 41   void DidStartNavigation( |  | 
| 42       content::NavigationHandle* navigation_handle) override; |  | 
| 43   void DidFinishNavigation( |  | 
| 44       content::NavigationHandle* navigation_handle) override; |  | 
| 45 |  | 
| 46   // Invoked when the renderer has performed at least one paint after the |  | 
| 47   // navigation was committed. |  | 
| 48   void DidPaintAfterNavigationCommitted(bool result); |  | 
| 49 |  | 
| 50   base::CancelableCallback<void(bool)> did_paint_after_navigation_callback_; |  | 
| 51 |  | 
| 52   PageLoadTrackerClient* client_; |  | 
| 53 |  | 
| 54   DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |  | 
| 55 }; |  | 
| 56 |  | 
| 57 }  // namespace engine |  | 
| 58 }  // namespace blimp |  | 
| 59 |  | 
| 60 #endif  // BLIMP_ENGINE_SESSION_PAGE_LOAD_TRACKER_H_ |  | 
| OLD | NEW | 
|---|