app_list: Re-enable people search.
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_manager.h
blobd5259de35deb052348400b25eae04ba2d6cf6452
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_
8 #include <list>
9 #include <map>
10 #include <string>
11 #include <utility>
12 #include <vector>
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/task/cancelable_task_tracker.h"
19 #include "base/threading/non_thread_safe.h"
20 #include "base/time/time.h"
21 #include "base/timer/timer.h"
22 #include "chrome/browser/history/history_service.h"
23 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
24 #include "chrome/browser/predictors/logged_in_predictor_table.h"
25 #include "chrome/browser/prerender/prerender_config.h"
26 #include "chrome/browser/prerender/prerender_contents.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 "components/keyed_service/core/keyed_service.h"
31 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h"
33 #include "content/public/browser/render_process_host_observer.h"
34 #include "net/cookies/canonical_cookie.h"
35 #include "net/cookies/cookie_monster.h"
36 #include "url/gurl.h"
38 class Profile;
39 class InstantSearchPrerendererTest;
40 struct ChromeCookieDetails;
42 namespace base {
43 class DictionaryValue;
46 namespace chrome {
47 struct NavigateParams;
50 namespace content {
51 class WebContents;
54 namespace gfx {
55 class Size;
58 namespace net {
59 class URLRequestContextGetter;
62 namespace prerender {
64 class PrerenderHandle;
65 class PrerenderHistory;
66 class PrerenderLocalPredictor;
67 class PrerenderTracker;
69 // PrerenderManager is responsible for initiating and keeping prerendered
70 // views of web pages. All methods must be called on the UI thread unless
71 // indicated otherwise.
72 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
73 public base::NonThreadSafe,
74 public content::NotificationObserver,
75 public content::RenderProcessHostObserver,
76 public KeyedService,
77 public MediaCaptureDevicesDispatcher::Observer {
78 public:
79 // NOTE: New values need to be appended, since they are used in histograms.
80 enum PrerenderManagerMode {
81 PRERENDER_MODE_DISABLED = 0,
82 PRERENDER_MODE_ENABLED = 1,
83 PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP = 2,
84 PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP = 3,
85 // Obsolete: PRERENDER_MODE_EXPERIMENT_5MIN_TTL_GROUP = 4,
86 PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP = 5,
87 PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP = 6,
88 PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP = 7,
89 PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP = 8,
90 PRERENDER_MODE_MAX
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.
95 enum ClearFlags {
96 CLEAR_PRERENDER_CONTENTS = 0x1 << 0,
97 CLEAR_PRERENDER_HISTORY = 0x1 << 1,
98 CLEAR_MAX = 0x1 << 2
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 ~PrerenderManager() override;
111 // From KeyedService:
112 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
121 // prerender.
122 PrerenderHandle* AddPrerenderFromLinkRelPrerender(
123 int process_id,
124 int route_id,
125 const GURL& url,
126 uint32 rel_types,
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 RenderFrameHost (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(
137 const GURL& url,
138 content::SessionStorageNamespace* session_storage_namespace,
139 const gfx::Size& size);
141 PrerenderHandle* AddPrerenderFromLocalPredictor(
142 const GURL& url,
143 content::SessionStorageNamespace* session_storage_namespace,
144 const gfx::Size& size);
146 PrerenderHandle* AddPrerenderFromExternalRequest(
147 const GURL& url,
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
155 // NULL.
156 PrerenderHandle* AddPrerenderForInstant(
157 const GURL& url,
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|
167 // otherwise.
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,
179 const GURL& url);
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(
188 Origin origin,
189 NavigationType navigation_type,
190 base::TimeDelta perceived_page_load_time,
191 double fraction_plt_elapsed_at_swap_in,
192 const GURL& url);
194 static PrerenderManagerMode GetMode();
195 static void SetMode(PrerenderManagerMode mode);
196 static const char* GetModeString();
197 static bool IsPrerenderingPossible();
198 static bool ActuallyPrerendering();
199 static bool IsControlGroup(uint8 experiment_id);
200 static bool IsNoUseGroup();
202 // Query the list of current prerender pages to see if the given web contents
203 // is prerendering a page. The optional parameter |origin| is an output
204 // parameter which, if a prerender is found, is set to the Origin of the
205 // prerender |web_contents|.
206 bool IsWebContentsPrerendering(const content::WebContents* web_contents,
207 Origin* origin) const;
209 // Whether the PrerenderManager has an active prerender with the given url and
210 // SessionStorageNamespace associated with the given WebContens.
211 bool HasPrerenderedUrl(GURL url, content::WebContents* web_contents) const;
213 // Returns the PrerenderContents object for the given web_contents, otherwise
214 // returns NULL. Note that the PrerenderContents may have been Destroy()ed,
215 // but not yet deleted.
216 PrerenderContents* GetPrerenderContents(
217 const content::WebContents* web_contents) const;
219 // Returns the PrerenderContents object for a given child_id, route_id pair,
220 // otherwise returns NULL. Note that the PrerenderContents may have been
221 // Destroy()ed, but not yet deleted.
222 virtual PrerenderContents* GetPrerenderContentsForRoute(
223 int child_id, int route_id) const;
225 // Returns a list of all WebContents being prerendered.
226 const std::vector<content::WebContents*> GetAllPrerenderingContents() const;
228 // Checks whether |url| has been recently navigated to.
229 bool HasRecentlyBeenNavigatedTo(Origin origin, const GURL& url);
231 // Returns true iff the method given is valid for prerendering.
232 static bool IsValidHttpMethod(const std::string& method);
234 // Returns true iff the scheme of the URL given is valid for prerendering.
235 static bool DoesURLHaveValidScheme(const GURL& url);
237 // Returns true iff the scheme of the subresource URL given is valid for
238 // prerendering.
239 static bool DoesSubresourceURLHaveValidScheme(const GURL& url);
241 // Returns a Value object containing the active pages being prerendered, and
242 // a history of pages which were prerendered. The caller is responsible for
243 // deleting the return value.
244 base::DictionaryValue* GetAsValue() const;
246 // Clears the data indicated by which bits of clear_flags are set.
248 // If the CLEAR_PRERENDER_CONTENTS bit is set, all active prerenders are
249 // cancelled and then deleted, and any WebContents queued for destruction are
250 // destroyed as well.
252 // If the CLEAR_PRERENDER_HISTORY bit is set, the prerender history is
253 // cleared, including any entries newly created by destroying them in
254 // response to the CLEAR_PRERENDER_CONTENTS flag.
256 // Intended to be used when clearing the cache or history.
257 void ClearData(int clear_flags);
259 // Record a final status of a prerendered page in a histogram.
260 // This variation allows specifying whether prerendering had been started
261 // (necessary to flag MatchComplete dummies).
262 void RecordFinalStatusWithMatchCompleteStatus(
263 Origin origin,
264 uint8 experiment_id,
265 PrerenderContents::MatchCompleteStatus mc_status,
266 FinalStatus final_status) const;
268 // Record a cookie status histogram (see prerender_histograms.h).
269 void RecordCookieStatus(Origin origin,
270 uint8 experiment_id,
271 int cookie_status) const;
273 // Record a cookie send type histogram (see prerender_histograms.h).
274 void RecordCookieSendType(Origin origin,
275 uint8 experiment_id,
276 int cookie_send_type) const;
278 // content::NotificationObserver
279 void Observe(int type,
280 const content::NotificationSource& source,
281 const content::NotificationDetails& details) override;
283 // MediaCaptureDevicesDispatcher::Observer
284 void OnCreatingAudioStream(int render_process_id,
285 int render_frame_id) override;
287 const Config& config() const { return config_; }
288 Config& mutable_config() { return config_; }
290 PrerenderTracker* prerender_tracker() { return prerender_tracker_; }
292 bool cookie_store_loaded() { return cookie_store_loaded_; }
294 // Records that some visible tab navigated (or was redirected) to the
295 // provided URL.
296 void RecordNavigation(const GURL& url);
298 // Updates the LoggedInPredictor state to reflect that a login has likely
299 // on the URL provided.
300 void RecordLikelyLoginOnURL(const GURL& url);
302 // Checks if the LoggedInPredictor shows that the user is likely logged on
303 // to the site for the URL provided.
304 void CheckIfLikelyLoggedInOnURL(const GURL& url,
305 bool* lookup_result,
306 bool* database_was_present,
307 const base::Closure& result_cb);
309 void OnHistoryServiceDidQueryURL(Origin origin,
310 uint8 experiment_id,
311 bool success,
312 const history::URLRow& url_row,
313 const history::VisitVector& visits);
315 Profile* profile() const { return profile_; }
317 // Classes which will be tested in prerender unit browser tests should use
318 // these methods to get times for comparison, so that the test framework can
319 // mock advancing/retarding time.
320 virtual base::Time GetCurrentTime() const;
321 virtual base::TimeTicks GetCurrentTimeTicks() const;
323 scoped_refptr<predictors::LoggedInPredictorTable>
324 logged_in_predictor_table() {
325 return logged_in_predictor_table_;
328 PrerenderLocalPredictor* local_predictor() {
329 return local_predictor_.get();
332 // Notification that a cookie event happened on a render frame. Will record a
333 // cookie event for a given render frame, if it is being prerendered.
334 // If cookies were sent, all cookies must be supplied in |cookie_list|.
335 static void RecordCookieEvent(int process_id,
336 int frame_id,
337 const GURL& url,
338 const GURL& frame_url,
339 bool is_for_blocking_resource,
340 PrerenderContents::CookieEvent event,
341 const net::CookieList* cookie_list);
343 // Notification that a prerender has completed and its bytes should be
344 // recorded.
345 void RecordNetworkBytes(Origin origin, bool used, int64 prerender_bytes);
347 // Returns whether prerendering is currently enabled for this manager.
348 bool IsEnabled() const;
350 // Add to the running tally of bytes transferred over the network for this
351 // profile if prerendering is currently enabled.
352 void AddProfileNetworkBytesIfEnabled(int64 bytes);
354 // Registers a new ProcessHost performing a prerender. Called by
355 // PrerenderContents.
356 void AddPrerenderProcessHost(content::RenderProcessHost* process_host);
358 // Returns whether or not |process_host| may be reused for new navigations
359 // from a prerendering perspective. Currently, if Prerender Cookie Stores are
360 // enabled, prerenders must be in their own processes that may not be shared.
361 bool MayReuseProcessHost(content::RenderProcessHost* process_host);
363 // content::RenderProcessHostObserver implementation.
364 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
366 // To be called once the cookie store for this profile has been loaded.
367 void OnCookieStoreLoaded();
369 // For testing purposes. Issues a callback once the cookie store has been
370 // loaded.
371 void set_on_cookie_store_loaded_cb_for_testing(base::Closure cb) {
372 on_cookie_store_loaded_cb_for_testing_ = cb;
375 protected:
376 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> {
377 public:
378 struct OrderByExpiryTime;
380 PrerenderData(PrerenderManager* manager,
381 PrerenderContents* contents,
382 base::TimeTicks expiry_time);
384 ~PrerenderData();
386 // Turn this PrerenderData into a Match Complete replacement for itself,
387 // placing the current prerender contents into |to_delete_prerenders_|.
388 void MakeIntoMatchCompleteReplacement();
390 // A new PrerenderHandle has been created for this PrerenderData.
391 void OnHandleCreated(PrerenderHandle* prerender_handle);
393 // The launcher associated with a handle is navigating away from the context
394 // that launched this prerender. If the prerender is active, it may stay
395 // alive briefly though, in case we we going through a redirect chain that
396 // will eventually land at it.
397 void OnHandleNavigatedAway(PrerenderHandle* prerender_handle);
399 // The launcher associated with a handle has taken explicit action to cancel
400 // this prerender. We may well destroy the prerender in this case if no
401 // other handles continue to track it.
402 void OnHandleCanceled(PrerenderHandle* prerender_handle);
404 PrerenderContents* contents() { return contents_.get(); }
406 PrerenderContents* ReleaseContents();
408 int handle_count() const { return handle_count_; }
410 base::TimeTicks abandon_time() const { return abandon_time_; }
412 base::TimeTicks expiry_time() const { return expiry_time_; }
413 void set_expiry_time(base::TimeTicks expiry_time) {
414 expiry_time_ = expiry_time;
417 private:
418 PrerenderManager* manager_;
419 scoped_ptr<PrerenderContents> contents_;
421 // The number of distinct PrerenderHandles created for |this|, including
422 // ones that have called PrerenderData::OnHandleNavigatedAway(), but not
423 // counting the ones that have called PrerenderData::OnHandleCanceled(). For
424 // pending prerenders, this will always be 1, since the PrerenderManager
425 // only merges handles of running prerenders.
426 int handle_count_;
428 // The time when OnHandleNavigatedAway was called.
429 base::TimeTicks abandon_time_;
431 // After this time, this prerender is no longer fresh, and should be
432 // removed.
433 base::TimeTicks expiry_time_;
435 DISALLOW_COPY_AND_ASSIGN(PrerenderData);
438 void SetPrerenderContentsFactory(
439 PrerenderContents::Factory* prerender_contents_factory);
441 // Called by a PrerenderData to signal that the launcher has navigated away
442 // from the context that launched the prerender. A user may have clicked
443 // a link in a page containing a <link rel=prerender> element, or the user
444 // might have committed an omnibox navigation. This is used to possibly
445 // shorten the TTL of the prerendered page.
446 void SourceNavigatedAway(PrerenderData* prerender_data);
448 // Gets the request context for the profile.
449 // For unit tests, this will be overriden to return NULL, since it is not
450 // needed.
451 virtual net::URLRequestContextGetter* GetURLRequestContext();
453 private:
454 friend class ::InstantSearchPrerendererTest;
455 friend class PrerenderBrowserTest;
456 friend class PrerenderContents;
457 friend class PrerenderHandle;
458 friend class UnitTestPrerenderManager;
460 class OnCloseWebContentsDeleter;
461 struct NavigationRecord;
463 // Time interval before a new prerender is allowed.
464 static const int kMinTimeBetweenPrerendersMs = 500;
466 // Time window for which we record old navigations, in milliseconds.
467 static const int kNavigationRecordWindowMs = 5000;
469 void OnCancelPrerenderHandle(PrerenderData* prerender_data);
471 // Adds a prerender for |url| from |referrer|. The |origin| specifies how the
472 // prerender was added. If |size| is empty, then
473 // PrerenderContents::StartPrerendering will instead use a default from
474 // PrerenderConfig. Returns a PrerenderHandle*, owned by the caller, or NULL.
475 PrerenderHandle* AddPrerender(
476 Origin origin,
477 const GURL& url,
478 const content::Referrer& referrer,
479 const gfx::Size& size,
480 content::SessionStorageNamespace* session_storage_namespace);
482 void StartSchedulingPeriodicCleanups();
483 void StopSchedulingPeriodicCleanups();
485 void EvictOldestPrerendersIfNecessary();
487 // Deletes stale and cancelled prerendered PrerenderContents, as well as
488 // WebContents that have been replaced by prerendered WebContents.
489 // Also identifies and kills PrerenderContents that use too much
490 // resources.
491 void PeriodicCleanup();
493 // Posts a task to call PeriodicCleanup. Results in quicker destruction of
494 // objects. If |this| is deleted before the task is run, the task will
495 // automatically be cancelled.
496 void PostCleanupTask();
498 base::TimeTicks GetExpiryTimeForNewPrerender(Origin origin) const;
499 base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const;
501 void DeleteOldEntries();
502 virtual PrerenderContents* CreatePrerenderContents(
503 const GURL& url,
504 const content::Referrer& referrer,
505 Origin origin,
506 uint8 experiment_id);
508 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call
509 // after every mutation of active_prerenders_ that can possibly make it
510 // unsorted (e.g. an insert, or changing an expiry time).
511 void SortActivePrerenders();
513 // Finds the active PrerenderData object for a running prerender matching
514 // |url| and |session_storage_namespace|.
515 PrerenderData* FindPrerenderData(
516 const GURL& url,
517 const content::SessionStorageNamespace* session_storage_namespace);
519 // Given the |prerender_contents|, find the iterator in active_prerenders_
520 // correponding to the given prerender.
521 ScopedVector<PrerenderData>::iterator
522 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents);
524 bool DoesRateLimitAllowPrerender(Origin origin) const;
526 // Deletes old WebContents that have been replaced by prerendered ones. This
527 // is needed because they're replaced in a callback from the old WebContents,
528 // so cannot immediately be deleted.
529 void DeleteOldWebContents();
531 // Cleans up old NavigationRecord's.
532 void CleanUpOldNavigations();
534 // Arrange for the given WebContents to be deleted asap. If deleter is not
535 // NULL, deletes that as well.
536 void ScheduleDeleteOldWebContents(content::WebContents* tab,
537 OnCloseWebContentsDeleter* deleter);
539 // Adds to the history list.
540 void AddToHistory(PrerenderContents* contents);
542 // Returns a new Value representing the pages currently being prerendered. The
543 // caller is responsible for delete'ing the return value.
544 base::Value* GetActivePrerendersAsValue() const;
546 // Destroys all pending prerenders using FinalStatus. Also deletes them as
547 // well as any swapped out WebContents queued for destruction.
548 // Used both on destruction, and when clearing the browsing history.
549 void DestroyAllContents(FinalStatus final_status);
551 // Helper function to destroy a PrerenderContents with the specified
552 // final_status, while at the same time recording that for the MatchComplete
553 // case, that this prerender would have been used.
554 void DestroyAndMarkMatchCompleteAsUsed(PrerenderContents* prerender_contents,
555 FinalStatus final_status);
557 // Records the final status a prerender in the case that a PrerenderContents
558 // was never created, and also adds a PrerenderHistory entry.
559 // This is a helper function which will ultimately call
560 // RecordFinalStatusWthMatchCompleteStatus, using MATCH_COMPLETE_DEFAULT.
561 void RecordFinalStatusWithoutCreatingPrerenderContents(
562 const GURL& url, Origin origin, uint8 experiment_id,
563 FinalStatus final_status) const;
566 void CookieChanged(ChromeCookieDetails* details);
567 void CookieChangedAnyCookiesLeftLookupResult(const std::string& domain_key,
568 bool cookies_exist);
569 void LoggedInPredictorDataReceived(scoped_ptr<LoggedInStateMap> new_map);
571 // Swaps a prerender |prerender_data| for |url| into the tab, replacing
572 // |web_contents|. Returns the new WebContents that was swapped in, or NULL
573 // if a swap-in was not possible. If |should_replace_current_entry| is true,
574 // the current history entry in |web_contents| is replaced.
575 content::WebContents* SwapInternal(const GURL& url,
576 content::WebContents* web_contents,
577 PrerenderData* prerender_data,
578 bool should_replace_current_entry);
580 // The configuration.
581 Config config_;
583 // The profile that owns this PrerenderManager.
584 Profile* profile_;
586 PrerenderTracker* prerender_tracker_;
588 // All running prerenders. Sorted by expiry time, in ascending order.
589 ScopedVector<PrerenderData> active_prerenders_;
591 // Prerenders awaiting deletion.
592 ScopedVector<PrerenderData> to_delete_prerenders_;
594 // List of recent navigations in this profile, sorted by ascending
595 // navigate_time_.
596 std::list<NavigationRecord> navigations_;
598 scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_;
600 static PrerenderManagerMode mode_;
602 // A count of how many prerenders we do per session. Initialized to 0 then
603 // incremented and emitted to a histogram on each successful prerender.
604 static int prerenders_per_session_count_;
606 // RepeatingTimer to perform periodic cleanups of pending prerendered
607 // pages.
608 base::RepeatingTimer<PrerenderManager> repeating_timer_;
610 // Track time of last prerender to limit prerender spam.
611 base::TimeTicks last_prerender_start_time_;
613 std::list<content::WebContents*> old_web_contents_list_;
615 ScopedVector<OnCloseWebContentsDeleter> on_close_web_contents_deleters_;
617 scoped_ptr<PrerenderHistory> prerender_history_;
619 scoped_ptr<PrerenderHistograms> histograms_;
621 scoped_ptr<PrerenderLocalPredictor> local_predictor_;
623 scoped_refptr<predictors::LoggedInPredictorTable> logged_in_predictor_table_;
625 // Here, we keep the logged in predictor state, but potentially a superset
626 // of its actual (database-backed) state, since we do not incorporate
627 // browser data deletion. We do not use this for actual lookups, but only
628 // to query cookie data for domains we know there was a login before.
629 // This is required to avoid a large number of cookie lookups on bulk
630 // deletion of cookies.
631 scoped_ptr<LoggedInStateMap> logged_in_state_;
633 content::NotificationRegistrar notification_registrar_;
635 base::CancelableTaskTracker query_url_tracker_;
637 // The number of bytes transferred over the network for the profile this
638 // PrerenderManager is attached to.
639 int64 profile_network_bytes_;
641 // The value of profile_network_bytes_ that was last recorded.
642 int64 last_recorded_profile_network_bytes_;
644 // Set of process hosts being prerendered.
645 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet;
646 PrerenderProcessSet prerender_process_hosts_;
648 // Indicates whether the cookie store for this profile has fully loaded yet.
649 bool cookie_store_loaded_;
651 base::Closure on_cookie_store_loaded_cb_for_testing_;
653 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
656 } // namespace prerender
658 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_