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

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

Issue 797443002: Remove prerender sessionStorage namespace merging (1/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 #include "chrome/browser/prerender/prerender_tracker.h" 5 #include "chrome/browser/prerender/prerender_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h"
10 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
12 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
13 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
14 13
15 using content::BrowserThread; 14 using content::BrowserThread;
16 15
17 namespace prerender { 16 namespace prerender {
18 17
19 PrerenderTracker::PrerenderTracker() { 18 PrerenderTracker::PrerenderTracker() {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
21 } 20 }
22 21
23 PrerenderTracker::~PrerenderTracker() { 22 PrerenderTracker::~PrerenderTracker() {
24 } 23 }
25 24
26 bool PrerenderTracker::IsPendingSwapRequestOnIOThread(
27 int render_process_id, int render_frame_id, const GURL& url) const {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
29
30 ChildRouteIdPair render_frame_route_id_pair(
31 render_process_id, render_frame_id);
32 PendingSwapThrottleMap::const_iterator it =
33 pending_swap_throttle_map_.find(render_frame_route_id_pair);
34 return (it != pending_swap_throttle_map_.end() && it->second.url == url);
35 }
36
37 void PrerenderTracker::AddPendingSwapThrottleOnIOThread(
38 int render_process_id,
39 int render_frame_id,
40 const GURL& url,
41 const base::WeakPtr<PrerenderPendingSwapThrottle>& throttle) {
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
43
44 ChildRouteIdPair render_frame_route_id_pair(
45 render_process_id, render_frame_id);
46 PendingSwapThrottleMap::iterator it =
47 pending_swap_throttle_map_.find(render_frame_route_id_pair);
48 DCHECK(it != pending_swap_throttle_map_.end());
49 if (it == pending_swap_throttle_map_.end())
50 return;
51 CHECK(!it->second.throttle);
52 it->second.throttle = throttle;
53 }
54
55 void PrerenderTracker::AddPrerenderPendingSwapOnIOThread(
56 const ChildRouteIdPair& render_frame_route_id_pair,
57 const GURL& url) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
59 std::pair<PendingSwapThrottleMap::iterator, bool> insert_result =
60 pending_swap_throttle_map_.insert(std::make_pair(
61 render_frame_route_id_pair, PendingSwapThrottleData(url)));
62 DCHECK(insert_result.second);
63 }
64
65 void PrerenderTracker::RemovePrerenderPendingSwapOnIOThread(
66 const ChildRouteIdPair& render_frame_route_id_pair,
67 bool swap_successful) {
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
69 PendingSwapThrottleMap::iterator it =
70 pending_swap_throttle_map_.find(render_frame_route_id_pair);
71 DCHECK(it != pending_swap_throttle_map_.end());
72 // Cancel or resume all throttled resources.
73 if (it->second.throttle) {
74 if (swap_successful)
75 it->second.throttle->Cancel();
76 else
77 it->second.throttle->Resume();
78 }
79 pending_swap_throttle_map_.erase(render_frame_route_id_pair);
80 }
81
82 void PrerenderTracker::AddPrerenderPendingSwap(
83 const ChildRouteIdPair& render_frame_route_id_pair,
84 const GURL& url) {
85 BrowserThread::PostTask(
86 BrowserThread::IO, FROM_HERE,
87 base::Bind(&PrerenderTracker::AddPrerenderPendingSwapOnIOThread,
88 base::Unretained(this), render_frame_route_id_pair, url));
89 }
90
91 void PrerenderTracker::RemovePrerenderPendingSwap(
92 const ChildRouteIdPair& render_frame_route_id_pair,
93 bool swap_successful) {
94 BrowserThread::PostTask(
95 BrowserThread::IO, FROM_HERE,
96 base::Bind(&PrerenderTracker::RemovePrerenderPendingSwapOnIOThread,
97 base::Unretained(this), render_frame_route_id_pair,
98 swap_successful));
99 }
100
101 PrerenderTracker::PendingSwapThrottleData::PendingSwapThrottleData(
102 const GURL& swap_url)
103 : url(swap_url) {
104 }
105
106 PrerenderTracker::PendingSwapThrottleData::~PendingSwapThrottleData() {
107 }
108
109 scoped_refptr<PrerenderCookieStore> 25 scoped_refptr<PrerenderCookieStore>
110 PrerenderTracker::GetPrerenderCookieStoreForRenderProcess( 26 PrerenderTracker::GetPrerenderCookieStoreForRenderProcess(
111 int process_id) { 27 int process_id) {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
113 PrerenderCookieStoreMap::const_iterator it = 29 PrerenderCookieStoreMap::const_iterator it =
114 prerender_cookie_store_map_.find(process_id); 30 prerender_cookie_store_map_.find(process_id);
115 31
116 if (it == prerender_cookie_store_map_.end()) 32 if (it == prerender_cookie_store_map_.end())
117 return NULL; 33 return NULL;
118 34
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 prerender_cookie_store_map_.end()); 100 prerender_cookie_store_map_.end());
185 DCHECK(!exists); 101 DCHECK(!exists);
186 if (exists) 102 if (exists)
187 return; 103 return;
188 prerender_cookie_store_map_[process_id] = 104 prerender_cookie_store_map_[process_id] =
189 new PrerenderCookieStore(make_scoped_refptr(cookie_monster), 105 new PrerenderCookieStore(make_scoped_refptr(cookie_monster),
190 cookie_conflict_cb); 106 cookie_conflict_cb);
191 } 107 }
192 108
193 } // namespace prerender 109 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698