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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/threading/non_thread_safe.h"
19 #include "base/time/time.h"
20 #include "base/timer/timer.h"
21 #include "chrome/browser/history/history_service.h"
22 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
23 #include "chrome/browser/predictors/logged_in_predictor_table.h"
24 #include "chrome/browser/prerender/prerender_config.h"
25 #include "chrome/browser/prerender/prerender_contents.h"
26 #include "chrome/browser/prerender/prerender_events.h"
27 #include "chrome/browser/prerender/prerender_final_status.h"
28 #include "chrome/browser/prerender/prerender_histograms.h"
29 #include "chrome/browser/prerender/prerender_origin.h"
30 #include "chrome/browser/prerender/prerender_tracker.h"
31 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
32 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h"
34 #include "content/public/browser/session_storage_namespace.h"
35 #include "content/public/browser/web_contents_observer.h"
36 #include "net/cookies/canonical_cookie.h"
37 #include "net/cookies/cookie_monster.h"
41 class InstantSearchPrerendererTest
;
42 struct ChromeCookieDetails
;
45 class DictionaryValue
;
49 struct NavigateParams
;
61 class URLRequestContextGetter
;
66 class PrerenderCondition
;
67 class PrerenderHandle
;
68 class PrerenderHistory
;
69 class PrerenderLocalPredictor
;
71 // PrerenderManager is responsible for initiating and keeping prerendered
72 // views of web pages. All methods must be called on the UI thread unless
73 // indicated otherwise.
74 class PrerenderManager
: public base::SupportsWeakPtr
<PrerenderManager
>,
75 public base::NonThreadSafe
,
76 public content::NotificationObserver
,
77 public BrowserContextKeyedService
,
78 public MediaCaptureDevicesDispatcher::Observer
{
80 // NOTE: New values need to be appended, since they are used in histograms.
81 enum PrerenderManagerMode
{
82 PRERENDER_MODE_DISABLED
= 0,
83 PRERENDER_MODE_ENABLED
= 1,
84 PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP
= 2,
85 PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP
= 3,
86 // Obsolete: PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP = 4,
87 PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP
= 5,
88 PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP
= 6,
89 PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP
= 7,
93 // One or more of these flags must be passed to ClearData() to specify just
94 // what data to clear. See function declaration for more information.
96 CLEAR_PRERENDER_CONTENTS
= 0x1 << 0,
97 CLEAR_PRERENDER_HISTORY
= 0x1 << 1,
101 typedef predictors::LoggedInPredictorTable::LoggedInStateMap LoggedInStateMap
;
103 // ID indicating that no experiment is active.
104 static const uint8 kNoExperiment
= 0;
106 // Owned by a Profile object for the lifetime of the profile.
107 PrerenderManager(Profile
* profile
, PrerenderTracker
* prerender_tracker
);
109 virtual ~PrerenderManager();
111 // From BrowserContextKeyedService:
112 virtual void Shutdown() OVERRIDE
;
114 // Entry points for adding prerenders.
116 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify
117 // the RenderView that the prerender request came from. If |size| is empty, a
118 // default from the PrerenderConfig is used. Returns a caller-owned
119 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching
120 // RenderView is itself prerendering, the prerender is added as a pending
122 PrerenderHandle
* AddPrerenderFromLinkRelPrerender(
127 const content::Referrer
& referrer
,
128 const gfx::Size
& size
);
130 // Adds a prerender for |url| if valid. As the prerender request is coming
131 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a
132 // child or route id, or a referrer. This method uses sensible values for
133 // those. The |session_storage_namespace| matches the namespace of the active
134 // tab at the time the prerender is generated from the omnibox. Returns a
135 // caller-owned PrerenderHandle*, or NULL.
136 PrerenderHandle
* AddPrerenderFromOmnibox(
138 content::SessionStorageNamespace
* session_storage_namespace
,
139 const gfx::Size
& size
);
141 PrerenderHandle
* AddPrerenderFromLocalPredictor(
143 content::SessionStorageNamespace
* session_storage_namespace
,
144 const gfx::Size
& size
);
146 PrerenderHandle
* AddPrerenderFromExternalRequest(
148 const content::Referrer
& referrer
,
149 content::SessionStorageNamespace
* session_storage_namespace
,
150 const gfx::Size
& size
);
152 // Adds a prerender for Instant Search |url| if valid. The
153 // |session_storage_namespace| matches the namespace of the active tab at the
154 // time the prerender is generated. Returns a caller-owned PrerenderHandle* or
156 PrerenderHandle
* AddPrerenderForInstant(
158 content::SessionStorageNamespace
* session_storage_namespace
,
159 const gfx::Size
& size
);
161 // Cancels all active prerenders.
162 void CancelAllPrerenders();
164 // If |url| matches a valid prerendered page and |params| are compatible, try
165 // to swap it and merge browsing histories. Returns |true| and updates
166 // |params->target_contents| if a prerendered page is swapped in, |false|
168 bool MaybeUsePrerenderedPage(const GURL
& url
,
169 chrome::NavigateParams
* params
);
171 // Moves a PrerenderContents to the pending delete list from the list of
172 // active prerenders when prerendering should be cancelled.
173 virtual void MoveEntryToPendingDelete(PrerenderContents
* entry
,
174 FinalStatus final_status
);
176 // Records the page load time for a prerender that wasn't swapped in.
177 void RecordPageLoadTimeNotSwappedIn(Origin origin
,
178 base::TimeDelta page_load_time
,
181 // Records the perceived page load time for a page - effectively the time from
182 // when the user navigates to a page to when it finishes loading. The actual
183 // load may have started prior to navigation due to prerender hints.
184 // This must be called on the UI thread.
185 // |fraction_plt_elapsed_at_swap_in| must either be in [0.0, 1.0], or a value
186 // outside that range indicating that it doesn't apply.
187 void RecordPerceivedPageLoadTime(
189 NavigationType navigation_type
,
190 base::TimeDelta perceived_page_load_time
,
191 double fraction_plt_elapsed_at_swap_in
,
194 // Set whether prerendering is currently enabled for this manager.
195 // Must be called on the UI thread.
196 // If |enabled| is false, existing prerendered pages will still persist until
197 // they time out, but new ones will not be generated.
198 void set_enabled(bool enabled
);
200 static PrerenderManagerMode
GetMode();
201 static void SetMode(PrerenderManagerMode mode
);
202 static const char* GetModeString();
203 static bool IsPrerenderingPossible();
204 static bool ActuallyPrerendering();
205 static bool IsControlGroup(uint8 experiment_id
);
206 static bool IsNoUseGroup();
208 // Query the list of current prerender pages to see if the given web contents
209 // is prerendering a page. The optional parameter |origin| is an output
210 // parameter which, if a prerender is found, is set to the Origin of the
211 // prerender |web_contents|.
212 bool IsWebContentsPrerendering(const content::WebContents
* web_contents
,
213 Origin
* origin
) const;
215 // Whether the PrerenderManager has an active prerender with the given url and
216 // SessionStorageNamespace associated with the given WebContens.
217 bool HasPrerenderedUrl(GURL url
, content::WebContents
* web_contents
) const;
219 // Returns the PrerenderContents object for the given web_contents, otherwise
220 // returns NULL. Note that the PrerenderContents may have been Destroy()ed,
221 // but not yet deleted.
222 PrerenderContents
* GetPrerenderContents(
223 const content::WebContents
* web_contents
) const;
225 // Returns the PrerenderContents object for a given child_id, route_id pair,
226 // otherwise returns NULL. Note that the PrerenderContents may have been
227 // Destroy()ed, but not yet deleted.
228 virtual PrerenderContents
* GetPrerenderContentsForRoute(
229 int child_id
, int route_id
) const;
231 // Returns a list of all WebContents being prerendered.
232 const std::vector
<content::WebContents
*> GetAllPrerenderingContents() const;
234 // Checks whether |url| has been recently navigated to.
235 bool HasRecentlyBeenNavigatedTo(Origin origin
, const GURL
& url
);
237 // Returns true iff the method given is valid for prerendering.
238 static bool IsValidHttpMethod(const std::string
& method
);
240 // Returns true iff the scheme of the URL given is valid for prerendering.
241 static bool DoesURLHaveValidScheme(const GURL
& url
);
243 // Returns true iff the scheme of the subresource URL given is valid for
245 static bool DoesSubresourceURLHaveValidScheme(const GURL
& url
);
247 // Returns a Value object containing the active pages being prerendered, and
248 // a history of pages which were prerendered. The caller is responsible for
249 // deleting the return value.
250 base::DictionaryValue
* GetAsValue() const;
252 // Clears the data indicated by which bits of clear_flags are set.
254 // If the CLEAR_PRERENDER_CONTENTS bit is set, all active prerenders are
255 // cancelled and then deleted, and any WebContents queued for destruction are
256 // destroyed as well.
258 // If the CLEAR_PRERENDER_HISTORY bit is set, the prerender history is
259 // cleared, including any entries newly created by destroying them in
260 // response to the CLEAR_PRERENDER_CONTENTS flag.
262 // Intended to be used when clearing the cache or history.
263 void ClearData(int clear_flags
);
265 // Record a final status of a prerendered page in a histogram.
266 // This variation allows specifying whether prerendering had been started
267 // (necessary to flag MatchComplete dummies).
268 void RecordFinalStatusWithMatchCompleteStatus(
271 PrerenderContents::MatchCompleteStatus mc_status
,
272 FinalStatus final_status
) const;
274 // Record a cookie status histogram (see prerender_histograms.h).
275 void RecordCookieStatus(Origin origin
,
277 int cookie_status
) const;
279 // content::NotificationObserver
280 virtual void Observe(int type
,
281 const content::NotificationSource
& source
,
282 const content::NotificationDetails
& details
) OVERRIDE
;
284 // MediaCaptureDevicesDispatcher::Observer
285 virtual void OnCreatingAudioStream(int render_process_id
,
286 int render_frame_id
) OVERRIDE
;
288 const Config
& config() const { return config_
; }
289 Config
& mutable_config() { return config_
; }
291 PrerenderTracker
* prerender_tracker() { return prerender_tracker_
; }
293 // Adds a condition. This is owned by the PrerenderManager.
294 void AddCondition(const PrerenderCondition
* condition
);
296 // Records that some visible tab navigated (or was redirected) to the
298 void RecordNavigation(const GURL
& url
);
300 // Updates the LoggedInPredictor state to reflect that a login has likely
301 // on the URL provided.
302 void RecordLikelyLoginOnURL(const GURL
& url
);
304 // Checks if the LoggedInPredictor shows that the user is likely logged on
305 // to the site for the URL provided.
306 void CheckIfLikelyLoggedInOnURL(const GURL
& url
,
308 bool* database_was_present
,
309 const base::Closure
& result_cb
);
311 void OnHistoryServiceDidQueryURL(Origin origin
,
313 CancelableRequestProvider::Handle handle
,
315 const history::URLRow
* url_row
,
316 history::VisitVector
* visits
);
318 Profile
* profile() const { return profile_
; }
320 // Classes which will be tested in prerender unit browser tests should use
321 // these methods to get times for comparison, so that the test framework can
322 // mock advancing/retarding time.
323 virtual base::Time
GetCurrentTime() const;
324 virtual base::TimeTicks
GetCurrentTimeTicks() const;
326 scoped_refptr
<predictors::LoggedInPredictorTable
>
327 logged_in_predictor_table() {
328 return logged_in_predictor_table_
;
331 PrerenderLocalPredictor
* local_predictor() {
332 return local_predictor_
.get();
335 // Notification that a cookie event happened on a render frame. Will record a
336 // cookie event for a given render frame, if it is being prerendered.
337 // If cookies were sent, all cookies must be supplied in |cookie_list|.
338 static void RecordCookieEvent(int process_id
,
341 const GURL
& frame_url
,
342 PrerenderContents::CookieEvent event
,
343 const net::CookieList
* cookie_list
);
345 // Arranges for all session storage merges to hang indefinitely. This is used
346 // to reliably test various swap abort cases.
347 static void HangSessionStorageMergesForTesting();
349 // Notification that a prerender has completed and its bytes should be
351 void RecordNetworkBytes(bool used
, int64 prerender_bytes
);
353 // Add to the running tally of bytes transferred over the network for this
354 // profile if prerendering is currently enabled.
355 void AddProfileNetworkBytesIfEnabled(int64 bytes
);
359 class PrerenderData
: public base::SupportsWeakPtr
<PrerenderData
> {
361 struct OrderByExpiryTime
;
363 PrerenderData(PrerenderManager
* manager
,
364 PrerenderContents
* contents
,
365 base::TimeTicks expiry_time
);
369 // Turn this PrerenderData into a Match Complete replacement for itself,
370 // placing the current prerender contents into |to_delete_prerenders_|.
371 void MakeIntoMatchCompleteReplacement();
373 // A new PrerenderHandle has been created for this PrerenderData.
374 void OnHandleCreated(PrerenderHandle
* prerender_handle
);
376 // The launcher associated with a handle is navigating away from the context
377 // that launched this prerender. If the prerender is active, it may stay
378 // alive briefly though, in case we we going through a redirect chain that
379 // will eventually land at it.
380 void OnHandleNavigatedAway(PrerenderHandle
* prerender_handle
);
382 // The launcher associated with a handle has taken explicit action to cancel
383 // this prerender. We may well destroy the prerender in this case if no
384 // other handles continue to track it.
385 void OnHandleCanceled(PrerenderHandle
* prerender_handle
);
387 PrerenderContents
* contents() { return contents_
.get(); }
389 PrerenderContents
* ReleaseContents();
391 int handle_count() const { return handle_count_
; }
393 base::TimeTicks
expiry_time() const { return expiry_time_
; }
394 void set_expiry_time(base::TimeTicks expiry_time
) {
395 expiry_time_
= expiry_time
;
398 void ClearPendingSwap();
400 PendingSwap
* pending_swap() { return pending_swap_
.get(); }
401 void set_pending_swap(PendingSwap
* pending_swap
) {
402 pending_swap_
.reset(pending_swap
);
406 PrerenderManager
* manager_
;
407 scoped_ptr
<PrerenderContents
> contents_
;
409 // The number of distinct PrerenderHandles created for |this|, including
410 // ones that have called PrerenderData::OnHandleNavigatedAway(), but not
411 // counting the ones that have called PrerenderData::OnHandleCanceled(). For
412 // pending prerenders, this will always be 1, since the PrerenderManager
413 // only merges handles of running prerenders.
416 // After this time, this prerender is no longer fresh, and should be
418 base::TimeTicks expiry_time_
;
420 // If a session storage namespace merge is in progress for this object,
421 // we need to keep track of various state associated with it.
422 scoped_ptr
<PendingSwap
> pending_swap_
;
424 DISALLOW_COPY_AND_ASSIGN(PrerenderData
);
427 // When a swap can't happen immediately, due to a sesison storage namespace
428 // merge, there will be a pending swap object while the merge is in
429 // progress. It retains all the data needed to do the merge, maintains
430 // throttles for the navigation in the target WebContents that needs to be
431 // delayed, and handles all conditions which would cancel a pending swap.
432 class PendingSwap
: public content::WebContentsObserver
{
434 PendingSwap(PrerenderManager
* manager
,
435 content::WebContents
* target_contents
,
436 PrerenderData
* prerender_data
,
438 bool should_replace_current_entry
);
439 virtual ~PendingSwap();
441 content::WebContents
* target_contents() const;
442 void set_swap_successful(bool swap_successful
) {
443 swap_successful_
= swap_successful
;
448 // content::WebContentsObserver implementation.
449 virtual void AboutToNavigateRenderView(
450 content::RenderViewHost
* render_view_host
) OVERRIDE
;
451 virtual void ProvisionalChangeToMainFrameUrl(
453 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
454 virtual void DidCommitProvisionalLoadForFrame(
456 const base::string16
& frame_unique_name
,
458 const GURL
& validated_url
,
459 content::PageTransition transition_type
,
460 content::RenderViewHost
* render_view_host
) OVERRIDE
;
461 virtual void DidFailProvisionalLoad(
463 const base::string16
& frame_unique_name
,
465 const GURL
& validated_url
,
467 const base::string16
& error_description
,
468 content::RenderViewHost
* render_view_host
) OVERRIDE
;
469 virtual void WebContentsDestroyed(content::WebContents
* web_contents
)
473 void RecordEvent(PrerenderEvent event
) const;
475 void OnMergeCompleted(content::SessionStorageNamespace::MergeResult result
);
476 void OnMergeTimeout();
478 // Prerender parameters.
479 PrerenderManager
* manager_
;
480 PrerenderData
* prerender_data_
;
482 bool should_replace_current_entry_
;
484 base::TimeTicks start_time_
;
485 PrerenderTracker::ChildRouteIdPair target_route_id_
;
486 bool seen_target_route_id_
;
487 base::OneShotTimer
<PendingSwap
> merge_timeout_
;
488 bool swap_successful_
;
490 base::WeakPtrFactory
<PendingSwap
> weak_factory_
;
493 void SetPrerenderContentsFactory(
494 PrerenderContents::Factory
* prerender_contents_factory
);
496 // Called by a PrerenderData to signal that the launcher has navigated away
497 // from the context that launched the prerender. A user may have clicked
498 // a link in a page containing a <link rel=prerender> element, or the user
499 // might have committed an omnibox navigation. This is used to possibly
500 // shorten the TTL of the prerendered page.
501 void SourceNavigatedAway(PrerenderData
* prerender_data
);
504 friend class ::InstantSearchPrerendererTest
;
505 friend class PrerenderBrowserTest
;
506 friend class PrerenderContents
;
507 friend class PrerenderHandle
;
508 friend class UnitTestPrerenderManager
;
510 class OnCloseWebContentsDeleter
;
511 struct NavigationRecord
;
513 // Time interval before a new prerender is allowed.
514 static const int kMinTimeBetweenPrerendersMs
= 500;
516 // Time window for which we record old navigations, in milliseconds.
517 static const int kNavigationRecordWindowMs
= 5000;
519 void OnCancelPrerenderHandle(PrerenderData
* prerender_data
);
521 // Adds a prerender for |url| from |referrer| initiated from the process
522 // |child_id|. The |origin| specifies how the prerender was added. If |size|
523 // is empty, then PrerenderContents::StartPrerendering will instead use a
524 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the
526 PrerenderHandle
* AddPrerender(
530 const content::Referrer
& referrer
,
531 const gfx::Size
& size
,
532 content::SessionStorageNamespace
* session_storage_namespace
);
534 void StartSchedulingPeriodicCleanups();
535 void StopSchedulingPeriodicCleanups();
537 void EvictOldestPrerendersIfNecessary();
539 // Deletes stale and cancelled prerendered PrerenderContents, as well as
540 // WebContents that have been replaced by prerendered WebContents.
541 // Also identifies and kills PrerenderContents that use too much
543 void PeriodicCleanup();
545 // Posts a task to call PeriodicCleanup. Results in quicker destruction of
546 // objects. If |this| is deleted before the task is run, the task will
547 // automatically be cancelled.
548 void PostCleanupTask();
550 base::TimeTicks
GetExpiryTimeForNewPrerender(Origin origin
) const;
551 base::TimeTicks
GetExpiryTimeForNavigatedAwayPrerender() const;
553 void DeleteOldEntries();
554 virtual PrerenderContents
* CreatePrerenderContents(
556 const content::Referrer
& referrer
,
558 uint8 experiment_id
);
560 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call
561 // after every mutation of active_prerenders_ that can possibly make it
562 // unsorted (e.g. an insert, or changing an expiry time).
563 void SortActivePrerenders();
565 // Finds the active PrerenderData object for a running prerender matching
566 // |url| and |session_storage_namespace|.
567 PrerenderData
* FindPrerenderData(
569 const content::SessionStorageNamespace
* session_storage_namespace
);
571 // Finds the active PrerenderData object currently in a PendingSwap for
572 // |target_contents|. Otherwise, returns NULL.
573 PrerenderData
* FindPrerenderDataForTargetContents(
574 content::WebContents
* target_contents
);
576 // Given the |prerender_contents|, find the iterator in active_prerenders_
577 // correponding to the given prerender.
578 ScopedVector
<PrerenderData
>::iterator
579 FindIteratorForPrerenderContents(PrerenderContents
* prerender_contents
);
581 bool DoesRateLimitAllowPrerender(Origin origin
) const;
583 // Deletes old WebContents that have been replaced by prerendered ones. This
584 // is needed because they're replaced in a callback from the old WebContents,
585 // so cannot immediately be deleted.
586 void DeleteOldWebContents();
588 // Cleans up old NavigationRecord's.
589 void CleanUpOldNavigations();
591 // Arrange for the given WebContents to be deleted asap. If deleter is not
592 // NULL, deletes that as well.
593 void ScheduleDeleteOldWebContents(content::WebContents
* tab
,
594 OnCloseWebContentsDeleter
* deleter
);
596 // Adds to the history list.
597 void AddToHistory(PrerenderContents
* contents
);
599 // Returns a new Value representing the pages currently being prerendered. The
600 // caller is responsible for delete'ing the return value.
601 base::Value
* GetActivePrerendersAsValue() const;
603 // Destroys all pending prerenders using FinalStatus. Also deletes them as
604 // well as any swapped out WebContents queued for destruction.
605 // Used both on destruction, and when clearing the browsing history.
606 void DestroyAllContents(FinalStatus final_status
);
608 // Helper function to destroy a PrerenderContents with the specified
609 // final_status, while at the same time recording that for the MatchComplete
610 // case, that this prerender would have been used.
611 void DestroyAndMarkMatchCompleteAsUsed(PrerenderContents
* prerender_contents
,
612 FinalStatus final_status
);
614 // Record a final status of a prerendered page in a histogram.
615 // This is a helper function which will ultimately call
616 // RecordFinalStatusWthMatchCompleteStatus, using MATCH_COMPLETE_DEFAULT.
617 void RecordFinalStatus(Origin origin
,
619 FinalStatus final_status
) const;
621 // Returns whether prerendering is currently enabled for this manager.
622 // Must be called on the UI thread.
623 bool IsEnabled() const;
625 void CookieChanged(ChromeCookieDetails
* details
);
626 void CookieChangedAnyCookiesLeftLookupResult(const std::string
& domain_key
,
628 void LoggedInPredictorDataReceived(scoped_ptr
<LoggedInStateMap
> new_map
);
630 void RecordEvent(PrerenderContents
* contents
, PrerenderEvent event
) const;
632 // Swaps a prerender |prerender_data| for |url| into the tab, replacing
633 // |web_contents|. Returns the new WebContents that was swapped in, or NULL
634 // if a swap-in was not possible. If |should_replace_current_entry| is true,
635 // the current history entry in |web_contents| is replaced.
636 content::WebContents
* SwapInternal(const GURL
& url
,
637 content::WebContents
* web_contents
,
638 PrerenderData
* prerender_data
,
639 bool should_replace_current_entry
);
641 // The configuration.
644 // Specifies whether prerendering is currently enabled for this
645 // manager. The value can change dynamically during the lifetime
646 // of the PrerenderManager.
649 // The profile that owns this PrerenderManager.
652 PrerenderTracker
* prerender_tracker_
;
654 // All running prerenders. Sorted by expiry time, in ascending order.
655 ScopedVector
<PrerenderData
> active_prerenders_
;
657 // Prerenders awaiting deletion.
658 ScopedVector
<PrerenderData
> to_delete_prerenders_
;
660 // List of recent navigations in this profile, sorted by ascending
662 std::list
<NavigationRecord
> navigations_
;
664 scoped_ptr
<PrerenderContents::Factory
> prerender_contents_factory_
;
666 static PrerenderManagerMode mode_
;
668 // A count of how many prerenders we do per session. Initialized to 0 then
669 // incremented and emitted to a histogram on each successful prerender.
670 static int prerenders_per_session_count_
;
672 // RepeatingTimer to perform periodic cleanups of pending prerendered
674 base::RepeatingTimer
<PrerenderManager
> repeating_timer_
;
676 // Track time of last prerender to limit prerender spam.
677 base::TimeTicks last_prerender_start_time_
;
679 std::list
<content::WebContents
*> old_web_contents_list_
;
681 ScopedVector
<OnCloseWebContentsDeleter
> on_close_web_contents_deleters_
;
683 scoped_ptr
<PrerenderHistory
> prerender_history_
;
685 std::list
<const PrerenderCondition
*> prerender_conditions_
;
687 scoped_ptr
<PrerenderHistograms
> histograms_
;
689 scoped_ptr
<PrerenderLocalPredictor
> local_predictor_
;
691 scoped_refptr
<predictors::LoggedInPredictorTable
> logged_in_predictor_table_
;
693 // Here, we keep the logged in predictor state, but potentially a superset
694 // of its actual (database-backed) state, since we do not incorporate
695 // browser data deletion. We do not use this for actual lookups, but only
696 // to query cookie data for domains we know there was a login before.
697 // This is required to avoid a large number of cookie lookups on bulk
698 // deletion of cookies.
699 scoped_ptr
<LoggedInStateMap
> logged_in_state_
;
701 content::NotificationRegistrar notification_registrar_
;
703 CancelableRequestConsumer query_url_consumer_
;
705 // The number of bytes transferred over the network for the profile this
706 // PrerenderManager is attached to.
707 int64 profile_network_bytes_
;
709 // The value of profile_network_bytes_ that was last recorded.
710 int64 last_recorded_profile_network_bytes_
;
712 DISALLOW_COPY_AND_ASSIGN(PrerenderManager
);
715 } // namespace prerender
717 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_