diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 03:04:09 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 03:04:09 +0000 |
commit | 10eb2816fd7d28974114910aa5bfc105366a187f (patch) | |
tree | 7584d8faaa940e6ce8bb08320004ff402160b60e | |
parent | f37a6bc327a34487e61beab79c3ec06390a42320 (diff) | |
download | chromium_src-10eb2816fd7d28974114910aa5bfc105366a187f.zip chromium_src-10eb2816fd7d28974114910aa5bfc105366a187f.tar.gz chromium_src-10eb2816fd7d28974114910aa5bfc105366a187f.tar.bz2 |
continuing from http://http://codereview.chromium.org/10823241
This intentionally doesn't change the ChromeOS behavior at all. They all still use the default FileSystemContext.
This code also exposes the normal and media URLRequestGetters via the StoragePartition, and cleans up a bit of code that was accessing the URLRequestGetter in odd ways. Also, it makes Workers correctly use the Media Cache for Media fetches.
TBR=benjhyden,sky,davemoore,piman,mkwst,kalman
BUG=85121
Review URL: https://chromiumcodereview.appspot.com/10909182
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157284 0039d316-1c4b-4281-b951-d872f2087c98
42 files changed, 491 insertions, 315 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_file_system_helper.cc b/chrome/browser/browsing_data/browsing_data_file_system_helper.cc index c1bd432..568af77 100644 --- a/chrome/browser/browsing_data/browsing_data_file_system_helper.cc +++ b/chrome/browser/browsing_data/browsing_data_file_system_helper.cc @@ -12,25 +12,28 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browsing_data/browsing_data_helper.h" -#include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_thread.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" -using content::BrowserContext; using content::BrowserThread; +namespace fileapi { +class FileSystemContext; +} + namespace { // An implementation of the BrowsingDataFileSystemHelper interface that pulls -// data from a given |profile| and returns a list of FileSystemInfo items to a -// client. +// data from a given |filesystem_context| and returns a list of FileSystemInfo +// items to a client. class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { public: // BrowsingDataFileSystemHelper implementation - explicit BrowsingDataFileSystemHelperImpl(Profile* profile); + explicit BrowsingDataFileSystemHelperImpl( + fileapi::FileSystemContext* filesystem_context); virtual void StartFetching(const base::Callback< void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE; @@ -77,8 +80,8 @@ class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { }; BrowsingDataFileSystemHelperImpl::BrowsingDataFileSystemHelperImpl( - Profile* profile) - : filesystem_context_(BrowserContext::GetFileSystemContext(profile)), + fileapi::FileSystemContext* filesystem_context) + : filesystem_context_(filesystem_context), is_fetching_(false) { DCHECK(filesystem_context_); } @@ -184,8 +187,8 @@ BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} // static BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create( - Profile* profile) { - return new BrowsingDataFileSystemHelperImpl(profile); + fileapi::FileSystemContext* filesystem_context) { + return new BrowsingDataFileSystemHelperImpl(filesystem_context); } CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper( diff --git a/chrome/browser/browsing_data/browsing_data_file_system_helper.h b/chrome/browser/browsing_data/browsing_data_file_system_helper.h index 89d685c..8029a36 100644 --- a/chrome/browser/browsing_data/browsing_data_file_system_helper.h +++ b/chrome/browser/browsing_data/browsing_data_file_system_helper.h @@ -18,6 +18,10 @@ #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_types.h" +namespace fileapi { +class FileSystemContext; +} + class Profile; // Defines an interface for classes that deal with aggregating and deleting @@ -70,7 +74,8 @@ class BrowsingDataFileSystemHelper // // The BrowsingDataFileSystemHelper will not change the profile itself, but // can modify data it contains (by removing file systems). - static BrowsingDataFileSystemHelper* Create(Profile* profile); + static BrowsingDataFileSystemHelper* Create( + fileapi::FileSystemContext* file_system_context); // Starts the process of fetching file system data, which will call |callback| // upon completion, passing it a constant list of FileSystemInfo objects. diff --git a/chrome/browser/browsing_data/browsing_data_file_system_helper_unittest.cc b/chrome/browser/browsing_data/browsing_data_file_system_helper_unittest.cc index d60e8f2..f12551d 100644 --- a/chrome/browser/browsing_data/browsing_data_file_system_helper_unittest.cc +++ b/chrome/browser/browsing_data/browsing_data_file_system_helper_unittest.cc @@ -12,6 +12,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" #include "chrome/test/base/testing_profile.h" +#include "content/public/browser/storage_partition.h" #include "content/public/test/test_browser_thread.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_types.h" @@ -69,7 +70,10 @@ class BrowsingDataFileSystemHelperTest : public testing::Test { BrowserThread::FILE_USER_BLOCKING, &message_loop_), io_thread_(BrowserThread::IO, &message_loop_) { profile_.reset(new TestingProfile()); - helper_ = BrowsingDataFileSystemHelper::Create(profile_.get()); + + helper_ = BrowsingDataFileSystemHelper::Create( + BrowserContext::GetDefaultStoragePartition(profile_.get())-> + GetFileSystemContext()); message_loop_.RunAllPending(); canned_helper_ = new CannedBrowsingDataFileSystemHelper(profile_.get()); } @@ -148,8 +152,8 @@ class BrowsingDataFileSystemHelperTest : public testing::Test { // Sets up kOrigin1 with a temporary file system, kOrigin2 with a persistent // file system, and kOrigin3 with both. virtual void PopulateTestFileSystemData() { - sandbox_ = BrowserContext::GetFileSystemContext(profile_.get())-> - sandbox_provider(); + sandbox_ = BrowserContext::GetDefaultStoragePartition(profile_.get())-> + GetFileSystemContext()->sandbox_provider(); CreateDirectoryForOriginAndType(kOrigin1, kTemporary); CreateDirectoryForOriginAndType(kOrigin2, kPersistent); diff --git a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc index eaded3e..08ceef8 100644 --- a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc +++ b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc @@ -25,8 +25,10 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/storage_partition.h" #include "content/public/test/test_utils.h" #include "testing/gmock/include/gmock/gmock.h" #include "webkit/fileapi/file_system_context.h" @@ -165,8 +167,8 @@ class FileSystemExtensionApiTest : public ExtensionApiTest { // Adds a local mount point at at mount point /tmp. void AddTmpMountPoint() { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(browser()->profile())-> - external_provider(); + BrowserContext::GetDefaultStoragePartition( + browser()->profile())->GetFileSystemContext()->external_provider(); provider->AddLocalMountPoint(test_mount_point_); } diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc index 9d6b92c..9814bb6 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api.cc @@ -54,6 +54,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/storage_partition.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" @@ -335,11 +336,13 @@ void FileHandlerSelectFileFunction::OnFilePathSelected( // We have to open file system in order to create a FileEntry object for the // selected file path. - BrowserContext::GetFileSystemContext(profile_)->OpenFileSystem( - source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, - base::Bind(&RunOpenFileSystemCallback, - base::Bind(&FileHandlerSelectFileFunction::OnFileSystemOpened, - this))); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext()->OpenFileSystem( + source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, + base::Bind( + &RunOpenFileSystemCallback, + base::Bind(&FileHandlerSelectFileFunction::OnFileSystemOpened, + this))); }; void FileHandlerSelectFileFunction::OnFileSystemOpened( @@ -362,7 +365,8 @@ void FileHandlerSelectFileFunction::OnFileSystemOpened( void FileHandlerSelectFileFunction::GrantPermissions() { fileapi::ExternalFileSystemMountPointProvider* external_provider = - BrowserContext::GetFileSystemContext(profile_)->external_provider(); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext()->external_provider(); DCHECK(external_provider); external_provider->GetVirtualPath(full_path_, &virtual_path_); diff --git a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc index fb62f68..5ffca6c 100644 --- a/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc +++ b/chrome/browser/chromeos/extensions/file_browser_handler_api_test.cc @@ -18,6 +18,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/storage_partition.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" @@ -171,8 +173,8 @@ class FileBrowserHandlerExtensionTest : public ExtensionApiTest { // Creates new, test mount point. void AddTmpMountPoint() { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(browser()->profile())-> - external_provider(); + BrowserContext::GetDefaultStoragePartition(browser()->profile())-> + GetFileSystemContext()->external_provider(); provider->AddLocalMountPoint(tmp_mount_point_); } diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index a9bb688..078cd52 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -49,6 +49,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/storage_partition.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" #include "grit/platform_locale_settings.h" @@ -175,7 +176,8 @@ void AddDriveMountPoint( const std::string& extension_id, content::RenderViewHost* render_view_host) { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(profile)->external_provider(); + BrowserContext::GetDefaultStoragePartition(profile)-> + GetFileSystemContext()->external_provider(); if (!provider) return; @@ -453,7 +455,8 @@ bool RequestLocalFileSystemFunction::RunImpl() { return false; scoped_refptr<fileapi::FileSystemContext> file_system_context = - BrowserContext::GetFileSystemContext(profile_); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext(); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind( @@ -515,7 +518,8 @@ bool FileWatchBrowserFunctionBase::RunImpl() { GURL file_watch_url(url); scoped_refptr<fileapi::FileSystemContext> file_system_context = - BrowserContext::GetFileSystemContext(profile_); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext(); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind( @@ -971,7 +975,8 @@ void FileBrowserFunction::GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( const UrlList& file_urls, GetLocalPathsCallback callback) { scoped_refptr<fileapi::FileSystemContext> file_system_context = - BrowserContext::GetFileSystemContext(profile_); + BrowserContext::GetDefaultStoragePartition(profile())-> + GetFileSystemContext(); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind( @@ -2503,9 +2508,10 @@ bool SearchDriveFunction::RunImpl() { if (!args_->GetString(1, &next_feed_)) return false; - BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( - source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, - base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); + BrowserContext::GetDefaultStoragePartition(profile())-> + GetFileSystemContext()->OpenFileSystem( + source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, + base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); return true; } diff --git a/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc b/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc index 8fdab44..ad5fe65 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_apitest.cc @@ -10,7 +10,9 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/ui_test_utils.h" #include "chromeos/disks/mock_disk_mount_manager.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/storage_partition.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" @@ -186,8 +188,8 @@ class ExtensionFileBrowserPrivateApiTest : public ExtensionApiTest { void AddTmpMountPoint() { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(browser()->profile())-> - external_provider(); + BrowserContext::GetDefaultStoragePartition(browser()->profile())-> + GetFileSystemContext()->external_provider(); provider->AddLocalMountPoint(test_mount_point_); } diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc index d26447d..afe5614 100644 --- a/chrome/browser/chromeos/extensions/file_handler_util.cc +++ b/chrome/browser/chromeos/extensions/file_handler_util.cc @@ -32,6 +32,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/site_instance.h" +#include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "net/base/escape.h" #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" @@ -752,9 +753,10 @@ bool ExtensionTaskExecutor::ExecuteAndNotify( done_ = done; - // Get local file system instance on file thread. scoped_refptr<fileapi::FileSystemContext> file_system_context = - BrowserContext::GetFileSystemContext(profile()); + BrowserContext::GetDefaultStoragePartition(profile())-> + GetFileSystemContext(); + BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind( diff --git a/chrome/browser/chromeos/extensions/file_manager_util.cc b/chrome/browser/chromeos/extensions/file_manager_util.cc index f765324..2191f0a 100644 --- a/chrome/browser/chromeos/extensions/file_manager_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager_util.cc @@ -41,6 +41,7 @@ #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/plugin_service.h" +#include "content/public/browser/storage_partition.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" @@ -304,7 +305,8 @@ bool ConvertFileToFileSystemUrl( bool ConvertFileToRelativeFileSystemPath( Profile* profile, const FilePath& full_file_path, FilePath* virtual_path) { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(profile)->external_provider(); + BrowserContext::GetDefaultStoragePartition(profile)-> + GetFileSystemContext()->external_provider(); if (!provider) return false; @@ -587,7 +589,8 @@ bool ExecuteDefaultHandler(Profile* profile, const FilePath& path) { // If File Browser has not been open yet then it did not request access // to the file system. Do it now. fileapi::ExternalFileSystemMountPointProvider* external_provider = - BrowserContext::GetFileSystemContext(profile)->external_provider(); + BrowserContext::GetDefaultStoragePartition( + profile)->GetFileSystemContext()->external_provider(); if (!external_provider) return false; external_provider->GrantFullAccessToExtension(source_url.host()); diff --git a/chrome/browser/chromeos/gdata/drive_system_service.cc b/chrome/browser/chromeos/gdata/drive_system_service.cc index d1688e5..99c8f30 100644 --- a/chrome/browser/chromeos/gdata/drive_system_service.cc +++ b/chrome/browser/chromeos/gdata/drive_system_service.cc @@ -24,6 +24,7 @@ #include "chrome/browser/profiles/profile_dependency_manager.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/storage_partition.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" @@ -140,7 +141,8 @@ void DriveSystemService::AddDriveMountPoint() { const FilePath mount_point = gdata::util::GetDriveMountPointPath(); fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(profile_)->external_provider(); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext()->external_provider(); if (provider && !provider->HasMountPoint(mount_point)) { provider->AddRemoteMountPoint( mount_point, @@ -156,7 +158,8 @@ void DriveSystemService::RemoveDriveMountPoint() { const FilePath mount_point = gdata::util::GetDriveMountPointPath(); fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(profile_)->external_provider(); + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext()->external_provider(); if (provider && provider->HasMountPoint(mount_point)) provider->RemoveMountPoint(mount_point); } diff --git a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc index bad27f0..aee109d 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api_unittest.cc @@ -35,6 +35,7 @@ #include "content/public/browser/download_manager.h" #include "content/public/browser/download_persistent_store_info.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" #include "content/public/test/download_test_observer.h" @@ -680,7 +681,8 @@ class HTML5FileWriter { events_listener_(events_listener), blob_data_(new webkit_blob::BlobData()), payload_(payload), - fs_(BrowserContext::GetFileSystemContext(profile_)) { + fs_(BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext()) { CHECK(profile_); CHECK(events_listener_); CHECK(fs_); diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc index 9ce58a8..07cc87a 100644 --- a/chrome/browser/extensions/data_deleter.cc +++ b/chrome/browser/extensions/data_deleter.cc @@ -93,15 +93,14 @@ DataDeleter::DataDeleter( extension_request_context_ = profile->GetRequestContextForExtensions(); } else if (is_storage_isolated) { extension_request_context_ = - profile->GetRequestContextForIsolatedApp(extension_id); + profile->GetRequestContextForStoragePartition(extension_id); isolated_app_path_ = profile->GetPath().Append( content::StoragePartition::GetPartitionPath(extension_id)); } else { extension_request_context_ = profile->GetRequestContext(); } - - file_system_context_ = BrowserContext::GetFileSystemContext(profile); + file_system_context_ = storage_partition->GetFileSystemContext(); indexed_db_context_ = storage_partition->GetIndexedDBContext(); storage_origin_ = storage_origin; diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 8cbd725..96b9ad2 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -121,6 +121,7 @@ #include "chrome/browser/chromeos/extensions/media_player_event_router.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" +#include "content/public/browser/storage_partition.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" #endif @@ -1107,10 +1108,12 @@ void ExtensionService::NotifyExtensionUnloaded( profile_, extension->GetChromeURLOverrides()); #if defined(OS_CHROMEOS) - // Revoke external file access to - if (BrowserContext::GetFileSystemContext(profile_) && - BrowserContext::GetFileSystemContext(profile_)->external_provider()) { - BrowserContext::GetFileSystemContext(profile_)->external_provider()-> + // Revoke external file access to third party extensions. + fileapi::FileSystemContext* filesystem_context = + BrowserContext::GetDefaultStoragePartition(profile_)-> + GetFileSystemContext(); + if (filesystem_context && filesystem_context->external_provider()) { + filesystem_context->external_provider()-> RevokeAccessForExtension(extension->id()); } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index ca279e0..722a17a 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -252,7 +252,7 @@ net::URLRequestContextGetter* const extensions::Extension* installed_app = GetExtensionService()-> GetInstalledAppForRenderer(renderer_child_id); if (installed_app != NULL && installed_app->is_storage_isolated()) { - return GetRequestContextForIsolatedApp(installed_app->id()); + return GetRequestContextForStoragePartition(installed_app->id()); } } @@ -265,7 +265,7 @@ net::URLRequestContextGetter* // non-persistent context using the RPH's id. std::string id("guest-"); id.append(base::IntToString(renderer_child_id)); - return GetRequestContextForIsolatedApp(id); + return GetRequestContextForStoragePartition(id); } return GetRequestContext(); @@ -285,14 +285,20 @@ net::URLRequestContextGetter* } net::URLRequestContextGetter* +OffTheRecordProfileImpl::GetMediaRequestContextForStoragePartition( + const std::string& partition_id) { + return GetRequestContextForStoragePartition(partition_id); +} + +net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContextForExtensions() { return io_data_.GetExtensionsRequestContextGetter(); } net::URLRequestContextGetter* - OffTheRecordProfileImpl::GetRequestContextForIsolatedApp( - const std::string& app_id) { - return io_data_.GetIsolatedAppRequestContextGetter(app_id); + OffTheRecordProfileImpl::GetRequestContextForStoragePartition( + const std::string& partition_id) { + return io_data_.GetIsolatedAppRequestContextGetter(partition_id); } content::ResourceContext* OffTheRecordProfileImpl::GetResourceContext() { diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index 0ec4628..be2278c 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -52,8 +52,8 @@ class OffTheRecordProfileImpl : public Profile, virtual PrefService* GetOffTheRecordPrefs() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForExtensions() OVERRIDE; - virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( - const std::string& app_id) OVERRIDE; + virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; @@ -93,6 +93,9 @@ class OffTheRecordProfileImpl : public Profile, virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index a0ec37c..69d59ad 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -117,11 +117,6 @@ bool Profile::IsGuestSession() { #endif } -net::URLRequestContextGetter* Profile::GetRequestContextForStoragePartition( - const std::string& partition_id) { - return GetRequestContextForIsolatedApp(partition_id); -} - bool Profile::IsSyncAccessible() { browser_sync::SyncPrefs prefs(GetPrefs()); return ProfileSyncService::IsSyncEnabled() && !prefs.IsManaged(); diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index d41bd32..3e3688d 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -237,17 +237,13 @@ class Profile : public content::BrowserContext { // Returns the main request context. virtual net::URLRequestContextGetter* GetRequestContext() = 0; - virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( - const std::string& partition_id) OVERRIDE; - // Returns the request context used for extension-related requests. This // is only used for a separate cookie store currently. virtual net::URLRequestContextGetter* GetRequestContextForExtensions() = 0; - // Returns the request context used within an installed app that has - // requested isolated storage. - virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( - const std::string& app_id) = 0; + // Returns the request context used within |partition_id|. + virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( + const std::string& partition_id) = 0; // Returns the SSLConfigService for this profile. virtual net::SSLConfigService* GetSSLConfigService() = 0; diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 809ade67..9fc6403 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -680,7 +680,7 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( const extensions::Extension* installed_app = extension_service-> GetInstalledAppForRenderer(renderer_child_id); if (installed_app && installed_app->is_storage_isolated()) - return GetRequestContextForIsolatedApp(installed_app->id()); + return GetRequestContextForStoragePartition(installed_app->id()); } content::RenderProcessHost* rph = content::RenderProcessHost::FromID( @@ -692,7 +692,7 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContextForRenderProcess( // non-persistent context using the RPH's id. std::string id("guest-"); id.append(base::IntToString(renderer_child_id)); - return GetRequestContextForIsolatedApp(id); + return GetRequestContextForStoragePartition(id); } return GetRequestContext(); @@ -730,6 +730,12 @@ ProfileImpl::GetMediaRequestContextForRenderProcess( return io_data_.GetMediaRequestContextGetter(); } +net::URLRequestContextGetter* +ProfileImpl::GetMediaRequestContextForStoragePartition( + const std::string& partition_id) { + return io_data_.GetIsolatedMediaRequestContextGetter(partition_id); +} + content::ResourceContext* ProfileImpl::GetResourceContext() { return io_data_.GetResourceContext(); } @@ -738,9 +744,9 @@ net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { return io_data_.GetExtensionsRequestContextGetter(); } -net::URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp( - const std::string& app_id) { - return io_data_.GetIsolatedAppRequestContextGetter(app_id); +net::URLRequestContextGetter* ProfileImpl::GetRequestContextForStoragePartition( + const std::string& partition_id) { + return io_data_.GetIsolatedAppRequestContextGetter(partition_id); } net::SSLConfigService* ProfileImpl::GetSSLConfigService() { diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 925e863..b714d39 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -57,9 +57,14 @@ class ProfileImpl : public Profile, virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; @@ -91,8 +96,6 @@ class ProfileImpl : public Profile, virtual PrefService* GetOffTheRecordPrefs() OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForExtensions() OVERRIDE; - virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( - const std::string& app_id) OVERRIDE; virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; diff --git a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc index f0c94f7..f47e926 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension_browsertest.cc @@ -19,9 +19,11 @@ #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/common/chrome_paths.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/storage_partition.h" #include "content/public/test/test_utils.h" #include "ui/base/dialogs/select_file_dialog.h" #include "ui/base/dialogs/selected_file_info.h" @@ -112,8 +114,8 @@ class SelectFileDialogExtensionBrowserTest : public ExtensionBrowserTest { // Creates a file system mount point for a directory. void AddMountPoint(const FilePath& path) { fileapi::ExternalFileSystemMountPointProvider* provider = - BrowserContext::GetFileSystemContext(browser()->profile())-> - external_provider(); + BrowserContext::GetDefaultStoragePartition(browser()->profile())-> + GetFileSystemContext()->external_provider(); provider->AddLocalMountPoint(path); } diff --git a/chrome/browser/ui/webui/options/cookies_view_handler.cc b/chrome/browser/ui/webui/options/cookies_view_handler.cc index 6cb5721..065c3dc 100644 --- a/chrome/browser/ui/webui/options/cookies_view_handler.cc +++ b/chrome/browser/ui/webui/options/cookies_view_handler.cc @@ -30,6 +30,10 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +namespace fileapi { +class FileSystemContext; +} + namespace options { CookiesViewHandler::CookiesViewHandler() @@ -194,6 +198,8 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { content::BrowserContext::GetDefaultStoragePartition(profile); content::IndexedDBContext* indexed_db_context = storage_partition->GetIndexedDBContext(); + fileapi::FileSystemContext* file_system_context = + storage_partition->GetFileSystemContext(); apps_map[std::string()] = new LocalDataContainer( "Site Data", std::string(), new BrowsingDataCookieHelper(profile->GetRequestContext()), @@ -202,7 +208,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { NULL, new BrowsingDataAppCacheHelper(profile), BrowsingDataIndexedDBHelper::Create(indexed_db_context), - BrowsingDataFileSystemHelper::Create(profile), + BrowsingDataFileSystemHelper::Create(file_system_context), BrowsingDataQuotaHelper::Create(profile), BrowsingDataServerBoundCertHelper::Create(profile), BrowsingDataFlashLSOHelper::Create(profile)); @@ -223,7 +229,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { it != extensions->end(); ++it) { if ((*it)->is_storage_isolated()) { net::URLRequestContextGetter* context_getter = - profile->GetRequestContextForIsolatedApp((*it)->id()); + profile->GetRequestContextForStoragePartition((*it)->id()); // TODO(nasko): When new types of storage are isolated, add the // appropriate browsing data helper objects to the constructor. // For now, just cookies are isolated, so other parameters are NULL. diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index e715ade..9f34ca3 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -616,7 +616,7 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( const extensions::Extension* installed_app = extension_service-> GetInstalledAppForRenderer(renderer_child_id); if (installed_app != NULL && installed_app->is_storage_isolated()) - return GetRequestContextForIsolatedApp(installed_app->id()); + return GetRequestContextForStoragePartition(installed_app->id()); } content::RenderProcessHost* rph = content::RenderProcessHost::FromID( @@ -628,7 +628,7 @@ net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( // non-persistent context using the RPH's id. std::string id("guest-"); id.append(base::IntToString(renderer_child_id)); - return GetRequestContextForIsolatedApp(id); + return GetRequestContextForStoragePartition(id); } return GetRequestContext(); @@ -659,6 +659,12 @@ TestingProfile::GetMediaRequestContextForRenderProcess( return NULL; } +net::URLRequestContextGetter* +TestingProfile::GetMediaRequestContextForStoragePartition( + const std::string& partition_id) { + return NULL; +} + net::URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { if (!extensions_request_context_) extensions_request_context_ = new TestExtensionURLRequestContextGetter(); @@ -669,9 +675,10 @@ net::SSLConfigService* TestingProfile::GetSSLConfigService() { return NULL; } -net::URLRequestContextGetter* TestingProfile::GetRequestContextForIsolatedApp( - const std::string& app_id) { - // We don't test isolated app storage here yet, so returning the same dummy +net::URLRequestContextGetter* +TestingProfile::GetRequestContextForStoragePartition( + const std::string& partition_id) { + // We don't test storage partitions here yet, so returning the same dummy // context is sufficient for now. return GetRequestContext(); } diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 0476899..1c48188 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -245,8 +245,11 @@ class TestingProfile : public Profile { int renderer_child_id) OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForExtensions() OVERRIDE; - virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( - const std::string& app_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; + virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; virtual std::wstring GetName(); diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc index 9508b80..cde0484 100644 --- a/content/browser/appcache/chrome_appcache_service.cc +++ b/content/browser/appcache/chrome_appcache_service.cc @@ -32,7 +32,8 @@ void ChromeAppCacheService::InitializeOnIOThread( resource_context_ = resource_context; // The |request_context_getter| can be NULL in some unit tests. - // TODO(awong): TestProfile is difficult to work with. The + // + // TODO(ajwong): TestProfile is difficult to work with. The // SafeBrowsing tests require that GetRequestContext return NULL // so we can't depend on having a non-NULL value here. See crbug/149783. if (request_context_getter) diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 3b33c31..cd65c76 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc @@ -103,13 +103,6 @@ DownloadManager* BrowserContext::GetDownloadManager( context, kDownloadManagerKeyName); } -fileapi::FileSystemContext* BrowserContext::GetFileSystemContext( - BrowserContext* browser_context) { - // TODO(ajwong): Change this API to require a SiteInstance instead of - // using GetDefaultStoragePartition(). - return GetDefaultStoragePartition(browser_context)->GetFileSystemContext(); -} - StoragePartition* BrowserContext::GetStoragePartition( BrowserContext* browser_context, SiteInstance* site_instance) { diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc index 2c1511f..a5c3025 100644 --- a/content/browser/download/download_manager_impl_unittest.cc +++ b/content/browser/download/download_manager_impl_unittest.cc @@ -384,6 +384,8 @@ class MockBrowserContext : public content::BrowserContext { net::URLRequestContextGetter*()); MOCK_METHOD1(GetMediaRequestContextForRenderProcess, net::URLRequestContextGetter*(int renderer_child_id)); + MOCK_METHOD1(GetMediaRequestContextForStoragePartition, + net::URLRequestContextGetter*(const std::string& id)); MOCK_METHOD0(GetResourceContext, content::ResourceContext*()); MOCK_METHOD0(GetDownloadManagerDelegate, content::DownloadManagerDelegate*()); MOCK_METHOD0(GetGeolocationPermissionContext, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 8ea4adf..61ab2f4 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -354,7 +354,7 @@ RenderProcessHostImpl::RenderProcessHostImpl( // requests them. // This is for the filesystem sandbox. ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( - GetID(), browser_context->GetPath().Append( + GetID(), storage_partition_impl->GetPath().Append( fileapi::SandboxMountPointProvider::kNewFileSystemDirectory), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_CREATE | @@ -371,14 +371,14 @@ RenderProcessHostImpl::RenderProcessHostImpl( // This is so that we can read and move stuff out of the old filesystem // sandbox. ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( - GetID(), browser_context->GetPath().Append( + GetID(), storage_partition_impl_->GetPath().Append( fileapi::SandboxMountPointProvider::kOldFileSystemDirectory), base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_WRITE_ATTRIBUTES | base::PLATFORM_FILE_ENUMERATE); // This is so that we can rename the old sandbox out of the way so that we // know we've taken care of it. ChildProcessSecurityPolicyImpl::GetInstance()->GrantPermissionsForFile( - GetID(), browser_context->GetPath().Append( + GetID(), storage_partition_impl_->GetPath().Append( fileapi::SandboxMountPointProvider::kRenamedOldFileSystemDirectory), base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE); @@ -562,22 +562,24 @@ void RenderProcessHostImpl::CreateMessageFilters() { #endif channel_->AddFilter( GetContentClient()->browser()->AllowPepperPrivateFileAPI() ? - new PepperUnsafeFileMessageFilter(GetID(), browser_context->GetPath()) : - new PepperFileMessageFilter(GetID())); + new PepperUnsafeFileMessageFilter( + GetID(), + storage_partition_impl_->GetPath()) : + new PepperFileMessageFilter(GetID())); channel_->AddFilter(new PepperMessageFilter(PepperMessageFilter::RENDERER, GetID(), browser_context)); #if defined(ENABLE_INPUT_SPEECH) channel_->AddFilter(new speech::InputTagSpeechDispatcherHost( - GetID(), browser_context->GetRequestContext(), + GetID(), storage_partition_impl_->GetURLRequestContext(), browser_context->GetSpeechRecognitionPreferences())); channel_->AddFilter(new speech::SpeechRecognitionDispatcherHost( - GetID(), browser_context->GetRequestContext(), + GetID(), storage_partition_impl_->GetURLRequestContext(), browser_context->GetSpeechRecognitionPreferences())); #endif channel_->AddFilter(new FileAPIMessageFilter( GetID(), - browser_context->GetRequestContext(), - BrowserContext::GetFileSystemContext(browser_context), + storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetFileSystemContext(), ChromeBlobStorageContext::GetFor(browser_context))); channel_->AddFilter(new OrientationMessageFilter()); channel_->AddFilter(new FileUtilitiesMessageFilter(GetID())); @@ -601,6 +603,8 @@ void RenderProcessHostImpl::CreateMessageFilters() { GetID(), resource_context, WorkerStoragePartition( + storage_partition_impl_->GetURLRequestContext(), + storage_partition_impl_->GetMediaURLRequestContext(), storage_partition_impl_->GetAppCacheService(), storage_partition_impl_->GetFileSystemContext(), storage_partition_impl_->GetDatabaseTracker(), diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index c4074d3..1ebcbce 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc @@ -54,134 +54,6 @@ class NonOwningZoomData : public base::SupportsUserData::Data { HostZoomMap* host_zoom_map_; }; -class BlobProtocolHandler : public webkit_blob::BlobProtocolHandler { - public: - BlobProtocolHandler( - webkit_blob::BlobStorageController* blob_storage_controller, - base::MessageLoopProxy* loop_proxy) - : webkit_blob::BlobProtocolHandler(blob_storage_controller, - loop_proxy) {} - - virtual ~BlobProtocolHandler() {} - - private: - virtual scoped_refptr<webkit_blob::BlobData> - LookupBlobData(net::URLRequest* request) const { - const ResourceRequestInfoImpl* info = - ResourceRequestInfoImpl::ForRequest(request); - if (!info) - return NULL; - return info->requested_blob_data(); - } - - DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); -}; - -// Adds a bunch of debugging urls. We use an interceptor instead of a protocol -// handler because we want to reuse the chrome://scheme (everyone is familiar -// with it, and no need to expose the content/chrome separation through our UI). -class DeveloperProtocolHandler - : public net::URLRequestJobFactory::Interceptor { - public: - DeveloperProtocolHandler( - AppCacheService* appcache_service, - BlobStorageController* blob_storage_controller) - : appcache_service_(appcache_service), - blob_storage_controller_(blob_storage_controller) {} - virtual ~DeveloperProtocolHandler() {} - - virtual net::URLRequestJob* MaybeIntercept( - net::URLRequest* request, - net::NetworkDelegate* network_delegate) const OVERRIDE { - // Check for chrome://view-http-cache/*, which uses its own job type. - if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) - return ViewHttpCacheJobFactory::CreateJobForRequest(request, - network_delegate); - - // Next check for chrome://appcache-internals/, which uses its own job type. - if (request->url().SchemeIs(chrome::kChromeUIScheme) && - request->url().host() == chrome::kChromeUIAppCacheInternalsHost) { - return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest( - request, network_delegate, appcache_service_); - } - - // Next check for chrome://blob-internals/, which uses its own job type. - if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) { - return ViewBlobInternalsJobFactory::CreateJobForRequest( - request, network_delegate, blob_storage_controller_); - } - -#if defined(USE_TCMALLOC) - // Next check for chrome://tcmalloc/, which uses its own job type. - if (request->url().SchemeIs(chrome::kChromeUIScheme) && - request->url().host() == chrome::kChromeUITcmallocHost) { - return new TcmallocInternalsRequestJob(request, network_delegate); - } -#endif - - // Next check for chrome://histograms/, which uses its own job type. - if (request->url().SchemeIs(chrome::kChromeUIScheme) && - request->url().host() == chrome::kChromeUIHistogramHost) { - return new HistogramInternalsRequestJob(request, network_delegate); - } - - return NULL; - } - - virtual net::URLRequestJob* MaybeInterceptRedirect( - const GURL& location, - net::URLRequest* request, - net::NetworkDelegate* network_delegate) const OVERRIDE { - return NULL; - } - - virtual net::URLRequestJob* MaybeInterceptResponse( - net::URLRequest* request, - net::NetworkDelegate* network_delegate) const OVERRIDE { - return NULL; - } - - virtual bool WillHandleProtocol(const std::string& protocol) const { - return protocol == chrome::kChromeUIScheme; - } - - private: - AppCacheService* appcache_service_; - BlobStorageController* blob_storage_controller_; -}; - -void InitializeRequestContext( - scoped_refptr<net::URLRequestContextGetter> context_getter, - AppCacheService* appcache_service, - FileSystemContext* file_system_context, - ChromeBlobStorageContext* blob_storage_context) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (!context_getter) - return; // tests. - net::URLRequestContext* context = context_getter->GetURLRequestContext(); - net::URLRequestJobFactory* job_factory = - const_cast<net::URLRequestJobFactory*>(context->job_factory()); - if (job_factory->IsHandledProtocol(chrome::kBlobScheme)) - return; // Already initialized this RequestContext. - - bool set_protocol = job_factory->SetProtocolHandler( - chrome::kBlobScheme, - new BlobProtocolHandler( - blob_storage_context->controller(), - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); - DCHECK(set_protocol); - set_protocol = job_factory->SetProtocolHandler( - chrome::kFileSystemScheme, - CreateFileSystemProtocolHandler(file_system_context)); - DCHECK(set_protocol); - - job_factory->AddInterceptor( - new DeveloperProtocolHandler(appcache_service, - blob_storage_context->controller())); - - // TODO(jam): Add the ProtocolHandlerRegistryIntercepter here! -} - } // namespace @@ -227,45 +99,6 @@ void InitializeResourceContext(BrowserContext* browser_context) { new NonOwningZoomData( HostZoomMap::GetForBrowserContext(browser_context))); resource_context->DetachUserDataThread(); - - StoragePartition* storage_partition = - BrowserContext::GetDefaultStoragePartition(browser_context); - - // Add content's URLRequestContext's hooks. - // Check first to avoid memory leak in unittests. - // TODO(creis): Do equivalent initializations for isolated app and isolated - // media request contexts. - if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { - // TODO(ajwong): Move this whole block into - // StoragePartitionImplMap::PostCreateInitialization after we're certain - // this is safe to happen before InitializeResourceContext, and after we've - // found the right URLRequestContext for a storage partition. Otherwise, - // our isolated URLRequestContext getters will do the wrong thing for blobs, - // and FileSystemContext. - // - // http://crbug.com/85121 - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind( - &InitializeRequestContext, - make_scoped_refptr(browser_context->GetRequestContext()), - storage_partition->GetAppCacheService(), - make_scoped_refptr( - storage_partition->GetFileSystemContext()), - make_scoped_refptr( - ChromeBlobStorageContext::GetFor(browser_context)))); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind( - &InitializeRequestContext, - make_scoped_refptr(browser_context->GetMediaRequestContext()), - storage_partition->GetAppCacheService(), - make_scoped_refptr( - storage_partition->GetFileSystemContext()), - make_scoped_refptr( - ChromeBlobStorageContext::GetFor(browser_context)))); - } } } // namespace content diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 02cb5d7..b09918b 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -7,6 +7,7 @@ #include "content/browser/fileapi/browser_file_system_helper.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" +#include "net/url_request/url_request_context_getter.h" #include "webkit/database/database_tracker.h" #include "webkit/quota/quota_manager.h" @@ -147,6 +148,15 @@ FilePath StoragePartitionImpl::GetPath() { return partition_path_; } +net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { + return url_request_context_; +} + +net::URLRequestContextGetter* +StoragePartitionImpl::GetMediaURLRequestContext() { + return media_url_request_context_; +} + quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { return quota_manager_; } @@ -171,4 +181,14 @@ IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { return indexed_db_context_; } +void StoragePartitionImpl::SetURLRequestContext( + net::URLRequestContextGetter* url_request_context) { + url_request_context_ = url_request_context; +} + +void StoragePartitionImpl::SetMediaURLRequestContext( + net::URLRequestContextGetter* media_url_request_context) { + media_url_request_context_ = media_url_request_context; +} + } // namespace content diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h index e7f2f5d..d3d6dba 100644 --- a/content/browser/storage_partition_impl.h +++ b/content/browser/storage_partition_impl.h @@ -23,10 +23,12 @@ class StoragePartitionImpl : public StoragePartition { // need 3 pieces of info from it. static StoragePartitionImpl* Create(BrowserContext* context, const std::string& partition_id, - const FilePath& partition_path); + const FilePath& profile_path); // StoragePartition interface. virtual FilePath GetPath() OVERRIDE; + virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; + virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; @@ -35,15 +37,36 @@ class StoragePartitionImpl : public StoragePartition { virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; private: - StoragePartitionImpl(const FilePath& partition_path, - quota::QuotaManager* quota_manager, - ChromeAppCacheService* appcache_service, - fileapi::FileSystemContext* filesystem_context, - webkit_database::DatabaseTracker* database_tracker, - DOMStorageContextImpl* dom_storage_context, - IndexedDBContextImpl* indexed_db_context); + friend class StoragePartitionImplMap; + + StoragePartitionImpl( + const FilePath& partition_path, + quota::QuotaManager* quota_manager, + ChromeAppCacheService* appcache_service, + fileapi::FileSystemContext* filesystem_context, + webkit_database::DatabaseTracker* database_tracker, + DOMStorageContextImpl* dom_storage_context, + IndexedDBContextImpl* indexed_db_context); + + // Used by StoragePartitionImplMap. + // + // TODO(ajwong): These should be taken in the constructor and in Create() but + // because the URLRequestContextGetter still lives in Profile with a tangled + // initialization, if we try to retrieve the URLRequestContextGetter() + // before the default StoragePartition is created, we end up reentering the + // construction and double-initializing. For now, we retain the legacy + // behavior while allowing StoragePartitionImpl to expose these accessors by + // letting StoragePartitionImplMap call these two private settings at the + // appropriate time. These should move back into the constructor once + // URLRequestContextGetter's lifetime is sorted out. We should also move the + // PostCreateInitialization() out of StoragePartitionImplMap. + void SetURLRequestContext(net::URLRequestContextGetter* url_request_context); + void SetMediaURLRequestContext( + net::URLRequestContextGetter* media_url_request_context); FilePath partition_path_; + scoped_refptr<net::URLRequestContextGetter> url_request_context_; + scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; scoped_refptr<quota::QuotaManager> quota_manager_; scoped_refptr<ChromeAppCacheService> appcache_service_; scoped_refptr<fileapi::FileSystemContext> filesystem_context_; diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index f943a5f..742242f 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -10,15 +10,166 @@ #include "base/stl_util.h" #include "base/string_util.h" #include "content/browser/appcache/chrome_appcache_service.h" +#include "content/browser/fileapi/browser_file_system_helper.h" +#include "content/browser/fileapi/chrome_blob_storage_context.h" +#include "content/browser/histogram_internals_request_job.h" +#include "content/browser/net/view_blob_internals_job_factory.h" +#include "content/browser/net/view_http_cache_job_factory.h" +#include "content/browser/renderer_host/resource_request_info_impl.h" #include "content/browser/resource_context_impl.h" #include "content/browser/storage_partition_impl.h" +#include "content/browser/tcmalloc_internals_request_job.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/storage_partition.h" #include "content/public/common/content_constants.h" +#include "content/public/common/url_constants.h" #include "net/url_request/url_request_context_getter.h" +#include "net/url_request/url_request_context.h" +#include "webkit/appcache/view_appcache_internals_job.h" +#include "webkit/blob/blob_data.h" +#include "webkit/blob/blob_url_request_job_factory.h" +#include "webkit/fileapi/file_system_url_request_job_factory.h" + +using appcache::AppCacheService; +using content::BrowserThread; +using fileapi::FileSystemContext; +using webkit_blob::BlobStorageController; namespace content { +namespace { + +class BlobProtocolHandler : public webkit_blob::BlobProtocolHandler { + public: + BlobProtocolHandler( + webkit_blob::BlobStorageController* blob_storage_controller, + base::MessageLoopProxy* loop_proxy) + : webkit_blob::BlobProtocolHandler(blob_storage_controller, + loop_proxy) {} + + virtual ~BlobProtocolHandler() {} + + private: + virtual scoped_refptr<webkit_blob::BlobData> + LookupBlobData(net::URLRequest* request) const { + const ResourceRequestInfoImpl* info = + ResourceRequestInfoImpl::ForRequest(request); + if (!info) + return NULL; + return info->requested_blob_data(); + } + + DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); +}; + +// Adds a bunch of debugging urls. We use an interceptor instead of a protocol +// handler because we want to reuse the chrome://scheme (everyone is familiar +// with it, and no need to expose the content/chrome separation through our UI). +class DeveloperProtocolHandler + : public net::URLRequestJobFactory::Interceptor { + public: + DeveloperProtocolHandler( + AppCacheService* appcache_service, + BlobStorageController* blob_storage_controller) + : appcache_service_(appcache_service), + blob_storage_controller_(blob_storage_controller) {} + virtual ~DeveloperProtocolHandler() {} + + virtual net::URLRequestJob* MaybeIntercept( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { + // Check for chrome://view-http-cache/*, which uses its own job type. + if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) + return ViewHttpCacheJobFactory::CreateJobForRequest(request, + network_delegate); + + // Next check for chrome://appcache-internals/, which uses its own job type. + if (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUIAppCacheInternalsHost) { + return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest( + request, network_delegate, appcache_service_); + } + + // Next check for chrome://blob-internals/, which uses its own job type. + if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) { + return ViewBlobInternalsJobFactory::CreateJobForRequest( + request, network_delegate, blob_storage_controller_); + } + +#if defined(USE_TCMALLOC) + // Next check for chrome://tcmalloc/, which uses its own job type. + if (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUITcmallocHost) { + return new TcmallocInternalsRequestJob(request, network_delegate); + } +#endif + + // Next check for chrome://histograms/, which uses its own job type. + if (request->url().SchemeIs(chrome::kChromeUIScheme) && + request->url().host() == chrome::kChromeUIHistogramHost) { + return new HistogramInternalsRequestJob(request, network_delegate); + } + + return NULL; + } + + virtual net::URLRequestJob* MaybeInterceptRedirect( + const GURL& location, + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { + return NULL; + } + + virtual net::URLRequestJob* MaybeInterceptResponse( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const OVERRIDE { + return NULL; + } + + virtual bool WillHandleProtocol(const std::string& protocol) const { + return protocol == chrome::kChromeUIScheme; + } + + private: + AppCacheService* appcache_service_; + BlobStorageController* blob_storage_controller_; +}; + +void InitializeURLRequestContext( + net::URLRequestContextGetter* context_getter, + AppCacheService* appcache_service, + FileSystemContext* file_system_context, + ChromeBlobStorageContext* blob_storage_context) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + if (!context_getter) + return; // tests. + net::URLRequestContext* context = context_getter->GetURLRequestContext(); + net::URLRequestJobFactory* job_factory = + const_cast<net::URLRequestJobFactory*>(context->job_factory()); + if (job_factory->IsHandledProtocol(chrome::kBlobScheme)) + return; // Already initialized this RequestContext. + + bool set_protocol = job_factory->SetProtocolHandler( + chrome::kBlobScheme, + new BlobProtocolHandler( + blob_storage_context->controller(), + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); + DCHECK(set_protocol); + set_protocol = job_factory->SetProtocolHandler( + chrome::kFileSystemScheme, + CreateFileSystemProtocolHandler(file_system_context)); + DCHECK(set_protocol); + + job_factory->AddInterceptor( + new DeveloperProtocolHandler(appcache_service, + blob_storage_context->controller())); + + // TODO(jam): Add the ProtocolHandlerRegistryIntercepter here! +} + +} // namespace + StoragePartitionImplMap::StoragePartitionImplMap( BrowserContext* browser_context) : browser_context_(browser_context) { @@ -38,26 +189,33 @@ StoragePartitionImpl* StoragePartitionImplMap::Get( return it->second; // There was no previous partition, so let's make a new one. - StoragePartitionImpl* storage_partition = - StoragePartitionImpl::Create(browser_context_, - partition_id, + StoragePartitionImpl* partition = + StoragePartitionImpl::Create(browser_context_, partition_id, browser_context_->GetPath()); - partitions_[partition_id] = storage_partition; + partitions_[partition_id] = partition; - net::URLRequestContextGetter* request_context = partition_id.empty() ? + // These calls must happen after StoragePartitionImpl::Create(). + partition->SetURLRequestContext( + partition_id.empty() ? browser_context_->GetRequestContext() : - browser_context_->GetRequestContextForStoragePartition(partition_id); + browser_context_->GetRequestContextForStoragePartition(partition_id)); + partition->SetMediaURLRequestContext( + partition_id.empty() ? + browser_context_->GetMediaRequestContext() : + browser_context_->GetMediaRequestContextForStoragePartition( + partition_id)); - PostCreateInitialization(storage_partition, request_context); + PostCreateInitialization(partition); - // TODO(ajwong): We need to remove this conditional by making - // InitializeResourceContext() understand having different partition data - // based on the renderer_id. + // TODO(ajwong): ResourceContexts no longer have any storage related state. + // We should move this into a place where it is called once per + // BrowserContext creation rather than piggybacking off the default context + // creation. if (partition_id.empty()) { InitializeResourceContext(browser_context_); } - return storage_partition; + return partition; } void StoragePartitionImplMap::ForEach( @@ -71,8 +229,7 @@ void StoragePartitionImplMap::ForEach( } void StoragePartitionImplMap::PostCreateInitialization( - StoragePartitionImpl* partition, - net::URLRequestContextGetter* request_context_getter) { + StoragePartitionImpl* partition) { // Check first to avoid memory leak in unittests. if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { BrowserThread::PostTask( @@ -82,9 +239,29 @@ void StoragePartitionImplMap::PostCreateInitialization( browser_context_->IsOffTheRecord() ? FilePath() : partition->GetPath().Append(kAppCacheDirname), browser_context_->GetResourceContext(), - make_scoped_refptr(request_context_getter), + make_scoped_refptr(partition->GetURLRequestContext()), make_scoped_refptr( browser_context_->GetSpecialStoragePolicy()))); + + // Add content's URLRequestContext's hooks. + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind( + &InitializeURLRequestContext, + make_scoped_refptr(partition->GetURLRequestContext()), + make_scoped_refptr(partition->GetAppCacheService()), + 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_)))); } } diff --git a/content/browser/storage_partition_impl_map.h b/content/browser/storage_partition_impl_map.h index b875353..9e5c6d6 100644 --- a/content/browser/storage_partition_impl_map.h +++ b/content/browser/storage_partition_impl_map.h @@ -38,8 +38,7 @@ class StoragePartitionImplMap : public base::SupportsUserData::Data { // TODO(ajwong): Is there a way to make it so that Get()'s implementation // doesn't need to be aware of this ordering? Revisit when refactoring // ResourceContext and AppCache to respect storage partitions. - void PostCreateInitialization(StoragePartitionImpl* partition, - net::URLRequestContextGetter* request_context); + void PostCreateInitialization(StoragePartitionImpl* partition); BrowserContext* browser_context_; // Not Owned. std::map<std::string, StoragePartitionImpl*> partitions_; diff --git a/content/browser/worker_host/worker_process_host.cc b/content/browser/worker_host/worker_process_host.cc index 40da5ab..8d40298 100644 --- a/content/browser/worker_host/worker_process_host.cc +++ b/content/browser/worker_host/worker_process_host.cc @@ -46,6 +46,7 @@ #include "ipc/ipc_switches.h" #include "net/base/mime_util.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" +#include "net/url_request/url_request_context_getter.h" #include "ui/base/ui_base_switches.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" @@ -70,18 +71,23 @@ class URLRequestContextSelector : public ResourceMessageFilter::URLRequestContextSelector { public: explicit URLRequestContextSelector( - net::URLRequestContext* url_request_context) - : url_request_context_(url_request_context) { + net::URLRequestContextGetter* url_request_context, + net::URLRequestContextGetter* media_url_request_context) + : url_request_context_(url_request_context), + media_url_request_context_(media_url_request_context) { } virtual ~URLRequestContextSelector() {} virtual net::URLRequestContext* GetRequestContext( ResourceType::Type resource_type) { - return url_request_context_; + if (resource_type == ResourceType::MEDIA) + return media_url_request_context_->GetURLRequestContext(); + return url_request_context_->GetURLRequestContext(); } private: - net::URLRequestContext* url_request_context_; + net::URLRequestContextGetter* url_request_context_; + net::URLRequestContextGetter* media_url_request_context_; }; } // namespace @@ -254,16 +260,17 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { content::GetChromeBlobStorageContextForResourceContext( resource_context_); - // TODO(michaeln): This is hacky but correct. The request context should be - // more directly accessible than digging it out of the appcache service. - net::URLRequestContext* request_context = - partition_.appcache_service()->request_context(); + net::URLRequestContextGetter* url_request_context = + partition_.url_request_context(); + net::URLRequestContextGetter* media_url_request_context = + partition_.url_request_context(); ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( process_->GetData().id, content::PROCESS_TYPE_WORKER, resource_context_, partition_.appcache_service(), blob_storage_context, - new URLRequestContextSelector(request_context)); + new URLRequestContextSelector(url_request_context, + media_url_request_context)); process_->GetHost()->AddFilter(resource_message_filter); worker_message_filter_ = new WorkerMessageFilter( @@ -276,7 +283,7 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { process_->GetData().id)); process_->GetHost()->AddFilter(new FileAPIMessageFilter( process_->GetData().id, - request_context, + url_request_context, partition_.filesystem_context(), blob_storage_context)); process_->GetHost()->AddFilter(new FileUtilitiesMessageFilter( @@ -286,8 +293,11 @@ void WorkerProcessHost::CreateMessageFilters(int render_process_id) { new DatabaseMessageFilter(partition_.database_tracker())); SocketStreamDispatcherHost* socket_stream_dispatcher_host = - new SocketStreamDispatcherHost(render_process_id, - new URLRequestContextSelector(request_context), resource_context_); + new SocketStreamDispatcherHost( + render_process_id, + new URLRequestContextSelector(url_request_context, + media_url_request_context), + resource_context_); process_->GetHost()->AddFilter(socket_stream_dispatcher_host); process_->GetHost()->AddFilter( new content::WorkerDevToolsMessageFilter(process_->GetData().id)); diff --git a/content/browser/worker_host/worker_storage_partition.cc b/content/browser/worker_host/worker_storage_partition.cc index c253d72..ea7f7fa 100644 --- a/content/browser/worker_host/worker_storage_partition.cc +++ b/content/browser/worker_host/worker_storage_partition.cc @@ -8,15 +8,20 @@ #include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.h" +#include "net/url_request/url_request_context_getter.h" #include "webkit/database/database_tracker.h" #include "webkit/fileapi/file_system_context.h" WorkerStoragePartition::WorkerStoragePartition( + net::URLRequestContextGetter* url_request_context, + net::URLRequestContextGetter* media_url_request_context, ChromeAppCacheService* appcache_service, fileapi::FileSystemContext* filesystem_context, webkit_database::DatabaseTracker* database_tracker, IndexedDBContextImpl* indexed_db_context) - : appcache_service_(appcache_service), + : url_request_context_(url_request_context), + media_url_request_context_(media_url_request_context), + appcache_service_(appcache_service), filesystem_context_(filesystem_context), database_tracker_(database_tracker), indexed_db_context_(indexed_db_context) { @@ -35,7 +40,9 @@ const WorkerStoragePartition& WorkerStoragePartition::operator=( bool WorkerStoragePartition::Equals( const WorkerStoragePartition& other) const { - return appcache_service_ == other.appcache_service_ && + return url_request_context_ == other.url_request_context_ && + media_url_request_context_ == other.media_url_request_context_ && + appcache_service_ == other.appcache_service_ && filesystem_context_ == other.filesystem_context_ && database_tracker_ == other.database_tracker_ && indexed_db_context_ == other.indexed_db_context_; @@ -45,6 +52,8 @@ WorkerStoragePartition::~WorkerStoragePartition() { } void WorkerStoragePartition::Copy(const WorkerStoragePartition& other) { + url_request_context_ = other.url_request_context_; + media_url_request_context_ = other.media_url_request_context_; appcache_service_ = other.appcache_service_; filesystem_context_ = other.filesystem_context_; database_tracker_ = other.database_tracker_; diff --git a/content/browser/worker_host/worker_storage_partition.h b/content/browser/worker_host/worker_storage_partition.h index accbb1b..5642e17 100644 --- a/content/browser/worker_host/worker_storage_partition.h +++ b/content/browser/worker_host/worker_storage_partition.h @@ -14,6 +14,10 @@ namespace fileapi { class FileSystemContext; } // namespace fileapi +namespace net { +class URLRequestContextGetter; +} + namespace webkit_database { class DatabaseTracker; } // namespace webkit_database @@ -32,10 +36,13 @@ class DatabaseTracker; // it which makes it look awkward as a struct. class WorkerStoragePartition { public: - WorkerStoragePartition(ChromeAppCacheService* appcache_service, - fileapi::FileSystemContext* filesystem_context, - webkit_database::DatabaseTracker* database_tracker, - IndexedDBContextImpl* indexed_db_context); + WorkerStoragePartition( + net::URLRequestContextGetter* url_request_context, + net::URLRequestContextGetter* media_url_request_context, + ChromeAppCacheService* appcache_service, + fileapi::FileSystemContext* filesystem_context, + webkit_database::DatabaseTracker* database_tracker, + IndexedDBContextImpl* indexed_db_context); ~WorkerStoragePartition(); // Declaring so these don't get inlined which has the unfortunate effect of @@ -46,6 +53,14 @@ class WorkerStoragePartition { bool Equals(const WorkerStoragePartition& other) const; + net::URLRequestContextGetter* url_request_context() const { + return url_request_context_.get(); + } + + net::URLRequestContextGetter* media_url_request_context() const { + return media_url_request_context_.get(); + } + ChromeAppCacheService* appcache_service() const { return appcache_service_.get(); } @@ -65,6 +80,8 @@ class WorkerStoragePartition { private: void Copy(const WorkerStoragePartition& other); + scoped_refptr<net::URLRequestContextGetter> url_request_context_; + scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; scoped_refptr<ChromeAppCacheService> appcache_service_; scoped_refptr<fileapi::FileSystemContext> filesystem_context_; scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 275ad42..16a2ea5 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -10,10 +10,6 @@ #include "base/supports_user_data.h" #include "content/common/content_export.h" -namespace fileapi { -class FileSystemContext; -} - namespace net { class URLRequestContextGetter; } @@ -47,8 +43,6 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { StoragePartitionCallback; static DownloadManager* GetDownloadManager(BrowserContext* browser_context); - static fileapi::FileSystemContext* GetFileSystemContext( - BrowserContext* browser_context); static content::StoragePartition* GetStoragePartition( BrowserContext* browser_context, SiteInstance* site_instance); @@ -111,6 +105,9 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { // context and renderer process. virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( int renderer_child_id) = 0; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) = 0; // Returns the resource context. virtual ResourceContext* GetResourceContext() = 0; diff --git a/content/public/browser/storage_partition.h b/content/public/browser/storage_partition.h index 6cdb328..6743a42 100644 --- a/content/public/browser/storage_partition.h +++ b/content/public/browser/storage_partition.h @@ -18,6 +18,10 @@ namespace fileapi { class FileSystemContext; } +namespace net { +class URLRequestContextGetter; +} + namespace quota { class QuotaManager; } @@ -41,6 +45,8 @@ class DOMStorageContext; class StoragePartition { public: virtual FilePath GetPath() = 0; + virtual net::URLRequestContextGetter* GetURLRequestContext() = 0; + virtual net::URLRequestContextGetter* GetMediaURLRequestContext() = 0; virtual quota::QuotaManager* GetQuotaManager() = 0; virtual appcache::AppCacheService* GetAppCacheService() = 0; virtual fileapi::FileSystemContext* GetFileSystemContext() = 0; diff --git a/content/public/test/test_browser_context.cc b/content/public/test/test_browser_context.cc index d7ee27a..4d808f6 100644 --- a/content/public/test/test_browser_context.cc +++ b/content/public/test/test_browser_context.cc @@ -126,6 +126,12 @@ TestBrowserContext::GetMediaRequestContextForRenderProcess( return NULL; } +net::URLRequestContextGetter* +TestBrowserContext::GetMediaRequestContextForStoragePartition( + const std::string& partition_id) { + return NULL; +} + ResourceContext* TestBrowserContext::GetResourceContext() { if (!resource_context_.get()) resource_context_.reset(new MockResourceContext()); diff --git a/content/public/test/test_browser_context.h b/content/public/test/test_browser_context.h index ecabc7f..07f8015 100644 --- a/content/public/test/test_browser_context.h +++ b/content/public/test/test_browser_context.h @@ -38,6 +38,9 @@ class TestBrowserContext : public BrowserContext { virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual ResourceContext* GetResourceContext() OVERRIDE; virtual GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index 92d33d9..a5ad7af 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -125,6 +125,12 @@ net::URLRequestContextGetter* } net::URLRequestContextGetter* + ShellBrowserContext::GetMediaRequestContextForStoragePartition( + const std::string& partition_id) { + return GetRequestContext(); +} + +net::URLRequestContextGetter* ShellBrowserContext::GetRequestContextForStoragePartition( const std::string& partition_id) { return NULL; diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index 7c09a82..fbcbc6e 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -33,6 +33,9 @@ class ShellBrowserContext : public BrowserContext { virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( int renderer_child_id) OVERRIDE; + virtual net::URLRequestContextGetter* + GetMediaRequestContextForStoragePartition( + const std::string& partition_id) OVERRIDE; virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition( const std::string& partition_id) OVERRIDE; virtual ResourceContext* GetResourceContext() OVERRIDE; |