| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_NET_PREDICTOR_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 11 #include "content/public/browser/reload_type.h" | 12 #include "content/public/browser/reload_type.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 class NavigationHandle; | 17 class NavigationHandle; |
| 17 } | 18 } |
| 18 | 19 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 content::NavigationHandle* navigation_handle) override; | 30 content::NavigationHandle* navigation_handle) override; |
| 30 void DidStartNavigationToPendingEntry( | 31 void DidStartNavigationToPendingEntry( |
| 31 const GURL& url, | 32 const GURL& url, |
| 32 content::ReloadType reload_type) override; | 33 content::ReloadType reload_type) override; |
| 33 void DocumentOnLoadCompletedInMainFrame() override; | 34 void DocumentOnLoadCompletedInMainFrame() override; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 explicit PredictorTabHelper(content::WebContents* web_contents); | 37 explicit PredictorTabHelper(content::WebContents* web_contents); |
| 37 friend class content::WebContentsUserData<PredictorTabHelper>; | 38 friend class content::WebContentsUserData<PredictorTabHelper>; |
| 38 | 39 |
| 39 void PreconnectUrl(const GURL& url); | 40 void HandleNavigation(const GURL& url); |
| 41 void DidStartServiceWorkerForNavigaionPreconnect(const GURL& url, |
| 42 bool success); |
| 43 void PreconnectUrlWithPredictor(const GURL& url); |
| 40 | 44 |
| 41 // This boolean is set to true after a call to | 45 // This boolean is set to true after a call to |
| 42 // DidStartNavigationToPendingEntry, which fires off predictive preconnects. | 46 // DidStartNavigationToPendingEntry, which fires off predictive preconnects. |
| 43 // This ensures that the resulting call to DidStartNavigation does not | 47 // This ensures that the resulting call to DidStartNavigation does not |
| 44 // duplicate these preconnects. The tab helper spawns preconnects on the | 48 // duplicate these preconnects. The tab helper spawns preconnects on the |
| 45 // navigation to the pending entry because DidStartNavigation is called after | 49 // navigation to the pending entry because DidStartNavigation is called after |
| 46 // render process spawn (pre-PlzNavigate), which can take substantial time | 50 // render process spawn (pre-PlzNavigate), which can take substantial time |
| 47 // especially on Android. | 51 // especially on Android. |
| 48 bool predicted_from_pending_entry_; | 52 bool predicted_from_pending_entry_; |
| 49 | 53 |
| 54 base::WeakPtrFactory<PredictorTabHelper> weak_factory_; |
| 55 |
| 50 DISALLOW_COPY_AND_ASSIGN(PredictorTabHelper); | 56 DISALLOW_COPY_AND_ASSIGN(PredictorTabHelper); |
| 51 }; | 57 }; |
| 52 | 58 |
| 53 } // namespace chrome_browser_net | 59 } // namespace chrome_browser_net |
| 54 | 60 |
| 55 #endif // CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ | 61 #endif // CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ |
| OLD | NEW |