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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // indicated otherwise. | 67 // indicated otherwise. |
68 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, | 68 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, |
69 public base::NonThreadSafe, | 69 public base::NonThreadSafe, |
70 public ProfileKeyedService { | 70 public ProfileKeyedService { |
71 public: | 71 public: |
72 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not | 72 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not |
73 // add in the middle. | 73 // add in the middle. |
74 enum PrerenderManagerMode { | 74 enum PrerenderManagerMode { |
75 PRERENDER_MODE_DISABLED, | 75 PRERENDER_MODE_DISABLED, |
76 PRERENDER_MODE_ENABLED, | 76 PRERENDER_MODE_ENABLED, |
| 77 PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP, |
77 PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP, | 78 PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP, |
78 PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP, | 79 PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP, |
79 PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP, | 80 PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP, |
80 PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP, | 81 PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP, |
81 PRERENDER_MODE_MAX | 82 PRERENDER_MODE_MAX |
82 }; | 83 }; |
83 | 84 |
84 // One or more of these flags must be passed to ClearData() to specify just | 85 // One or more of these flags must be passed to ClearData() to specify just |
85 // what data to clear. See function declaration for more information. | 86 // what data to clear. See function declaration for more information. |
86 enum ClearFlags { | 87 enum ClearFlags { |
87 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, | 88 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, |
88 CLEAR_PRERENDER_HISTORY = 0x1 << 1, | 89 CLEAR_PRERENDER_HISTORY = 0x1 << 1, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 static bool IsPrefetchEnabled(); | 170 static bool IsPrefetchEnabled(); |
170 static void SetIsPrefetchEnabled(bool enabled); | 171 static void SetIsPrefetchEnabled(bool enabled); |
171 | 172 |
172 static PrerenderManagerMode GetMode(); | 173 static PrerenderManagerMode GetMode(); |
173 static void SetMode(PrerenderManagerMode mode); | 174 static void SetMode(PrerenderManagerMode mode); |
174 static const char* GetModeString(); | 175 static const char* GetModeString(); |
175 static bool IsPrerenderingPossible(); | 176 static bool IsPrerenderingPossible(); |
176 static bool ActuallyPrerendering(); | 177 static bool ActuallyPrerendering(); |
177 static bool IsControlGroup(); | 178 static bool IsControlGroup(); |
178 static bool IsNoUseGroup(); | 179 static bool IsNoUseGroup(); |
| 180 static size_t GetMaxConcurrency(); |
179 | 181 |
180 // Query the list of current prerender pages to see if the given web contents | 182 // Query the list of current prerender pages to see if the given web contents |
181 // is prerendering a page. | 183 // is prerendering a page. |
182 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; | 184 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; |
183 | 185 |
184 // Maintaining and querying the set of WebContents belonging to this | 186 // Maintaining and querying the set of WebContents belonging to this |
185 // PrerenderManager that are currently showing prerendered pages. | 187 // PrerenderManager that are currently showing prerendered pages. |
186 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); | 188 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); |
187 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); | 189 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); |
188 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 190 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 friend class PrerenderBrowserTest; | 308 friend class PrerenderBrowserTest; |
307 friend class PrerenderContents; | 309 friend class PrerenderContents; |
308 friend class PrerenderHandle; | 310 friend class PrerenderHandle; |
309 friend class UnitTestPrerenderManager; | 311 friend class UnitTestPrerenderManager; |
310 | 312 |
311 class OnCloseTabContentsDeleter; | 313 class OnCloseTabContentsDeleter; |
312 struct NavigationRecord; | 314 struct NavigationRecord; |
313 | 315 |
314 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 316 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
315 | 317 |
| 318 // Time interval before a new prerender is allowed. |
| 319 static const int kMinTimeBetweenPrerendersMs = 500; |
| 320 |
316 // Time window for which we record old navigations, in milliseconds. | 321 // Time window for which we record old navigations, in milliseconds. |
317 static const int kNavigationRecordWindowMs = 5000; | 322 static const int kNavigationRecordWindowMs = 5000; |
318 | 323 |
319 void OnCancelPrerenderHandle(PrerenderData* prerender_data); | 324 void OnCancelPrerenderHandle(PrerenderData* prerender_data); |
320 | 325 |
321 // Adds a prerender for |url| from |referrer| initiated from the process | 326 // Adds a prerender for |url| from |referrer| initiated from the process |
322 // |child_id|. The |origin| specifies how the prerender was added. If |size| | 327 // |child_id|. The |origin| specifies how the prerender was added. If |size| |
323 // is empty, then PrerenderContents::StartPrerendering will instead use a | 328 // is empty, then PrerenderContents::StartPrerendering will instead use a |
324 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the | 329 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the |
325 // caller, or NULL. | 330 // caller, or NULL. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 502 |
498 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 503 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
499 }; | 504 }; |
500 | 505 |
501 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 506 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
502 int render_process_id); | 507 int render_process_id); |
503 | 508 |
504 } // namespace prerender | 509 } // namespace prerender |
505 | 510 |
506 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 511 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |