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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 #endif | 53 #endif |
54 | 54 |
55 namespace prerender { | 55 namespace prerender { |
56 | 56 |
57 class PrerenderCondition; | 57 class PrerenderCondition; |
58 class PrerenderHistograms; | 58 class PrerenderHistograms; |
59 class PrerenderHistory; | 59 class PrerenderHistory; |
60 class PrerenderLocalPredictor; | 60 class PrerenderLocalPredictor; |
61 class PrerenderTracker; | 61 class PrerenderRenderViewTracker; |
62 | 62 |
63 // PrerenderManager is responsible for initiating and keeping prerendered | 63 // PrerenderManager is responsible for initiating and keeping prerendered |
64 // views of web pages. All methods must be called on the UI thread unless | 64 // views of web pages. All methods must be called on the UI thread unless |
65 // indicated otherwise. | 65 // indicated otherwise. |
66 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, | 66 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, |
67 public base::NonThreadSafe, | 67 public base::NonThreadSafe, |
68 public ProfileKeyedService { | 68 public ProfileKeyedService { |
69 public: | 69 public: |
70 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not | 70 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not |
71 // add in the middle. | 71 // add in the middle. |
(...skipping 12 matching lines...) Expand all Loading... |
84 enum ClearFlags { | 84 enum ClearFlags { |
85 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, | 85 CLEAR_PRERENDER_CONTENTS = 0x1 << 0, |
86 CLEAR_PRERENDER_HISTORY = 0x1 << 1, | 86 CLEAR_PRERENDER_HISTORY = 0x1 << 1, |
87 CLEAR_MAX = 0x1 << 2 | 87 CLEAR_MAX = 0x1 << 2 |
88 }; | 88 }; |
89 | 89 |
90 // ID indicating that no experiment is active. | 90 // ID indicating that no experiment is active. |
91 static const uint8 kNoExperiment = 0; | 91 static const uint8 kNoExperiment = 0; |
92 | 92 |
93 // Owned by a Profile object for the lifetime of the profile. | 93 // Owned by a Profile object for the lifetime of the profile. |
94 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); | 94 PrerenderManager(Profile* profile, |
| 95 PrerenderRenderViewTracker* prerender_render_view_tracker); |
95 | 96 |
96 virtual ~PrerenderManager(); | 97 virtual ~PrerenderManager(); |
97 | 98 |
98 // ProfileKeyedService implementation. | 99 // ProfileKeyedService implementation. |
99 virtual void Shutdown() OVERRIDE; | 100 virtual void Shutdown() OVERRIDE; |
100 | 101 |
101 // Entry points for adding prerenders. | 102 // Entry points for adding prerenders. |
102 | 103 |
103 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 104 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify |
104 // the RenderView that the prerender request came from. The |size| may be | 105 // the RenderView that the prerender request came from. The |size| may be |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // (necessary to flag MatchComplete dummies). | 228 // (necessary to flag MatchComplete dummies). |
228 void RecordFinalStatusWithMatchCompleteStatus( | 229 void RecordFinalStatusWithMatchCompleteStatus( |
229 Origin origin, | 230 Origin origin, |
230 uint8 experiment_id, | 231 uint8 experiment_id, |
231 PrerenderContents::MatchCompleteStatus mc_status, | 232 PrerenderContents::MatchCompleteStatus mc_status, |
232 FinalStatus final_status) const; | 233 FinalStatus final_status) const; |
233 | 234 |
234 const Config& config() const { return config_; } | 235 const Config& config() const { return config_; } |
235 Config& mutable_config() { return config_; } | 236 Config& mutable_config() { return config_; } |
236 | 237 |
237 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } | 238 PrerenderRenderViewTracker* prerender_render_view_tracker() { |
| 239 return prerender_render_view_tracker_; |
| 240 } |
238 | 241 |
239 // Adds a condition. This is owned by the PrerenderManager. | 242 // Adds a condition. This is owned by the PrerenderManager. |
240 void AddCondition(const PrerenderCondition* condition); | 243 void AddCondition(const PrerenderCondition* condition); |
241 | 244 |
242 bool IsTopSite(const GURL& url); | 245 bool IsTopSite(const GURL& url); |
243 | 246 |
244 bool IsPendingEntry(const GURL& url) const; | 247 bool IsPendingEntry(const GURL& url) const; |
245 | 248 |
246 // Returns true if |url| matches any URLs being prerendered. | 249 // Returns true if |url| matches any URLs being prerendered. |
247 bool IsPrerendering(const GURL& url) const; | 250 bool IsPrerendering(const GURL& url) const; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // Specifies whether prerendering is currently enabled for this | 433 // Specifies whether prerendering is currently enabled for this |
431 // manager. The value can change dynamically during the lifetime | 434 // manager. The value can change dynamically during the lifetime |
432 // of the PrerenderManager. | 435 // of the PrerenderManager. |
433 bool enabled_; | 436 bool enabled_; |
434 | 437 |
435 static bool is_prefetch_enabled_; | 438 static bool is_prefetch_enabled_; |
436 | 439 |
437 // The profile that owns this PrerenderManager. | 440 // The profile that owns this PrerenderManager. |
438 Profile* profile_; | 441 Profile* profile_; |
439 | 442 |
440 PrerenderTracker* prerender_tracker_; | 443 PrerenderRenderViewTracker* prerender_render_view_tracker_; |
441 | 444 |
442 // List of prerendered elements. | 445 // List of prerendered elements. |
443 PrerenderContentsDataList prerender_list_; | 446 PrerenderContentsDataList prerender_list_; |
444 | 447 |
445 // List of recent navigations in this profile, sorted by ascending | 448 // List of recent navigations in this profile, sorted by ascending |
446 // navigate_time_. | 449 // navigate_time_. |
447 std::list<NavigationRecord> navigations_; | 450 std::list<NavigationRecord> navigations_; |
448 | 451 |
449 // List of prerender elements to be deleted | 452 // List of prerender elements to be deleted |
450 std::list<PrerenderContents*> pending_delete_list_; | 453 std::list<PrerenderContents*> pending_delete_list_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 493 |
491 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 494 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
492 }; | 495 }; |
493 | 496 |
494 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 497 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
495 int render_process_id); | 498 int render_process_id); |
496 | 499 |
497 } // namespace prerender | 500 } // namespace prerender |
498 | 501 |
499 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 502 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |