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

Unified Diff: android_webview/browser/net/aw_url_request_context_getter.cc

Issue 18618004: Change BrowserThreadDelegate to run Init() async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/net/aw_url_request_context_getter.h ('k') | chrome/browser/io_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/net/aw_url_request_context_getter.cc
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index d323f4efe436757e3bd39b40517ed76a13078812..eed948f0b17e84f6ad2ebf261ac7bf9486b93985 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -54,6 +54,22 @@ AwURLRequestContextGetter::~AwURLRequestContextGetter() {
void AwURLRequestContextGetter::Init() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ cookie_store_ = content::CreatePersistentCookieStore(
+ browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cookies")),
+ true,
+ NULL,
+ NULL);
+ cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true);
+
+ // The CookieMonster must be passed here so it happens synchronously to
+ // the main thread initialization (to avoid race condition in another
+ // thread trying to access the CookieManager API).
+ DidCreateCookieMonster(cookie_store_->GetCookieMonster());
+}
+
+void AwURLRequestContextGetter::InitAsync() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
net::URLRequestContextBuilder builder;
builder.set_user_agent(content::GetUserAgent(GURL()));
builder.set_network_delegate(new AwNetworkDelegate());
@@ -84,21 +100,7 @@ void AwURLRequestContextGetter::Init() {
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
main_http_factory_.reset(main_cache);
url_request_context_->set_http_transaction_factory(main_cache);
-
- scoped_refptr<net::CookieStore> cookie_store =
- content::CreatePersistentCookieStore(
- browser_context_->GetPath().Append(FILE_PATH_LITERAL("Cookies")),
- true,
- NULL,
- NULL);
- cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
- url_request_context_->set_cookie_store(cookie_store.get());
-
- // The CookieMonster must be passed here so it happens synchronously to
- // the main thread initialization (to avoid race condition in another
- // thread trying to access the CookieManager API).
- DidCreateCookieMonster(
- url_request_context_->cookie_store()->GetCookieMonster());
+ url_request_context_->set_cookie_store(cookie_store_.get());
}
void AwURLRequestContextGetter::PopulateNetworkSessionParams(
« no previous file with comments | « android_webview/browser/net/aw_url_request_context_getter.h ('k') | chrome/browser/io_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698