| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRERENDER_PRERENDER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 class PrerenderLocalPredictor; | 73 class PrerenderLocalPredictor; |
| 74 | 74 |
| 75 // PrerenderManager is responsible for initiating and keeping prerendered | 75 // PrerenderManager is responsible for initiating and keeping prerendered |
| 76 // views of web pages. All methods must be called on the UI thread unless | 76 // views of web pages. All methods must be called on the UI thread unless |
| 77 // indicated otherwise. | 77 // indicated otherwise. |
| 78 class PrerenderManager : public content::NotificationObserver, | 78 class PrerenderManager : public content::NotificationObserver, |
| 79 public content::RenderProcessHostObserver, | 79 public content::RenderProcessHostObserver, |
| 80 public KeyedService, | 80 public KeyedService, |
| 81 public MediaCaptureDevicesDispatcher::Observer { | 81 public MediaCaptureDevicesDispatcher::Observer { |
| 82 public: | 82 public: |
| 83 // NOTE: New values need to be appended, since they are used in histograms. | |
| 84 enum PrerenderManagerMode { | 83 enum PrerenderManagerMode { |
| 85 PRERENDER_MODE_DISABLED = 0, | 84 PRERENDER_MODE_DISABLED, |
| 86 PRERENDER_MODE_ENABLED = 1, | 85 PRERENDER_MODE_ENABLED, |
| 87 PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP = 2, | 86 PRERENDER_MODE_NOSTATE_PREFETCH |
| 88 PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP = 3, | |
| 89 // Obsolete: PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP = 4, | |
| 90 PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP = 5, | |
| 91 PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP = 6, | |
| 92 PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP = 7, | |
| 93 // Obsolete: PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP = 8, | |
| 94 PRERENDER_MODE_NOSTATE_PREFETCH = 9, | |
| 95 PRERENDER_MODE_MAX = 10 | |
| 96 }; | 87 }; |
| 97 | 88 |
| 98 // One or more of these flags must be passed to ClearData() to specify just | 89 // One or more of these flags must be passed to ClearData() to specify just |
| 99 // what data to clear. See function declaration for more information. | 90 // what data to clear. See function declaration for more information. |
| 100 enum ClearFlags { | 91 enum ClearFlags { |
| 101 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, | 92 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, |
| 102 CLEAR_PRERENDER_HISTORY = 0x1 << 1, | 93 CLEAR_PRERENDER_HISTORY = 0x1 << 1, |
| 103 CLEAR_MAX = 0x1 << 2 | 94 CLEAR_MAX = 0x1 << 2 |
| 104 }; | 95 }; |
| 105 | 96 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Must not be called for prefetch loads (which are never rendered anyway). | 214 // Must not be called for prefetch loads (which are never rendered anyway). |
| 224 // |is_no_store| must be true if the main resource has a "no-store" cache | 215 // |is_no_store| must be true if the main resource has a "no-store" cache |
| 225 // control HTTP header. | 216 // control HTTP header. |
| 226 void RecordFirstContentfulPaint(const GURL& url, | 217 void RecordFirstContentfulPaint(const GURL& url, |
| 227 bool is_no_store, | 218 bool is_no_store, |
| 228 base::TimeDelta time); | 219 base::TimeDelta time); |
| 229 | 220 |
| 230 static PrerenderManagerMode GetMode(); | 221 static PrerenderManagerMode GetMode(); |
| 231 static void SetMode(PrerenderManagerMode mode); | 222 static void SetMode(PrerenderManagerMode mode); |
| 232 static bool IsPrerenderingPossible(); | 223 static bool IsPrerenderingPossible(); |
| 233 static bool ActuallyPrerendering(); | |
| 234 static bool IsControlGroup(); | |
| 235 static bool IsNoUseGroup(); | |
| 236 static bool IsNoStatePrefetch(); | 224 static bool IsNoStatePrefetch(); |
| 237 | 225 |
| 238 // Query the list of current prerender pages to see if the given web contents | 226 // Query the list of current prerender pages to see if the given web contents |
| 239 // is prerendering a page. The optional parameter |origin| is an output | 227 // is prerendering a page. The optional parameter |origin| is an output |
| 240 // parameter which, if a prerender is found, is set to the Origin of the | 228 // parameter which, if a prerender is found, is set to the Origin of the |
| 241 // prerender |web_contents|. | 229 // prerender |web_contents|. |
| 242 bool IsWebContentsPrerendering(const content::WebContents* web_contents, | 230 bool IsWebContentsPrerendering(const content::WebContents* web_contents, |
| 243 Origin* origin) const; | 231 Origin* origin) const; |
| 244 | 232 |
| 245 // Whether the PrerenderManager has an active prerender with the given url and | 233 // Whether the PrerenderManager has an active prerender with the given url and |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 std::unique_ptr<base::TickClock> tick_clock_; | 601 std::unique_ptr<base::TickClock> tick_clock_; |
| 614 | 602 |
| 615 base::WeakPtrFactory<PrerenderManager> weak_factory_; | 603 base::WeakPtrFactory<PrerenderManager> weak_factory_; |
| 616 | 604 |
| 617 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 605 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 618 }; | 606 }; |
| 619 | 607 |
| 620 } // namespace prerender | 608 } // namespace prerender |
| 621 | 609 |
| 622 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 610 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |