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

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

Issue 509573002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/prerender/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_cookie_store.h" 5 #include "chrome/browser/prerender/prerender_cookie_store.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 12
13 namespace prerender { 13 namespace prerender {
14 14
15 PrerenderCookieStore::PrerenderCookieStore( 15 PrerenderCookieStore::PrerenderCookieStore(
16 scoped_refptr<net::CookieMonster> default_cookie_monster, 16 scoped_refptr<net::CookieMonster> default_cookie_monster,
17 const base::Closure& cookie_conflict_cb) 17 const base::Closure& cookie_conflict_cb)
18 : in_forwarding_mode_(false), 18 : in_forwarding_mode_(false),
19 default_cookie_monster_(default_cookie_monster), 19 default_cookie_monster_(default_cookie_monster),
20 changes_cookie_monster_(new net::CookieMonster(NULL, NULL)), 20 changes_cookie_monster_(new net::CookieMonster(NULL, NULL)),
21 cookie_conflict_cb_(cookie_conflict_cb), 21 cookie_conflict_cb_(cookie_conflict_cb),
22 cookie_conflict_(false) { 22 cookie_conflict_(false) {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
24 DCHECK(default_cookie_monster_ != NULL); 24 DCHECK(default_cookie_monster_.get() != NULL);
25 DCHECK(default_cookie_monster_->loaded()); 25 DCHECK(default_cookie_monster_->loaded());
26 } 26 }
27 27
28 PrerenderCookieStore::~PrerenderCookieStore() { 28 PrerenderCookieStore::~PrerenderCookieStore() {
29 } 29 }
30 30
31 void PrerenderCookieStore::SetCookieWithOptionsAsync( 31 void PrerenderCookieStore::SetCookieWithOptionsAsync(
32 const GURL& url, 32 const GURL& url,
33 const std::string& cookie_line, 33 const std::string& cookie_line,
34 const net::CookieOptions& options, 34 const net::CookieOptions& options,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 net::CookieStore* PrerenderCookieStore::GetCookieStoreForCookieOpAndLog( 113 net::CookieStore* PrerenderCookieStore::GetCookieStoreForCookieOpAndLog(
114 const CookieOperation& op) { 114 const CookieOperation& op) {
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
116 116
117 std::string key = default_cookie_monster_->GetKey(op.url.host()); 117 std::string key = default_cookie_monster_->GetKey(op.url.host());
118 bool is_read_only = (op.op == COOKIE_OP_GET_COOKIES_WITH_OPTIONS_ASYNC || 118 bool is_read_only = (op.op == COOKIE_OP_GET_COOKIES_WITH_OPTIONS_ASYNC ||
119 op.op == COOKIE_OP_GET_ALL_COOKIES_FOR_URL_ASYNC); 119 op.op == COOKIE_OP_GET_ALL_COOKIES_FOR_URL_ASYNC);
120 120
121 if (in_forwarding_mode_) 121 if (in_forwarding_mode_)
122 return default_cookie_monster_; 122 return default_cookie_monster_.get();
123 123
124 DCHECK(changes_cookie_monster_ != NULL); 124 DCHECK(changes_cookie_monster_.get() != NULL);
125 125
126 cookie_ops_.push_back(op); 126 cookie_ops_.push_back(op);
127 127
128 bool key_copied = ContainsKey(copied_keys_, key); 128 bool key_copied = ContainsKey(copied_keys_, key);
129 129
130 if (key_copied) 130 if (key_copied)
131 return changes_cookie_monster_; 131 return changes_cookie_monster_.get();
132 132
133 if (is_read_only) { 133 if (is_read_only) {
134 // Insert this key into the set of read keys, if it doesn't exist yet. 134 // Insert this key into the set of read keys, if it doesn't exist yet.
135 if (!ContainsKey(read_keys_, key)) 135 if (!ContainsKey(read_keys_, key))
136 read_keys_.insert(key); 136 read_keys_.insert(key);
137 return default_cookie_monster_; 137 return default_cookie_monster_.get();
138 } 138 }
139 139
140 // If this method hasn't returned yet, the key has not been copied yet, 140 // If this method hasn't returned yet, the key has not been copied yet,
141 // and we must copy it due to the requested write operation. 141 // and we must copy it due to the requested write operation.
142 142
143 bool copy_success = default_cookie_monster_-> 143 bool copy_success =
144 CopyCookiesForKeyToOtherCookieMonster(key, changes_cookie_monster_); 144 default_cookie_monster_->CopyCookiesForKeyToOtherCookieMonster(
145 key, changes_cookie_monster_.get());
145 146
146 // The copy must succeed. 147 // The copy must succeed.
147 DCHECK(copy_success); 148 DCHECK(copy_success);
148 149
149 copied_keys_.insert(key); 150 copied_keys_.insert(key);
150 151
151 return changes_cookie_monster_; 152 return changes_cookie_monster_.get();
152 } 153 }
153 154
154 void PrerenderCookieStore::ApplyChanges(std::vector<GURL>* cookie_change_urls) { 155 void PrerenderCookieStore::ApplyChanges(std::vector<GURL>* cookie_change_urls) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
156 157
157 if (in_forwarding_mode_) 158 if (in_forwarding_mode_)
158 return; 159 return;
159 160
160 // Apply all changes to the underlying cookie store. 161 // Apply all changes to the underlying cookie store.
161 for (std::vector<CookieOperation>::const_iterator it = cookie_ops_.begin(); 162 for (std::vector<CookieOperation>::const_iterator it = cookie_ops_.begin();
(...skipping 29 matching lines...) Expand all
191 changes_cookie_monster_ = NULL; 192 changes_cookie_monster_ = NULL;
192 } 193 }
193 194
194 void PrerenderCookieStore::OnCookieChangedForURL( 195 void PrerenderCookieStore::OnCookieChangedForURL(
195 net::CookieMonster* cookie_monster, 196 net::CookieMonster* cookie_monster,
196 const GURL& url) { 197 const GURL& url) {
197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
198 199
199 // If the cookie was changed in a different cookie monster than the one 200 // If the cookie was changed in a different cookie monster than the one
200 // being decorated, there is nothing to do). 201 // being decorated, there is nothing to do).
201 if (cookie_monster != default_cookie_monster_) 202 if (cookie_monster != default_cookie_monster_.get())
202 return; 203 return;
203 204
204 if (in_forwarding_mode_) 205 if (in_forwarding_mode_)
205 return; 206 return;
206 207
207 // If we have encountered a conflict before, it has already been recorded 208 // If we have encountered a conflict before, it has already been recorded
208 // and the cb has been issued, so nothing to do. 209 // and the cb has been issued, so nothing to do.
209 if (cookie_conflict_) 210 if (cookie_conflict_)
210 return; 211 return;
211 212
(...skipping 20 matching lines...) Expand all
232 } 233 }
233 } 234 }
234 235
235 PrerenderCookieStore::CookieOperation::CookieOperation() { 236 PrerenderCookieStore::CookieOperation::CookieOperation() {
236 } 237 }
237 238
238 PrerenderCookieStore::CookieOperation::~CookieOperation() { 239 PrerenderCookieStore::CookieOperation::~CookieOperation() {
239 } 240 }
240 241
241 } // namespace prerender 242 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698