| Index: chrome/browser/profiles/profile_impl_io_data.cc
|
| diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
|
| index faba3535fa634f92fc430102620364147e664686..20a055c7bde19d6aee48a63efa063cdb805147b8 100644
|
| --- a/chrome/browser/profiles/profile_impl_io_data.cc
|
| +++ b/chrome/browser/profiles/profile_impl_io_data.cc
|
| @@ -208,14 +208,16 @@ ProfileImplIOData::Handle::GetExtensionsRequestContextGetter() const {
|
|
|
| scoped_refptr<ChromeURLRequestContextGetter>
|
| ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter(
|
| - const std::string& app_id) const {
|
| + const StoragePartitionDetails& partition_details) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - CHECK(!app_id.empty());
|
| + // TODO(nasko): Enable this check, once the browser tag is properly
|
| + // isolated in its own directory.
|
| + // CHECK_NE(partition_details.path.value(), profile_->GetPath().value());
|
| LazyInitialize();
|
|
|
| - // Keep a map of request context getters, one per requested app ID.
|
| + // Keep a map of request context getters, one per requested storage partition.
|
| ChromeURLRequestContextGetterMap::iterator iter =
|
| - app_request_context_getter_map_.find(app_id);
|
| + app_request_context_getter_map_.find(partition_details);
|
| if (iter != app_request_context_getter_map_.end())
|
| return iter->second;
|
|
|
| @@ -225,34 +227,38 @@ ProfileImplIOData::Handle::GetIsolatedAppRequestContextGetter(
|
| CreateURLInterceptor());
|
| ChromeURLRequestContextGetter* context =
|
| ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
|
| - profile_, io_data_, app_id, protocol_handler_interceptor.Pass());
|
| - app_request_context_getter_map_[app_id] = context;
|
| + profile_, io_data_, partition_details,
|
| + protocol_handler_interceptor.Pass());
|
| + app_request_context_getter_map_[partition_details] = context;
|
|
|
| return context;
|
| }
|
|
|
| scoped_refptr<ChromeURLRequestContextGetter>
|
| ProfileImplIOData::Handle::GetIsolatedMediaRequestContextGetter(
|
| - const std::string& app_id) const {
|
| + const StoragePartitionDetails& partition_details) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - // We must have an app ID, or this will act like the default media context.
|
| - CHECK(!app_id.empty());
|
| + // We must have a non-default path, or this will act like the default media
|
| + // context.
|
| + // TODO(nasko): Enable this check, once the browser tag is properly
|
| + // isolated in its own directory.
|
| + // CHECK_NE(partition_details.path.value(), profile_->GetPath().value());
|
| LazyInitialize();
|
|
|
| - // Keep a map of request context getters, one per requested app ID.
|
| + // Keep a map of request context getters, one per requested storage partition.
|
| ChromeURLRequestContextGetterMap::iterator iter =
|
| - isolated_media_request_context_getter_map_.find(app_id);
|
| + isolated_media_request_context_getter_map_.find(partition_details);
|
| if (iter != isolated_media_request_context_getter_map_.end())
|
| return iter->second;
|
|
|
| // Get the app context as the starting point for the media context, so that
|
| // it uses the app's cookie store.
|
| ChromeURLRequestContextGetter* app_context =
|
| - GetIsolatedAppRequestContextGetter(app_id);
|
| + GetIsolatedAppRequestContextGetter(partition_details);
|
| ChromeURLRequestContextGetter* context =
|
| ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia(
|
| - profile_, app_context, io_data_, app_id);
|
| - isolated_media_request_context_getter_map_[app_id] = context;
|
| + profile_, app_context, io_data_, partition_details);
|
| + isolated_media_request_context_getter_map_[partition_details] = context;
|
|
|
| return context;
|
| }
|
| @@ -468,7 +474,9 @@ void ProfileImplIOData::LazyInitializeInternal(
|
|
|
| // Create a media request context based on the main context, but using a
|
| // media cache. It shares the same job factory as the main context.
|
| - media_request_context_.reset(InitializeMediaRequestContext(main_context, ""));
|
| + StoragePartitionDetails details(FilePath(), false);
|
| + media_request_context_.reset(InitializeMediaRequestContext(main_context,
|
| + details));
|
|
|
| lazy_params_.reset();
|
| }
|
| @@ -476,23 +484,15 @@ void ProfileImplIOData::LazyInitializeInternal(
|
| ChromeURLRequestContext*
|
| ProfileImplIOData::InitializeAppRequestContext(
|
| ChromeURLRequestContext* main_context,
|
| - const std::string& app_id,
|
| + const StoragePartitionDetails& partition_details,
|
| scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| protocol_handler_interceptor) const {
|
| - // If this is for a guest process, we should not persist cookies and http
|
| - // cache.
|
| - bool is_guest_process = (app_id.find("guest-") != std::string::npos);
|
| -
|
| // Copy most state from the main context.
|
| AppRequestContext* context = new AppRequestContext(load_time_stats());
|
| context->CopyFrom(main_context);
|
|
|
| - using content::StoragePartition;
|
| - FilePath app_path =
|
| - profile_path_.Append(StoragePartition::GetPartitionPath(app_id));
|
| -
|
| - FilePath cookie_path = app_path.Append(chrome::kCookieFilename);
|
| - FilePath cache_path = app_path.Append(chrome::kCacheDirname);
|
| + FilePath cookie_path = partition_details.path.Append(chrome::kCookieFilename);
|
| + FilePath cache_path = partition_details.path.Append(chrome::kCacheDirname);
|
|
|
| const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| // Only allow Record Mode if we are in a Debug build or where we are running
|
| @@ -504,7 +504,7 @@ ProfileImplIOData::InitializeAppRequestContext(
|
|
|
| // Use a separate HTTP disk cache for isolated apps.
|
| net::HttpCache::BackendFactory* app_backend = NULL;
|
| - if (is_guest_process) {
|
| + if (partition_details.in_memory) {
|
| app_backend = net::HttpCache::DefaultBackend::InMemory(0);
|
| } else {
|
| app_backend = new net::HttpCache::DefaultBackend(
|
| @@ -519,7 +519,7 @@ ProfileImplIOData::InitializeAppRequestContext(
|
| new net::HttpCache(main_network_session, app_backend);
|
|
|
| scoped_refptr<net::CookieStore> cookie_store = NULL;
|
| - if (is_guest_process) {
|
| + if (partition_details.in_memory) {
|
| cookie_store = new net::CookieMonster(NULL, NULL);
|
| } else if (record_mode || playback_mode) {
|
| // Don't use existing cookies and use an in-memory store.
|
| @@ -564,10 +564,10 @@ ProfileImplIOData::InitializeAppRequestContext(
|
| ChromeURLRequestContext*
|
| ProfileImplIOData::InitializeMediaRequestContext(
|
| ChromeURLRequestContext* original_context,
|
| - const std::string& app_id) const {
|
| - // If this is for a guest process, we do not persist storage, so we can
|
| - // simply use the app's in-memory cache (like off-the-record mode).
|
| - if (app_id.find("guest-") != std::string::npos)
|
| + const StoragePartitionDetails& partition_details) const {
|
| + // If this is for a in_memory partition, we can simply use the original
|
| + // context (like off-the-record mode).
|
| + if (partition_details.in_memory)
|
| return original_context;
|
|
|
| // Copy most state from the original context.
|
| @@ -575,16 +575,14 @@ ProfileImplIOData::InitializeMediaRequestContext(
|
| context->CopyFrom(original_context);
|
|
|
| using content::StoragePartition;
|
| - FilePath app_path =
|
| - profile_path_.Append(StoragePartition::GetPartitionPath(app_id));
|
| FilePath cache_path;
|
| int cache_max_size = app_media_cache_max_size_;
|
| - if (app_id.empty()) {
|
| + if (partition_details.path == profile_path_) {
|
| // lazy_params_ is only valid for the default media context creation.
|
| cache_path = lazy_params_->media_cache_path;
|
| cache_max_size = lazy_params_->media_cache_max_size;
|
| } else {
|
| - cache_path = app_path.Append(chrome::kMediaCacheDirname);
|
| + cache_path = partition_details.path.Append(chrome::kMediaCacheDirname);
|
| }
|
|
|
| // Use a separate HTTP disk cache for isolated apps.
|
| @@ -620,12 +618,12 @@ ProfileImplIOData::AcquireMediaRequestContext() const {
|
| ChromeURLRequestContext*
|
| ProfileImplIOData::AcquireIsolatedAppRequestContext(
|
| ChromeURLRequestContext* main_context,
|
| - const std::string& app_id,
|
| + const StoragePartitionDetails& partition_details,
|
| scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| protocol_handler_interceptor) const {
|
| // We create per-app contexts on demand, unlike the others above.
|
| ChromeURLRequestContext* app_request_context =
|
| - InitializeAppRequestContext(main_context, app_id,
|
| + InitializeAppRequestContext(main_context, partition_details,
|
| protocol_handler_interceptor.Pass());
|
| DCHECK(app_request_context);
|
| return app_request_context;
|
| @@ -634,10 +632,10 @@ ProfileImplIOData::AcquireIsolatedAppRequestContext(
|
| ChromeURLRequestContext*
|
| ProfileImplIOData::AcquireIsolatedMediaRequestContext(
|
| ChromeURLRequestContext* app_context,
|
| - const std::string& app_id) const {
|
| + const StoragePartitionDetails& partition_details) const {
|
| // We create per-app media contexts on demand, unlike the others above.
|
| ChromeURLRequestContext* media_request_context =
|
| - InitializeMediaRequestContext(app_context, app_id);
|
| + InitializeMediaRequestContext(app_context, partition_details);
|
| DCHECK(media_request_context);
|
| return media_request_context;
|
| }
|
|
|