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

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

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

Powered by Google App Engine
This is Rietveld 408576698