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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 9810022: Remove DONTUSEME_GetCookieStore(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 #include "chrome/browser/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/io_thread.h" 12 #include "chrome/browser/io_thread.h"
14 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_io_data.h" 15 #include "chrome/browser/profiles/profile_io_data.h"
17 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_details.h" 19 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 factory_.reset(); 139 factory_.reset();
141 } 140 }
142 141
143 // Should not be NULL, unless we're trying to use the URLRequestContextGetter 142 // Should not be NULL, unless we're trying to use the URLRequestContextGetter
144 // after the Profile has already been deleted. 143 // after the Profile has already been deleted.
145 CHECK(url_request_context_.get()); 144 CHECK(url_request_context_.get());
146 145
147 return url_request_context_; 146 return url_request_context_;
148 } 147 }
149 148
150 net::CookieStore* ChromeURLRequestContextGetter::DONTUSEME_GetCookieStore() {
151 // If we are running on the IO thread this is real easy.
152 if (BrowserThread::CurrentlyOn(BrowserThread::IO))
153 return GetURLRequestContext()->cookie_store();
154
155 // If we aren't running on the IO thread, we cannot call
156 // GetURLRequestContext(). Instead we will post a task to the IO loop
157 // and wait for it to complete.
158
159 base::WaitableEvent completion(false, false);
160 net::CookieStore* result = NULL;
161
162 BrowserThread::PostTask(
163 BrowserThread::IO, FROM_HERE,
164 base::Bind(&ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper,
165 this,
166 &completion,
167 &result));
168
169 completion.Wait();
170 DCHECK(result);
171 return result;
172 }
173
174 scoped_refptr<base::MessageLoopProxy> 149 scoped_refptr<base::MessageLoopProxy>
175 ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const { 150 ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const {
176 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 151 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
177 } 152 }
178 153
179 // static 154 // static
180 ChromeURLRequestContextGetter* ChromeURLRequestContextGetter::CreateOriginal( 155 ChromeURLRequestContextGetter* ChromeURLRequestContextGetter::CreateOriginal(
181 Profile* profile, 156 Profile* profile,
182 const ProfileIOData* profile_io_data) { 157 const ProfileIOData* profile_io_data) {
183 DCHECK(!profile->IsOffTheRecord()); 158 DCHECK(!profile->IsOffTheRecord());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 GetURLRequestContext()->cookie_store()->GetCookieMonster(); 303 GetURLRequestContext()->cookie_store()->GetCookieMonster();
329 304
330 // If there is no cookie monster, this function does nothing. If 305 // If there is no cookie monster, this function does nothing. If
331 // clear_site_data is true, this is most certainly not the expected behavior. 306 // clear_site_data is true, this is most certainly not the expected behavior.
332 DCHECK(!clear_site_data || cookie_monster); 307 DCHECK(!clear_site_data || cookie_monster);
333 308
334 if (cookie_monster) 309 if (cookie_monster)
335 cookie_monster->SetClearPersistentStoreOnExit(clear_site_data); 310 cookie_monster->SetClearPersistentStoreOnExit(clear_site_data);
336 } 311 }
337 312
338 void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper(
339 base::WaitableEvent* completion,
340 net::CookieStore** result) {
341 // Note that CookieStore is refcounted, yet we do not add a reference.
342 *result = GetURLRequestContext()->cookie_store();
343 completion->Signal();
344 }
345
346 // ---------------------------------------------------------------------------- 313 // ----------------------------------------------------------------------------
347 // ChromeURLRequestContext 314 // ChromeURLRequestContext
348 // ---------------------------------------------------------------------------- 315 // ----------------------------------------------------------------------------
349 316
350 ChromeURLRequestContext::ChromeURLRequestContext() 317 ChromeURLRequestContext::ChromeURLRequestContext()
351 : is_incognito_(false) { 318 : is_incognito_(false) {
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
353 } 320 }
354 321
355 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { 322 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); 354 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language));
388 } 355 }
389 356
390 void ChromeURLRequestContext::OnDefaultCharsetChange( 357 void ChromeURLRequestContext::OnDefaultCharsetChange(
391 const std::string& default_charset) { 358 const std::string& default_charset) {
392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
393 set_referrer_charset(default_charset); 360 set_referrer_charset(default_charset);
394 set_accept_charset( 361 set_accept_charset(
395 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); 362 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset));
396 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | content/shell/shell_url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698