diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 06:33:31 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 06:33:31 +0000 |
commit | be180c8044f145310f9eb13fd2cab5fd20e88220 (patch) | |
tree | 707ac9f3f95f5191664dbdac2ff3f34ab08ad8e7 /chrome/browser/plugin_process_host.cc | |
parent | 4cb1d3be9986c105608991f3dde12c6346335060 (diff) | |
download | chromium_src-be180c8044f145310f9eb13fd2cab5fd20e88220.zip chromium_src-be180c8044f145310f9eb13fd2cab5fd20e88220.tar.gz chromium_src-be180c8044f145310f9eb13fd2cab5fd20e88220.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/plugin_process_host.cc')
-rw-r--r-- | chrome/browser/plugin_process_host.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 35dcda3..fe4583a 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -34,6 +34,7 @@ #include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/chrome_plugin_browsing_context.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/browser/net/url_request_context_getter.h" #include "chrome/browser/net/url_request_tracking.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/profile.h" @@ -149,7 +150,8 @@ void PluginDownloadUrlHelper::InitiateDownload() { download_file_request_ = new URLRequest(GURL(download_url_), this); chrome_browser_net::SetOriginProcessUniqueIDForRequest( download_source_child_unique_id_, download_file_request_); - download_file_request_->set_context(Profile::GetDefaultRequestContext()); + download_file_request_->set_context( + Profile::GetDefaultRequestContext()->GetURLRequestContext()); download_file_request_->Start(); } @@ -563,7 +565,7 @@ void PluginProcessHost::OnGetCookies(uint32 request_context, ToURLRequestContext(request_context); // TODO(mpcomplete): remove fallback case when Gears support is prevalent. if (!context) - context = Profile::GetDefaultRequestContext(); + context = Profile::GetDefaultRequestContext()->GetURLRequestContext(); // Note: We don't have a first_party_for_cookies check because plugins bypass // third-party cookie blocking. |