summaryrefslogtreecommitdiffstats
path: root/content/browser/storage_partition_impl_map.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-21 02:31:18 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-21 02:31:18 +0000
commite79b1d5a6edc56613e099fcd8fb75a05f501fc71 (patch)
treea118f4edf3f2aee250af4e71ee8493bcde5629ab /content/browser/storage_partition_impl_map.cc
parent8643f2d60717c84be350040d553ea04dda4d6f21 (diff)
downloadchromium_src-e79b1d5a6edc56613e099fcd8fb75a05f501fc71.zip
chromium_src-e79b1d5a6edc56613e099fcd8fb75a05f501fc71.tar.gz
chromium_src-e79b1d5a6edc56613e099fcd8fb75a05f501fc71.tar.bz2
Create a new URLRequestJobFactory for isolated request contexts.
Also includes unittest from tzik@: http://codereview.chromium.org/10956009/ Originally the isolated URLRequestContexts used the same URLRequestJobFactory instance as the "default" request context. This breaks filesystem: because the isolated context would incorrectly dispatch to FileSystemContext of the default URLRequestContext. This CL makes it so the isolated contexts do not share the same URLRequestJobFactory. There is now one URLRequestJobFactory per StoragePartition (the code equiv of one isolated context). Note that each RequestContext and MediaRequestContext pair still share the same URLRequestJobFactory. This is safe because they are in the isolation domain. High level changes are: - Each URLRequestJobFactory needs its own protocol_handler_interceptor which requires threading the parameter through all the URLRequestContext factory mess because this particular object must be created on the UI thread. - GetIsolatedMediaRequestContext no longer looks up the app context out of the profile. Instead GetIsolatedMediaRequestContextGetter() does this. This makes it a little clearer that it is really a thin facade over the related isolated context. - The common code for URLJobFactory creation is pulled up into SetUpJobFactoryDefaults out of both off_the_record and the normal profile_impl. This will avoid future divergence of the setup. - FtpProtocolHandler also moved into SetUpJobFactoryDefaults. Again, this is just to avoid future divergence. - Lots of ownership passing moved to scoped_ptr<> to be more explicit. No functionality change here, but lots of text churn. TBR=finnur BUG=150861 Review URL: https://codereview.chromium.org/10969017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157900 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/storage_partition_impl_map.cc')
-rw-r--r--content/browser/storage_partition_impl_map.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 742242f..02bfdd6 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -144,11 +144,24 @@ void InitializeURLRequestContext(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!context_getter)
return; // tests.
+
+ // This code only modifies the URLRequestJobFactory on the context
+ // to handle blob: URLs, filesystem: URLs, and to let AppCache intercept
+ // the appropriate requests. This is in addition to the slew of other
+ // initializtion that is done in during creation of the URLRequestContext.
+ // We cannot yet centralize this code because URLRequestContext needs
+ // to be created before the StoragePartition context.
+ //
+ // TODO(ajwong): Fix the ordering so all the initialization is in one spot.
net::URLRequestContext* context = context_getter->GetURLRequestContext();
net::URLRequestJobFactory* job_factory =
const_cast<net::URLRequestJobFactory*>(context->job_factory());
+
+ // Note: if this is called twice with 2 request contexts that share one job
+ // factory (as is the case with a media request context and its related
+ // normal request context) then this will early exit.
if (job_factory->IsHandledProtocol(chrome::kBlobScheme))
- return; // Already initialized this RequestContext.
+ return; // Already initialized this JobFactory.
bool set_protocol = job_factory->SetProtocolHandler(
chrome::kBlobScheme,
@@ -253,15 +266,12 @@ void StoragePartitionImplMap::PostCreateInitialization(
make_scoped_refptr(partition->GetFileSystemContext()),
make_scoped_refptr(
ChromeBlobStorageContext::GetFor(browser_context_))));
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(
- &InitializeURLRequestContext,
- make_scoped_refptr(partition->GetMediaURLRequestContext()),
- make_scoped_refptr(partition->GetAppCacheService()),
- make_scoped_refptr(partition->GetFileSystemContext()),
- make_scoped_refptr(
- ChromeBlobStorageContext::GetFor(browser_context_))));
+
+ // We do not call InitializeURLRequestContext() for media contexts because,
+ // other than the HTTP cache, the media contexts share the same backing
+ // objects as their associated "normal" request context. Thus, the previous
+ // call serves to initialize the media request context for this storage
+ // partition as well.
}
}