prerender_manager.h revision 7d4cd473f85ac64c3747c96c277f9e506a0d2246
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.
4
5#ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
6#define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
7
8#include <list>
9#include <map>
10#include <string>
11#include <utility>
12#include <vector>
13
14#include "base/containers/hash_tables.h"
15#include "base/gtest_prod_util.h"
16#include "base/memory/scoped_ptr.h"
17#include "base/memory/scoped_vector.h"
18#include "base/memory/weak_ptr.h"
19#include "base/threading/non_thread_safe.h"
20#include "base/time.h"
21#include "base/timer.h"
22#include "chrome/browser/predictors/logged_in_predictor_table.h"
23#include "chrome/browser/prerender/prerender_config.h"
24#include "chrome/browser/prerender/prerender_contents.h"
25#include "chrome/browser/prerender/prerender_final_status.h"
26#include "chrome/browser/prerender/prerender_origin.h"
27#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
28#include "content/public/browser/notification_observer.h"
29#include "content/public/browser/notification_registrar.h"
30#include "googleurl/src/gurl.h"
31#include "net/cookies/cookie_monster.h"
32
33class Profile;
34struct ChromeCookieDetails;
35
36namespace base {
37class DictionaryValue;
38}
39
40namespace content {
41class WebContents;
42}
43
44namespace gfx {
45class Size;
46}
47
48namespace net {
49class URLRequestContextGetter;
50}
51
52#if defined(COMPILER_GCC)
53
54namespace BASE_HASH_NAMESPACE {
55template <>
56struct hash<content::WebContents*> {
57  std::size_t operator()(content::WebContents* value) const {
58    return reinterpret_cast<std::size_t>(value);
59  }
60};
61
62}  // namespace BASE_HASH_NAMESPACE
63
64#endif
65
66namespace prerender {
67
68class PrerenderCondition;
69class PrerenderHandle;
70class PrerenderHistograms;
71class PrerenderHistory;
72class PrerenderLocalPredictor;
73class PrerenderTracker;
74
75// PrerenderManager is responsible for initiating and keeping prerendered
76// views of web pages. All methods must be called on the UI thread unless
77// indicated otherwise.
78class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
79                         public base::NonThreadSafe,
80                         public content::NotificationObserver,
81                         public BrowserContextKeyedService {
82 public:
83  // NOTE: New values need to be appended, since they are used in histograms.
84  enum PrerenderManagerMode {
85    PRERENDER_MODE_DISABLED = 0,
86    PRERENDER_MODE_ENABLED = 1,
87    PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP = 2,
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    PRERENDER_MODE_MAX
94  };
95
96  // One or more of these flags must be passed to ClearData() to specify just
97  // what data to clear.  See function declaration for more information.
98  enum ClearFlags {
99    CLEAR_PRERENDER_CONTENTS = 0x1 << 0,
100    CLEAR_PRERENDER_HISTORY = 0x1 << 1,
101    CLEAR_MAX = 0x1 << 2
102  };
103
104  typedef predictors::LoggedInPredictorTable::LoggedInStateMap LoggedInStateMap;
105
106  // ID indicating that no experiment is active.
107  static const uint8 kNoExperiment = 0;
108
109  // Owned by a Profile object for the lifetime of the profile.
110  PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker);
111
112  virtual ~PrerenderManager();
113
114  // From BrowserContextKeyedService:
115  virtual void Shutdown() OVERRIDE;
116
117  // Entry points for adding prerenders.
118
119  // Adds a prerender for |url| if valid. |process_id| and |route_id| identify
120  // the RenderView that the prerender request came from. If |size| is empty, a
121  // default from the PrerenderConfig is used. Returns a caller-owned
122  // PrerenderHandle* if the URL was added, NULL if it was not. If the launching
123  // RenderView is itself prerendering, the prerender is added as a pending
124  // prerender.
125  PrerenderHandle* AddPrerenderFromLinkRelPrerender(
126      int process_id,
127      int route_id,
128      const GURL& url,
129      const content::Referrer& referrer,
130      const gfx::Size& size);
131
132  // Adds a prerender for |url| if valid. As the prerender request is coming
133  // from a source without a RenderViewHost (i.e., the omnibox) we don't have a
134  // child or route id, or a referrer. This method uses sensible values for
135  // those. The |session_storage_namespace| matches the namespace of the active
136  // tab at the time the prerender is generated from the omnibox. Returns a
137  // caller-owned PrerenderHandle*, or NULL.
138  PrerenderHandle* AddPrerenderFromOmnibox(
139      const GURL& url,
140      content::SessionStorageNamespace* session_storage_namespace,
141      const gfx::Size& size);
142
143  PrerenderHandle* AddPrerenderFromLocalPredictor(
144      const GURL& url,
145      content::SessionStorageNamespace* session_storage_namespace,
146      const gfx::Size& size);
147
148  // If |process_id| and |view_id| refer to a running prerender, destroy
149  // it with |final_status|.
150  virtual void DestroyPrerenderForRenderView(int process_id,
151                                             int view_id,
152                                             FinalStatus final_status);
153
154  // Cancels all active prerenders.
155  void CancelAllPrerenders();
156
157  // If |url| matches a valid prerendered page, try to swap it into
158  // |web_contents| and merge browsing histories. Returns |true| if a
159  // prerendered page is swapped in, |false| otherwise.
160  bool MaybeUsePrerenderedPage(content::WebContents* web_contents,
161                               const GURL& url);
162
163  // Moves a PrerenderContents to the pending delete list from the list of
164  // active prerenders when prerendering should be cancelled.
165  virtual void MoveEntryToPendingDelete(PrerenderContents* entry,
166                                        FinalStatus final_status);
167
168  // Records the perceived page load time for a page - effectively the time from
169  // when the user navigates to a page to when it finishes loading. The actual
170  // load may have started prior to navigation due to prerender hints.
171  // This must be called on the UI thread.
172  // |fraction_plt_elapsed_at_swap_in| must either be in [0.0, 1.0], or a value
173  // outside that range indicating that it doesn't apply.
174  static void RecordPerceivedPageLoadTime(
175      base::TimeDelta perceived_page_load_time,
176      double fraction_plt_elapsed_at_swap_in,
177      content::WebContents* web_contents,
178      const GURL& url);
179
180  // Records the percentage of pixels of the final page in place at swap-in.
181  void RecordFractionPixelsFinalAtSwapin(
182      content::WebContents* web_contents,
183      double fraction);
184
185  // Set whether prerendering is currently enabled for this manager.
186  // Must be called on the UI thread.
187  // If |enabled| is false, existing prerendered pages will still persist until
188  // they time out, but new ones will not be generated.
189  void set_enabled(bool enabled);
190
191  // Controls if we launch or squash prefetch requests as they arrive from
192  // renderers.
193  static bool IsPrefetchEnabled();
194  static void SetIsPrefetchEnabled(bool enabled);
195
196  static PrerenderManagerMode GetMode();
197  static void SetMode(PrerenderManagerMode mode);
198  static const char* GetModeString();
199  static bool IsPrerenderingPossible();
200  static bool ActuallyPrerendering();
201  static bool IsControlGroup(uint8 experiment_id);
202  static bool IsNoUseGroup();
203
204  // Query the list of current prerender pages to see if the given web contents
205  // is prerendering a page. The optional parameter |origin| is an output
206  // parameter which, if a prerender is found, is set to the Origin of the
207  // prerender |web_contents|.
208  bool IsWebContentsPrerendering(const content::WebContents* web_contents,
209                                 Origin* origin) const;
210
211  // Returns the PrerenderContents object for the given web_contents if it's
212  // used for an active prerender page, otherwise returns NULL.
213  PrerenderContents* GetPrerenderContents(
214      const content::WebContents* web_contents) const;
215
216  // Returns a list of all WebContents being prerendered.
217  const std::vector<content::WebContents*> GetAllPrerenderingContents() const;
218
219  // Maintaining and querying the set of WebContents belonging to this
220  // PrerenderManager that are currently showing prerendered pages.
221  void MarkWebContentsAsPrerendered(content::WebContents* web_contents,
222                                    Origin origin);
223  void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents,
224                                           Origin origin);
225  void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents);
226
227  // Returns true if |web_contents| was originally a prerender that has since
228  // been swapped in. The optional parameter |origin| is an output parameter
229  // which, if a prerender is found, is set to the Origin of the prerender of
230  // |web_contents|.
231  bool IsWebContentsPrerendered(content::WebContents* web_contents,
232                                Origin* origin) const;
233  bool WouldWebContentsBePrerendered(content::WebContents* web_contents,
234                                     Origin* origin) const;
235
236  // Checks whether |url| has been recently navigated to.
237  bool HasRecentlyBeenNavigatedTo(Origin origin, const GURL& url);
238
239  // Returns true iff the method given is valid for prerendering.
240  static bool IsValidHttpMethod(const std::string& method);
241
242  // Returns true iff the scheme of the URL given is valid for prerendering.
243  static bool DoesURLHaveValidScheme(const GURL& url);
244
245  // Returns a Value object containing the active pages being prerendered, and
246  // a history of pages which were prerendered. The caller is responsible for
247  // deleting the return value.
248  base::DictionaryValue* GetAsValue() const;
249
250  // Clears the data indicated by which bits of clear_flags are set.
251  //
252  // If the CLEAR_PRERENDER_CONTENTS bit is set, all active prerenders are
253  // cancelled and then deleted, and any WebContents queued for destruction are
254  // destroyed as well.
255  //
256  // If the CLEAR_PRERENDER_HISTORY bit is set, the prerender history is
257  // cleared, including any entries newly created by destroying them in
258  // response to the CLEAR_PRERENDER_CONTENTS flag.
259  //
260  // Intended to be used when clearing the cache or history.
261  void ClearData(int clear_flags);
262
263  // Record a final status of a prerendered page in a histogram.
264  // This variation allows specifying whether prerendering had been started
265  // (necessary to flag MatchComplete dummies).
266  void RecordFinalStatusWithMatchCompleteStatus(
267      Origin origin,
268      uint8 experiment_id,
269      PrerenderContents::MatchCompleteStatus mc_status,
270      FinalStatus final_status) const;
271
272  // content::NotificationObserver
273  virtual void Observe(int type,
274                       const content::NotificationSource& source,
275                       const content::NotificationDetails& details) OVERRIDE;
276
277  const Config& config() const { return config_; }
278  Config& mutable_config() { return config_; }
279
280  PrerenderTracker* prerender_tracker() { return prerender_tracker_; }
281
282  // Adds a condition. This is owned by the PrerenderManager.
283  void AddCondition(const PrerenderCondition* condition);
284
285  // Records that some visible tab navigated (or was redirected) to the
286  // provided URL.
287  void RecordNavigation(const GURL& url);
288
289  // Updates the LoggedInPredictor state to reflect that a login has likely
290  // on the URL provided.
291  void RecordLikelyLoginOnURL(const GURL& url);
292
293  // Checks if the LoggedInPredictor shows that the user is likely logged on
294  // to the site for the URL provided.
295  void CheckIfLikelyLoggedInOnURL(const GURL& url,
296                                  bool* lookup_result,
297                                  bool* database_was_present,
298                                  const base::Closure& result_cb);
299
300  Profile* profile() const { return profile_; }
301
302  // Classes which will be tested in prerender unit browser tests should use
303  // these methods to get times for comparison, so that the test framework can
304  // mock advancing/retarding time.
305  virtual base::Time GetCurrentTime() const;
306  virtual base::TimeTicks GetCurrentTimeTicks() const;
307
308  scoped_refptr<predictors::LoggedInPredictorTable>
309  logged_in_predictor_table() {
310    return logged_in_predictor_table_;
311  }
312
313  PrerenderLocalPredictor* local_predictor() {
314    return local_predictor_.get();
315  }
316
317 protected:
318  class PrerenderData : public base::SupportsWeakPtr<PrerenderData> {
319   public:
320    struct OrderByExpiryTime;
321
322    PrerenderData(PrerenderManager* manager,
323                  PrerenderContents* contents,
324                  base::TimeTicks expiry_time);
325
326    ~PrerenderData();
327
328    // Turn this PrerenderData into a Match Complete replacement for itself,
329    // placing the current prerender contents into |to_delete_prerenders_|.
330    void MakeIntoMatchCompleteReplacement();
331
332    // A new PrerenderHandle has been created for this PrerenderData.
333    void OnHandleCreated(PrerenderHandle* prerender_handle);
334
335    // The launcher associated with a handle is navigating away from the context
336    // that launched this prerender. If the prerender is active, it may stay
337    // alive briefly though, in case we we going through a redirect chain that
338    // will eventually land at it.
339    void OnHandleNavigatedAway(PrerenderHandle* prerender_handle);
340
341    // The launcher associated with a handle has taken explicit action to cancel
342    // this prerender. We may well destroy the prerender in this case if no
343    // other handles continue to track it.
344    void OnHandleCanceled(PrerenderHandle* prerender_handle);
345
346    PrerenderContents* contents() { return contents_.get(); }
347
348    PrerenderContents* ReleaseContents();
349
350    int handle_count() const { return handle_count_; }
351
352    base::TimeTicks expiry_time() const { return expiry_time_; }
353    void set_expiry_time(base::TimeTicks expiry_time) {
354      expiry_time_ = expiry_time;
355    }
356
357   private:
358    PrerenderManager* manager_;
359    scoped_ptr<PrerenderContents> contents_;
360
361    // The number of distinct PrerenderHandles created for |this|, including
362    // ones that have called PrerenderData::OnHandleNavigatedAway(), but not
363    // counting the ones that have called PrerenderData::OnHandleCanceled(). For
364    // pending prerenders, this will always be 1, since the PrerenderManager
365    // only merges handles of running prerenders.
366    int handle_count_;
367
368    // After this time, this prerender is no longer fresh, and should be
369    // removed.
370    base::TimeTicks expiry_time_;
371
372    DISALLOW_COPY_AND_ASSIGN(PrerenderData);
373  };
374
375  void SetPrerenderContentsFactory(
376      PrerenderContents::Factory* prerender_contents_factory);
377
378  // Adds prerenders from the pending Prerenders, called by
379  // PrerenderContents::StartPendingPrerenders.
380  void StartPendingPrerenders(
381      int process_id,
382      ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders,
383      content::SessionStorageNamespace* session_storage_namespace);
384
385  // Called by a PrerenderData to signal that the launcher has navigated away
386  // from the context that launched the prerender. A user may have clicked
387  // a link in a page containing a <link rel=prerender> element, or the user
388  // might have committed an omnibox navigation. This is used to possibly
389  // shorten the TTL of the prerendered page.
390  void SourceNavigatedAway(PrerenderData* prerender_data);
391
392 private:
393  friend class PrerenderBrowserTest;
394  friend class PrerenderContents;
395  friend class PrerenderHandle;
396  friend class UnitTestPrerenderManager;
397
398  class OnCloseWebContentsDeleter;
399  struct NavigationRecord;
400
401  // For each WebContents that is swapped in, we store a
402  // PrerenderedWebContentsData so that we can track the origin of the
403  // prerender.
404  struct PrerenderedWebContentsData {
405    explicit PrerenderedWebContentsData(Origin origin);
406
407    Origin origin;
408  };
409
410  // In the control group experimental group for each WebContents "not swapped
411  // in" we create a WouldBePrerenderedWebContentsData to the origin of the
412  // "prerender" we did not launch. We also track a state machine to ensure
413  // the histogram reporting tracks what histograms would have done.
414  struct WouldBePrerenderedWebContentsData {
415    // When the WebContents gets a provisional load, we'd like to remove the
416    // WebContents from  the map since the new navigation would not have swapped
417    // in a prerender. But the first provisional load after the control
418    // prerender is not "swapped in" is actually to the prerendered location! So
419    // we don't remove the item from the map on the first provisional load, but
420    // we do for subsequent loads.
421    enum State {
422      WAITING_FOR_PROVISIONAL_LOAD,
423      SEEN_PROVISIONAL_LOAD,
424    };
425
426    explicit WouldBePrerenderedWebContentsData(Origin origin);
427
428    Origin origin;
429    State state;
430  };
431
432  // Time interval before a new prerender is allowed.
433  static const int kMinTimeBetweenPrerendersMs = 500;
434
435  // Time window for which we record old navigations, in milliseconds.
436  static const int kNavigationRecordWindowMs = 5000;
437
438  void OnCancelPrerenderHandle(PrerenderData* prerender_data);
439
440  // Adds a prerender for |url| from |referrer| initiated from the process
441  // |child_id|. The |origin| specifies how the prerender was added. If |size|
442  // is empty, then PrerenderContents::StartPrerendering will instead use a
443  // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the
444  // caller, or NULL.
445  PrerenderHandle* AddPrerender(
446      Origin origin,
447      int child_id,
448      const GURL& url,
449      const content::Referrer& referrer,
450      const gfx::Size& size,
451      content::SessionStorageNamespace* session_storage_namespace);
452
453  void StartSchedulingPeriodicCleanups();
454  void StopSchedulingPeriodicCleanups();
455
456  void EvictOldestPrerendersIfNecessary();
457
458  // Deletes stale and cancelled prerendered PrerenderContents, as well as
459  // WebContents that have been replaced by prerendered WebContents.
460  // Also identifies and kills PrerenderContents that use too much
461  // resources.
462  void PeriodicCleanup();
463
464  // Posts a task to call PeriodicCleanup.  Results in quicker destruction of
465  // objects.  If |this| is deleted before the task is run, the task will
466  // automatically be cancelled.
467  void PostCleanupTask();
468
469  base::TimeTicks GetExpiryTimeForNewPrerender(Origin origin) const;
470  base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const;
471
472  void DeleteOldEntries();
473  virtual PrerenderContents* CreatePrerenderContents(
474      const GURL& url,
475      const content::Referrer& referrer,
476      Origin origin,
477      uint8 experiment_id);
478
479  // Insures the |active_prerenders_| are sorted by increasing expiry time. Call
480  // after every mutation of active_prerenders_ that can possibly make it
481  // unsorted (e.g. an insert, or changing an expiry time).
482  void SortActivePrerenders();
483
484  // Finds the active PrerenderData object for a running prerender matching
485  // |url| and |session_storage_namespace|.
486  PrerenderData* FindPrerenderData(
487      const GURL& url,
488      const content::SessionStorageNamespace* session_storage_namespace);
489
490  // If |child_id| and |route_id| correspond to a RenderView that is an active
491  // prerender, returns the PrerenderData object for that prerender. Otherwise,
492  // returns NULL.
493  PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id);
494
495  // Given the |prerender_contents|, find the iterator in active_prerenders_
496  // correponding to the given prerender.
497  ScopedVector<PrerenderData>::iterator
498      FindIteratorForPrerenderContents(PrerenderContents* prerender_contents);
499
500  bool DoesRateLimitAllowPrerender(Origin origin) const;
501
502  // Deletes old WebContents that have been replaced by prerendered ones.  This
503  // is needed because they're replaced in a callback from the old WebContents,
504  // so cannot immediately be deleted.
505  void DeleteOldWebContents();
506
507  // Cleans up old NavigationRecord's.
508  void CleanUpOldNavigations();
509
510  // Arrange for the given WebContents to be deleted asap. If deleter is not
511  // NULL, deletes that as well.
512  void ScheduleDeleteOldWebContents(content::WebContents* tab,
513                                    OnCloseWebContentsDeleter* deleter);
514
515  // Adds to the history list.
516  void AddToHistory(PrerenderContents* contents);
517
518  // Returns a new Value representing the pages currently being prerendered. The
519  // caller is responsible for delete'ing the return value.
520  base::Value* GetActivePrerendersAsValue() const;
521
522  // Destroys all pending prerenders using FinalStatus.  Also deletes them as
523  // well as any swapped out WebContents queued for destruction.
524  // Used both on destruction, and when clearing the browsing history.
525  void DestroyAllContents(FinalStatus final_status);
526
527  // Helper function to destroy a PrerenderContents with the specified
528  // final_status, while at the same time recording that for the MatchComplete
529  // case, that this prerender would have been used.
530  void DestroyAndMarkMatchCompleteAsUsed(PrerenderContents* prerender_contents,
531                                         FinalStatus final_status);
532
533  // Record a final status of a prerendered page in a histogram.
534  // This is a helper function which will ultimately call
535  // RecordFinalStatusWthMatchCompleteStatus, using MATCH_COMPLETE_DEFAULT.
536  void RecordFinalStatus(Origin origin,
537                         uint8 experiment_id,
538                         FinalStatus final_status) const;
539
540  // Returns whether prerendering is currently enabled for this manager.
541  // Must be called on the UI thread.
542  bool IsEnabled() const;
543
544  void CookieChanged(ChromeCookieDetails* details);
545  void CookieChangedAnyCookiesLeftLookupResult(const std::string& domain_key,
546                                               bool cookies_exist);
547  void LoggedInPredictorDataReceived(scoped_ptr<LoggedInStateMap> new_map);
548
549  // The configuration.
550  Config config_;
551
552  // Specifies whether prerendering is currently enabled for this
553  // manager. The value can change dynamically during the lifetime
554  // of the PrerenderManager.
555  bool enabled_;
556
557  static bool is_prefetch_enabled_;
558
559  // The profile that owns this PrerenderManager.
560  Profile* profile_;
561
562  PrerenderTracker* prerender_tracker_;
563
564  // All running prerenders. Sorted by expiry time, in ascending order.
565  ScopedVector<PrerenderData> active_prerenders_;
566
567  // Prerenders awaiting deletion.
568  ScopedVector<PrerenderData> to_delete_prerenders_;
569
570  // List of recent navigations in this profile, sorted by ascending
571  // navigate_time_.
572  std::list<NavigationRecord> navigations_;
573
574  // This map is from all WebContents which are currently displaying a
575  // prerendered page which has already been swapped in to a
576  // PrerenderedWebContentsData for tracking full lifetime information
577  // on prerenders.
578  base::hash_map<content::WebContents*, PrerenderedWebContentsData>
579      prerendered_web_contents_data_;
580
581  // WebContents that would have been swapped out for a prerendered WebContents
582  // if the user was not part of the control group for measurement. When the
583  // WebContents gets a provisional load, the WebContents is removed from
584  // the map since the new navigation would not have swapped in a prerender.
585  // However, one complication exists because the first provisional load after
586  // the WebContents is marked as "Would Have Been Prerendered" is actually to
587  // the prerendered location. So, we need to keep a state around that does
588  // not clear the item from the map on the first provisional load, but does
589  // for subsequent loads.
590  base::hash_map<content::WebContents*, WouldBePrerenderedWebContentsData>
591      would_be_prerendered_map_;
592
593  scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_;
594
595  static PrerenderManagerMode mode_;
596
597  // A count of how many prerenders we do per session. Initialized to 0 then
598  // incremented and emitted to a histogram on each successful prerender.
599  static int prerenders_per_session_count_;
600
601  // RepeatingTimer to perform periodic cleanups of pending prerendered
602  // pages.
603  base::RepeatingTimer<PrerenderManager> repeating_timer_;
604
605  // Track time of last prerender to limit prerender spam.
606  base::TimeTicks last_prerender_start_time_;
607
608  std::list<content::WebContents*> old_web_contents_list_;
609
610  ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_;
611
612  scoped_ptr<PrerenderHistory> prerender_history_;
613
614  std::list<const PrerenderCondition*> prerender_conditions_;
615
616  scoped_ptr<PrerenderHistograms> histograms_;
617
618  scoped_ptr<PrerenderLocalPredictor> local_predictor_;
619
620  scoped_refptr<predictors::LoggedInPredictorTable> logged_in_predictor_table_;
621
622  // Here, we keep the logged in predictor state, but potentially a superset
623  // of its actual (database-backed) state, since we do not incorporate
624  // browser data deletion. We do not use this for actual lookups, but only
625  // to query cookie data for domains we know there was a login before.
626  // This is required to avoid a large number of cookie lookups on bulk
627  // deletion of cookies.
628  scoped_ptr<LoggedInStateMap> logged_in_state_;
629
630  content::NotificationRegistrar notification_registrar_;
631
632  DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
633};
634
635PrerenderManager* FindPrerenderManagerUsingRenderProcessId(
636    int render_process_id);
637
638}  // namespace prerender
639
640#endif  // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
641