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

Unified Diff: chrome/browser/prerender/prerender_tracker.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_tracker.h
===================================================================
--- chrome/browser/prerender/prerender_tracker.h (revision 265252)
+++ chrome/browser/prerender/prerender_tracker.h (working copy)
@@ -6,17 +6,27 @@
#define CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
#include <map>
+#include <set>
#include <utility>
+#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/synchronization/lock.h"
+#include "chrome/browser/prerender/prerender_cookie_store.h"
+#include "content/public/browser/render_process_host_observer.h"
#include "url/gurl.h"
+namespace net {
+class URLRequestContextGetter;
+}
+
namespace prerender {
class PrerenderPendingSwapThrottle;
// Global object for maintaining prerender state on the IO thread.
-class PrerenderTracker {
+class PrerenderTracker : public content::RenderProcessHostObserver {
public:
typedef std::pair<int, int> ChildRouteIdPair;
@@ -46,6 +56,31 @@
const ChildRouteIdPair& render_frame_route_id_pair,
bool swap_successful);
+ // Gets the Prerender Cookie Store for a specific render process, if it
+ // is a prerender. Only to be called from the IO thread.
+ scoped_refptr<PrerenderCookieStore> GetPrerenderCookieStoreForRenderProcess(
+ int process_id);
+
+ bool IsProcessPrerendering(content::RenderProcessHost* process_host);
+
+ // Called when a given render process has changed a cookie for |url|.
+ // Only to be called from the IO thread.
+ void OnCookieChangedForURL(int process_id, const GURL& url);
+
+ // Adds a prerender and creates a corresponding prerender cookie store.
+ // Must be called on the UI thread.
+ void AddPrerender(content::RenderProcessHost* host,
+ net::URLRequestContextGetter* request_context,
+ const base::Closure& cookie_conflict_cb);
+
+ // Called when a prerender was successfully swapped and shown.
+ // The corresponding prerender cookie store will be set to forwarding mode.
+ void OnPrerenderSwapped(content::RenderProcessHost* host);
+
+ // content::RenderProcessHostObserver implementation.
+ virtual void RenderProcessHostDestroyed(
+ content::RenderProcessHost* host) OVERRIDE;
+
private:
// Add/remove prerenders pending swap on the IO Thread.
void AddPrerenderPendingSwapOnIOThread(
@@ -54,6 +89,14 @@
const ChildRouteIdPair& render_frame_route_id_pair,
bool swap_successful);
+ void AddPrerenderCookieStoreOnIOThread(
+ int process_id,
+ scoped_refptr<net::URLRequestContextGetter> request_context,
+ const base::Closure& cookie_conflict_cb);
+
+ // Removes a prerender cookie store on the IO thread.
+ void RemovePrerenderCookieStoreOnIOThread(int process_id, bool was_swapped);
+
struct PendingSwapThrottleData {
explicit PendingSwapThrottleData(const GURL& swap_url);
~PendingSwapThrottleData();
@@ -68,6 +111,16 @@
PendingSwapThrottleMap;
PendingSwapThrottleMap pending_swap_throttle_map_;
+ // Map of prerendering render process ids to PrerenderCookieStore used for
+ // the prerender. Only to be used on the IO thread.
+ typedef base::hash_map<int, scoped_refptr<PrerenderCookieStore> >
+ PrerenderCookieStoreMap;
+ PrerenderCookieStoreMap prerender_cookie_store_map_;
+
+ // Set of process hosts being prerendered, maintained on the UI thread.
+ typedef std::set<content::RenderProcessHost*> PrerenderProcessSet;
+ PrerenderProcessSet prerender_process_hosts_;
+
DISALLOW_COPY_AND_ASSIGN(PrerenderTracker);
};

Powered by Google App Engine
This is Rietveld 408576698