Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/net/predictor_tab_helper.h

Issue 2916533002: Introduce chrome://flags/#network-prediction-options-for-service-worker
Patch Set: use StartServiceWorkerForNavigationHint Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/net/prediction_options.cc ('k') | chrome/browser/net/predictor_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
13 #include "content/public/browser/service_worker_context.h"
12 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h" 15 #include "content/public/browser/web_contents_user_data.h"
14 16
15 namespace content { 17 namespace content {
16 class NavigationHandle; 18 class NavigationHandle;
17 } 19 }
18 20
19 namespace chrome_browser_net { 21 namespace chrome_browser_net {
20 22
21 class PredictorTabHelper 23 class PredictorTabHelper
22 : public content::WebContentsObserver, 24 : public content::WebContentsObserver,
23 public content::WebContentsUserData<PredictorTabHelper> { 25 public content::WebContentsUserData<PredictorTabHelper> {
24 public: 26 public:
25 ~PredictorTabHelper() override; 27 ~PredictorTabHelper() override;
26 28
27 // content::WebContentsObserver: 29 // content::WebContentsObserver:
28 void DidStartNavigation( 30 void DidStartNavigation(
29 content::NavigationHandle* navigation_handle) override; 31 content::NavigationHandle* navigation_handle) override;
30 void DidStartNavigationToPendingEntry( 32 void DidStartNavigationToPendingEntry(
31 const GURL& url, 33 const GURL& url,
32 content::ReloadType reload_type) override; 34 content::ReloadType reload_type) override;
33 void DocumentOnLoadCompletedInMainFrame() override; 35 void DocumentOnLoadCompletedInMainFrame() override;
34 36
35 private: 37 private:
36 explicit PredictorTabHelper(content::WebContents* web_contents); 38 explicit PredictorTabHelper(content::WebContents* web_contents);
37 friend class content::WebContentsUserData<PredictorTabHelper>; 39 friend class content::WebContentsUserData<PredictorTabHelper>;
38 40
41 void HandleNavigation(const GURL& url);
42 void DidStartServiceWorkerForNavigationPreconnect(
43 const GURL& url,
44 content::StartServiceWorkerForNavigationHintResult result);
39 void PreconnectUrl(const GURL& url); 45 void PreconnectUrl(const GURL& url);
40 46
41 // This boolean is set to true after a call to 47 // This boolean is set to true after a call to
42 // DidStartNavigationToPendingEntry, which fires off predictive preconnects. 48 // DidStartNavigationToPendingEntry, which fires off predictive preconnects.
43 // This ensures that the resulting call to DidStartNavigation does not 49 // This ensures that the resulting call to DidStartNavigation does not
44 // duplicate these preconnects. The tab helper spawns preconnects on the 50 // duplicate these preconnects. The tab helper spawns preconnects on the
45 // navigation to the pending entry because DidStartNavigation is called after 51 // navigation to the pending entry because DidStartNavigation is called after
46 // render process spawn (pre-PlzNavigate), which can take substantial time 52 // render process spawn (pre-PlzNavigate), which can take substantial time
47 // especially on Android. 53 // especially on Android.
48 bool predicted_from_pending_entry_; 54 bool predicted_from_pending_entry_;
49 55
56 base::WeakPtrFactory<PredictorTabHelper> weak_factory_;
57
50 DISALLOW_COPY_AND_ASSIGN(PredictorTabHelper); 58 DISALLOW_COPY_AND_ASSIGN(PredictorTabHelper);
51 }; 59 };
52 60
53 } // namespace chrome_browser_net 61 } // namespace chrome_browser_net
54 62
55 #endif // CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_ 63 #endif // CHROME_BROWSER_NET_PREDICTOR_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/prediction_options.cc ('k') | chrome/browser/net/predictor_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698