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

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

Issue 280403002: Only commit cookie changes in prerenders after a prerender is shown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix sync related bug 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_TRACKER_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set>
9 #include <utility> 10 #include <utility>
10 11
12 #include "base/containers/hash_tables.h"
13 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "chrome/browser/prerender/prerender_cookie_store.h"
17 #include "content/public/browser/render_process_host_observer.h"
12 #include "url/gurl.h" 18 #include "url/gurl.h"
13 19
20 namespace net {
21 class URLRequestContextGetter;
22 }
23
14 namespace prerender { 24 namespace prerender {
15 25
16 class PrerenderPendingSwapThrottle; 26 class PrerenderPendingSwapThrottle;
17 27
18 // Global object for maintaining prerender state on the IO thread. 28 // Global object for maintaining various prerender state on the IO thread.
19 class PrerenderTracker { 29 class PrerenderTracker {
20 public: 30 public:
21 typedef std::pair<int, int> ChildRouteIdPair; 31 typedef std::pair<int, int> ChildRouteIdPair;
22 32
23 PrerenderTracker(); 33 PrerenderTracker();
24 virtual ~PrerenderTracker(); 34 virtual ~PrerenderTracker();
25 35
26 // Returns whether or not a RenderFrame and URL are regarding a pending 36 // Returns whether or not a RenderFrame and URL are regarding a pending
27 // prerender swap. Can only be called on the IO thread. 37 // prerender swap. Can only be called on the IO thread.
28 bool IsPendingSwapRequestOnIOThread(int render_process_id, 38 bool IsPendingSwapRequestOnIOThread(int render_process_id,
(...skipping 10 matching lines...) Expand all
39 // Called to add throttles for a pending prerender swap. 49 // Called to add throttles for a pending prerender swap.
40 void AddPrerenderPendingSwap( 50 void AddPrerenderPendingSwap(
41 const ChildRouteIdPair& render_frame_route_id_pair, 51 const ChildRouteIdPair& render_frame_route_id_pair,
42 const GURL& url); 52 const GURL& url);
43 53
44 // Called to remove the throttles for a pending prerender swap. 54 // Called to remove the throttles for a pending prerender swap.
45 void RemovePrerenderPendingSwap( 55 void RemovePrerenderPendingSwap(
46 const ChildRouteIdPair& render_frame_route_id_pair, 56 const ChildRouteIdPair& render_frame_route_id_pair,
47 bool swap_successful); 57 bool swap_successful);
48 58
59 // Gets the Prerender Cookie Store for a specific render process, if it
60 // is a prerender. Only to be called from the IO thread.
61 scoped_refptr<PrerenderCookieStore> GetPrerenderCookieStoreForRenderProcess(
62 int process_id);
63
64 // Called when a given render process has changed a cookie for |url|,
65 // in |cookie_monster|.
66 // Only to be called from the IO thread.
67 void OnCookieChangedForURL(int process_id,
68 net::CookieMonster* cookie_monster,
69 const GURL& url);
70
71 void AddPrerenderCookieStoreOnIOThread(
72 int process_id,
73 scoped_refptr<net::URLRequestContextGetter> request_context,
74 const base::Closure& cookie_conflict_cb);
75
76 void RemovePrerenderCookieStoreOnIOThread(int process_id, bool was_swapped);
77
49 private: 78 private:
50 // Add/remove prerenders pending swap on the IO Thread. 79 // Add/remove prerenders pending swap on the IO Thread.
51 void AddPrerenderPendingSwapOnIOThread( 80 void AddPrerenderPendingSwapOnIOThread(
52 const ChildRouteIdPair& render_frame_route_id_pair, const GURL& url); 81 const ChildRouteIdPair& render_frame_route_id_pair, const GURL& url);
53 void RemovePrerenderPendingSwapOnIOThread( 82 void RemovePrerenderPendingSwapOnIOThread(
54 const ChildRouteIdPair& render_frame_route_id_pair, 83 const ChildRouteIdPair& render_frame_route_id_pair,
55 bool swap_successful); 84 bool swap_successful);
56 85
57 struct PendingSwapThrottleData { 86 struct PendingSwapThrottleData {
58 explicit PendingSwapThrottleData(const GURL& swap_url); 87 explicit PendingSwapThrottleData(const GURL& swap_url);
59 ~PendingSwapThrottleData(); 88 ~PendingSwapThrottleData();
60 GURL url; 89 GURL url;
61 base::WeakPtr<PrerenderPendingSwapThrottle> throttle; 90 base::WeakPtr<PrerenderPendingSwapThrottle> throttle;
62 }; 91 };
63 92
64 // Map of pending prerender swaps and their associated throttles, 93 // Map of pending prerender swaps and their associated throttles,
65 // maintained on the IO thread. The key is the routing ID pair 94 // maintained on the IO thread. The key is the routing ID pair
66 // of a RenderFrame. 95 // of a RenderFrame.
67 typedef std::map<ChildRouteIdPair, PendingSwapThrottleData> 96 typedef std::map<ChildRouteIdPair, PendingSwapThrottleData>
68 PendingSwapThrottleMap; 97 PendingSwapThrottleMap;
69 PendingSwapThrottleMap pending_swap_throttle_map_; 98 PendingSwapThrottleMap pending_swap_throttle_map_;
70 99
100 // Map of prerendering render process ids to PrerenderCookieStore used for
101 // the prerender. Only to be used on the IO thread.
102 typedef base::hash_map<int, scoped_refptr<PrerenderCookieStore> >
103 PrerenderCookieStoreMap;
104 PrerenderCookieStoreMap prerender_cookie_store_map_;
105
71 DISALLOW_COPY_AND_ASSIGN(PrerenderTracker); 106 DISALLOW_COPY_AND_ASSIGN(PrerenderTracker);
72 }; 107 };
73 108
74 } // namespace prerender 109 } // namespace prerender
75 110
76 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_ 111 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | chrome/browser/prerender/prerender_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698