Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/prerender/prerender_manager.h

Issue 233353003: Only commit cookie changes in prerenders after a prerender is shown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add browser tests, fix a bug in what was changed yesterday. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 // MediaCaptureDevicesDispatcher::Observer 289 // MediaCaptureDevicesDispatcher::Observer
290 virtual void OnCreatingAudioStream(int render_process_id, 290 virtual void OnCreatingAudioStream(int render_process_id,
291 int render_frame_id) OVERRIDE; 291 int render_frame_id) OVERRIDE;
292 292
293 const Config& config() const { return config_; } 293 const Config& config() const { return config_; }
294 Config& mutable_config() { return config_; } 294 Config& mutable_config() { return config_; }
295 295
296 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } 296 PrerenderTracker* prerender_tracker() { return prerender_tracker_; }
297 297
298 bool cookie_store_loaded() { return cookie_store_loaded_; }
299
298 // Adds a condition. This is owned by the PrerenderManager. 300 // Adds a condition. This is owned by the PrerenderManager.
299 void AddCondition(const PrerenderCondition* condition); 301 void AddCondition(const PrerenderCondition* condition);
300 302
301 // Records that some visible tab navigated (or was redirected) to the 303 // Records that some visible tab navigated (or was redirected) to the
302 // provided URL. 304 // provided URL.
303 void RecordNavigation(const GURL& url); 305 void RecordNavigation(const GURL& url);
304 306
305 // Updates the LoggedInPredictor state to reflect that a login has likely 307 // Updates the LoggedInPredictor state to reflect that a login has likely
306 // on the URL provided. 308 // on the URL provided.
307 void RecordLikelyLoginOnURL(const GURL& url); 309 void RecordLikelyLoginOnURL(const GURL& url);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 static void HangSessionStorageMergesForTesting(); 355 static void HangSessionStorageMergesForTesting();
354 356
355 // Notification that a prerender has completed and its bytes should be 357 // Notification that a prerender has completed and its bytes should be
356 // recorded. 358 // recorded.
357 void RecordNetworkBytes(bool used, int64 prerender_bytes); 359 void RecordNetworkBytes(bool used, int64 prerender_bytes);
358 360
359 // Add to the running tally of bytes transferred over the network for this 361 // Add to the running tally of bytes transferred over the network for this
360 // profile if prerendering is currently enabled. 362 // profile if prerendering is currently enabled.
361 void AddProfileNetworkBytesIfEnabled(int64 bytes); 363 void AddProfileNetworkBytesIfEnabled(int64 bytes);
362 364
365 // To be called once the cookie store for this profile has been loaded.
366 void OnCookieStoreLoaded();
367
368 // For testing purposes. Issues a callback once the cookie store has been
369 // loaded.
370 void set_on_cookie_store_loaded_cb(base::Closure cb) {
Charlie Reis 2014/05/07 17:21:32 I think we typically include "_for_testing" in the
tburkard 2014/05/07 18:34:27 Done.
371 on_cookie_store_loaded_cb_ = cb;
372 }
373
363 protected: 374 protected:
364 class PendingSwap; 375 class PendingSwap;
365 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { 376 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> {
366 public: 377 public:
367 struct OrderByExpiryTime; 378 struct OrderByExpiryTime;
368 379
369 PrerenderData(PrerenderManager* manager, 380 PrerenderData(PrerenderManager* manager,
370 PrerenderContents* contents, 381 PrerenderContents* contents,
371 base::TimeTicks expiry_time); 382 base::TimeTicks expiry_time);
372 383
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 void SetPrerenderContentsFactory( 515 void SetPrerenderContentsFactory(
505 PrerenderContents::Factory* prerender_contents_factory); 516 PrerenderContents::Factory* prerender_contents_factory);
506 517
507 // Called by a PrerenderData to signal that the launcher has navigated away 518 // Called by a PrerenderData to signal that the launcher has navigated away
508 // from the context that launched the prerender. A user may have clicked 519 // from the context that launched the prerender. A user may have clicked
509 // a link in a page containing a <link rel=prerender> element, or the user 520 // a link in a page containing a <link rel=prerender> element, or the user
510 // might have committed an omnibox navigation. This is used to possibly 521 // might have committed an omnibox navigation. This is used to possibly
511 // shorten the TTL of the prerendered page. 522 // shorten the TTL of the prerendered page.
512 void SourceNavigatedAway(PrerenderData* prerender_data); 523 void SourceNavigatedAway(PrerenderData* prerender_data);
513 524
525 // Gets the request context for the profile.
526 // For unit tests, this will be overriden to return NULL, since it is not
527 // needed.
528 virtual net::URLRequestContextGetter* GetURLRequestContext();
529
514 private: 530 private:
515 friend class ::InstantSearchPrerendererTest; 531 friend class ::InstantSearchPrerendererTest;
516 friend class PrerenderBrowserTest; 532 friend class PrerenderBrowserTest;
517 friend class PrerenderContents; 533 friend class PrerenderContents;
518 friend class PrerenderHandle; 534 friend class PrerenderHandle;
519 friend class UnitTestPrerenderManager; 535 friend class UnitTestPrerenderManager;
520 536
521 class OnCloseWebContentsDeleter; 537 class OnCloseWebContentsDeleter;
522 struct NavigationRecord; 538 struct NavigationRecord;
523 539
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 729
714 CancelableRequestConsumer query_url_consumer_; 730 CancelableRequestConsumer query_url_consumer_;
715 731
716 // The number of bytes transferred over the network for the profile this 732 // The number of bytes transferred over the network for the profile this
717 // PrerenderManager is attached to. 733 // PrerenderManager is attached to.
718 int64 profile_network_bytes_; 734 int64 profile_network_bytes_;
719 735
720 // The value of profile_network_bytes_ that was last recorded. 736 // The value of profile_network_bytes_ that was last recorded.
721 int64 last_recorded_profile_network_bytes_; 737 int64 last_recorded_profile_network_bytes_;
722 738
739 // Indicates whether the cookie store for this profile has fully loaded yet.
740 bool cookie_store_loaded_;
741
742 base::Closure on_cookie_store_loaded_cb_;
743
723 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 744 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
724 }; 745 };
725 746
726 } // namespace prerender 747 } // namespace prerender
727 748
728 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 749 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698