From be180c8044f145310f9eb13fd2cab5fd20e88220 Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Fri, 23 Oct 2009 06:33:31 +0000 Subject: Move initialization of ChromeURLRequestContexts to the IO thread. Before, these URLRequestContexts were lazily created from the UI thread. Unfortunately that model made it easy for consumers on the UI thread to poke at stuff which was being used from the IO thread, and introduce races. So instead of providing a URLRequestContext*, the Profile now vends a URLRequestContextGetter*. The consequence of this is: * Consumers on the UI thread can no longer get access to a URLRequestContext. * Consumers on the IO thread need to call URLRequestContextGetter::GetURLRequestContext() to get at the context. This uses the same style lazy-creation of URLRequestContexts, albeit from the IO thread. OK, so now the smelly part: There were a couple of consumers of URLRequestContext on the UI thread that can't easily be moved to the IO thread -- these are the consumers of the cookie store. Before they could happily mess with the cookie store from the UI thread, and this was fine since CookieStore is threadsafe. However under the new model, they have no way to get at the URLRequestContext from the UI thread, hence can't get a pointer to the cookie store. To support that use-cases, I bastardized the API some by adding a URLRequestContextGetter::GetCookieStore() method that lets UI thread consumers get a pointer to the cookie store, since we know this particular cross-thread usage is safe. BUG=http://crbug.com/22294 Review URL: http://codereview.chromium.org/258008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29880 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/net/url_fetcher.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chrome/browser/net/url_fetcher.h') diff --git a/chrome/browser/net/url_fetcher.h b/chrome/browser/net/url_fetcher.h index b7aa137..d62536c 100644 --- a/chrome/browser/net/url_fetcher.h +++ b/chrome/browser/net/url_fetcher.h @@ -18,7 +18,7 @@ class GURL; typedef std::vector ResponseCookies; class URLFetcher; -class URLRequestContext; +class URLRequestContextGetter; class URLRequestStatus; namespace net { @@ -143,7 +143,7 @@ class URLFetcher { // Set the URLRequestContext on the request. Must be called before the // request is started. - void set_request_context(URLRequestContext* request_context); + void set_request_context(URLRequestContextGetter* request_context_getter); // Retrieve the response headers from the request. Must only be called after // the OnURLFetchComplete callback has run. -- cgit v1.1