diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:12:12 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:12:12 +0000 |
commit | b7b82eb3dce4220e592472d0f9220280d1246243 (patch) | |
tree | 2fa55d5d932949d4a313ca3b7d8ed39fc9c81d11 | |
parent | a097393e6e0f08f521c977677bed01a0ad01120b (diff) | |
download | chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.zip chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.gz chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.bz2 |
Remove BrowserFileSystemContext class and merge it into SandboxedFileSystemContext
BUG=60243
TEST=none
Review URL: http://codereview.chromium.org/5633008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69089 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 154 insertions, 141 deletions
diff --git a/chrome/browser/extensions/extension_data_deleter.cc b/chrome/browser/extensions/extension_data_deleter.cc index d87ffef..f98ac86 100644 --- a/chrome/browser/extensions/extension_data_deleter.cc +++ b/chrome/browser/extensions/extension_data_deleter.cc @@ -6,13 +6,13 @@ #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/file_system/browser_file_system_context.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/net/url_request_context_getter.h" #include "net/base/cookie_monster.h" #include "net/base/net_errors.h" #include "webkit/database/database_util.h" #include "webkit/database/database_tracker.h" +#include "webkit/fileapi/sandboxed_file_system_context.h" ExtensionDataDeleter::ExtensionDataDeleter(Profile* profile, const GURL& extension_url) { diff --git a/chrome/browser/extensions/extension_data_deleter.h b/chrome/browser/extensions/extension_data_deleter.h index 86d5aa5..9f83546 100644 --- a/chrome/browser/extensions/extension_data_deleter.h +++ b/chrome/browser/extensions/extension_data_deleter.h @@ -15,7 +15,10 @@ namespace webkit_database { class DatabaseTracker; } -class BrowserFileSystemContext; +namespace fileapi { +class SandboxedFileSystemContext; +} + class Profile; class URLRequestContextGetter; class WebKitContext; @@ -72,7 +75,7 @@ class ExtensionDataDeleter // Webkit context for accessing the DOM storage helper. scoped_refptr<WebKitContext> webkit_context_; - scoped_refptr<BrowserFileSystemContext> file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter); }; diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 88d97d2..a2ccce5 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -1298,7 +1298,7 @@ void ExtensionsService::GrantUnlimitedStorage(const Extension* extension) { BrowserThread::IO, FROM_HERE, NewRunnableMethod( profile_->GetFileSystemContext(), - &BrowserFileSystemContext::SetOriginQuotaUnlimited, + &fileapi::SandboxedFileSystemContext::SetOriginQuotaUnlimited, origin)); } } @@ -1333,7 +1333,7 @@ void ExtensionsService::RevokeUnlimitedStorage(const Extension* extension) { BrowserThread::IO, FROM_HERE, NewRunnableMethod( profile_->GetFileSystemContext(), - &BrowserFileSystemContext::ResetOriginQuotaUnlimited, + &fileapi::SandboxedFileSystemContext::ResetOriginQuotaUnlimited, origin)); } } diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 9ac3aa7..80ed848 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -23,7 +23,6 @@ #include "base/version.h" #include "chrome/browser/appcache/chrome_appcache_service.h" #include "chrome/browser/browser_thread.h" -#include "chrome/browser/file_system/browser_file_system_context.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_creator.h" #include "chrome/browser/extensions/extension_error_reporter.h" @@ -31,6 +30,7 @@ #include "chrome/browser/extensions/external_extension_provider.h" #include "chrome/browser/extensions/external_pref_extension_provider.h" #include "chrome/browser/extensions/pack_extension_job.cc" +#include "chrome/browser/file_system/browser_file_system_helper.h" #include "chrome/browser/in_process_webkit/dom_storage_context.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/prefs/browser_prefs.h" @@ -316,17 +316,17 @@ class ExtensionTestingProfile : public TestingProfile { return appcache_service_; } - virtual BrowserFileSystemContext* GetFileSystemContext() { - if (!browser_file_system_context_) - browser_file_system_context_ = new BrowserFileSystemContext( + virtual fileapi::SandboxedFileSystemContext* GetFileSystemContext() { + if (!file_system_context_) + file_system_context_ = CreateFileSystemContext( GetPath(), IsOffTheRecord()); - return browser_file_system_context_; + return file_system_context_; } private: ExtensionsService* service_; scoped_refptr<ChromeAppCacheService> appcache_service_; - scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; }; // Our message loop may be used in tests which require it to be an IO loop. diff --git a/chrome/browser/file_system/browser_file_system_context.cc b/chrome/browser/file_system/browser_file_system_context.cc deleted file mode 100644 index bbc4806..0000000 --- a/chrome/browser/file_system/browser_file_system_context.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/file_system/browser_file_system_context.h" - -#include "base/file_path.h" -#include "base/command_line.h" -#include "chrome/common/chrome_switches.h" -#include "webkit/fileapi/file_system_quota_manager.h" - -BrowserFileSystemContext::BrowserFileSystemContext( - const FilePath& profile_path, bool is_incognito) - : fileapi::SandboxedFileSystemContext( - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), - profile_path, - is_incognito, - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAllowFileAccessFromFiles), - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUnlimitedQuotaForFiles)) { -} - -void BrowserFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - quota_manager()->SetOriginQuotaUnlimited(url); -} - -void BrowserFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - quota_manager()->ResetOriginQuotaUnlimited(url); -} - -BrowserFileSystemContext::~BrowserFileSystemContext() {} diff --git a/chrome/browser/file_system/browser_file_system_context.h b/chrome/browser/file_system/browser_file_system_context.h deleted file mode 100644 index 8082179..0000000 --- a/chrome/browser/file_system/browser_file_system_context.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_CONTEXT_H_ -#define CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_CONTEXT_H_ - -#include "base/ref_counted.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/browser_thread.h" -#include "webkit/fileapi/sandboxed_file_system_context.h" - -class FilePath; -class GURL; - -// This is owned by profile and shared by all the FileSystemDispatcherHost -// that shared by the same profile. This class is just a thin wrapper around -// fileapi::SandboxedFileSystemContext. -class BrowserFileSystemContext - : public base::RefCountedThreadSafe<BrowserFileSystemContext, - BrowserThread::DeleteOnIOThread>, - public fileapi::SandboxedFileSystemContext { - public: - BrowserFileSystemContext(const FilePath& profile_path, bool is_incognito); - virtual ~BrowserFileSystemContext(); - - // Quota related methods. - void SetOriginQuotaUnlimited(const GURL& url); - void ResetOriginQuotaUnlimited(const GURL& url); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserFileSystemContext); -}; - -#endif // CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_CONTEXT_H_ diff --git a/chrome/browser/file_system/browser_file_system_helper.cc b/chrome/browser/file_system/browser_file_system_helper.cc new file mode 100644 index 0000000..2ce4f36 --- /dev/null +++ b/chrome/browser/file_system/browser_file_system_helper.cc @@ -0,0 +1,23 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/file_system/browser_file_system_helper.h" + +#include "base/file_path.h" +#include "base/command_line.h" +#include "chrome/browser/browser_thread.h" +#include "chrome/common/chrome_switches.h" + +scoped_refptr<fileapi::SandboxedFileSystemContext> CreateFileSystemContext( + const FilePath& profile_path, bool is_incognito) { + return new fileapi::SandboxedFileSystemContext( + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), + profile_path, + is_incognito, + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAllowFileAccessFromFiles), + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUnlimitedQuotaForFiles)); +} diff --git a/chrome/browser/file_system/browser_file_system_helper.h b/chrome/browser/file_system/browser_file_system_helper.h new file mode 100644 index 0000000..56ec3e2 --- /dev/null +++ b/chrome/browser/file_system/browser_file_system_helper.h @@ -0,0 +1,17 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_ +#define CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_ + +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "webkit/fileapi/sandboxed_file_system_context.h" + +// Convenient method that returns SandboxedFileSystemContext +// constructed for the browser process. +scoped_refptr<fileapi::SandboxedFileSystemContext> CreateFileSystemContext( + const FilePath& profile_path, bool is_incognito); + +#endif // CHROME_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_ diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc index fe2504d..98b14a5 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.cc +++ b/chrome/browser/file_system/file_system_dispatcher_host.cc @@ -11,7 +11,6 @@ #include "base/thread.h" #include "base/time.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/file_system/browser_file_system_context.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" @@ -24,6 +23,7 @@ #include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_path_manager.h" #include "webkit/fileapi/file_system_quota_manager.h" +#include "webkit/fileapi/sandboxed_file_system_context.h" #include "webkit/fileapi/sandboxed_file_system_operation.h" using fileapi::FileSystemCallbackDispatcher; @@ -89,7 +89,7 @@ FileSystemDispatcherHost::FileSystemDispatcherHost(Profile* profile) FileSystemDispatcherHost::FileSystemDispatcherHost( ChromeURLRequestContext* context) - : context_(context->browser_file_system_context()), + : context_(context->file_system_context()), host_content_settings_map_(context->host_content_settings_map()), request_context_(context) { } @@ -239,7 +239,7 @@ SandboxedFileSystemOperation* FileSystemDispatcherHost::GetNewOperation( SandboxedFileSystemOperation* operation = new SandboxedFileSystemOperation( dispatcher, BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), - context_.get()); + context_); operations_.AddWithID(operation, request_id); return operation; } diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h index 8f1620b..ab57d09 100644 --- a/chrome/browser/file_system/file_system_dispatcher_host.h +++ b/chrome/browser/file_system/file_system_dispatcher_host.h @@ -17,7 +17,6 @@ class Time; } class ChromeURLRequestContext; -class BrowserFileSystemContext; class FilePath; class GURL; class HostContentSettingsMap; @@ -28,6 +27,7 @@ class URLRequestContext; class URLRequestContextGetter; namespace fileapi { +class SandboxedFileSystemContext; class SandboxedFileSystemOperation; } @@ -81,7 +81,7 @@ class FileSystemDispatcherHost : public BrowserMessageFilter { // Creates a new SandboxedFileSystemOperation. fileapi::SandboxedFileSystemOperation* GetNewOperation(int request_id); - scoped_refptr<BrowserFileSystemContext> context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> context_; // Used to look up permissions. scoped_refptr<HostContentSettingsMap> host_content_settings_map_; diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 58b353f..530790e 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -850,7 +850,7 @@ ChromeURLRequestContext::ChromeURLRequestContext( is_media_ = other->is_media_; is_off_the_record_ = other->is_off_the_record_; blob_storage_context_ = other->blob_storage_context_; - browser_file_system_context_ = other->browser_file_system_context_; + file_system_context_ = other->file_system_context_; extension_info_map_ = other->extension_info_map_; } @@ -919,7 +919,7 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) appcache_service_ = profile->GetAppCacheService(); database_tracker_ = profile->GetDatabaseTracker(); blob_storage_context_ = profile->GetBlobStorageContext(); - browser_file_system_context_ = profile->GetFileSystemContext(); + file_system_context_ = profile->GetFileSystemContext(); extension_info_map_ = profile->GetExtensionInfoMap(); } @@ -945,6 +945,6 @@ void ChromeURLRequestContextFactory::ApplyProfileParametersToContext( context->set_appcache_service(appcache_service_); context->set_database_tracker(database_tracker_); context->set_blob_storage_context(blob_storage_context_); - context->set_browser_file_system_context(browser_file_system_context_); + context->set_file_system_context(file_system_context_); context->set_extension_info_map(extension_info_map_); } diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 791805d..bedb9a8 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -14,7 +14,6 @@ #include "chrome/browser/chrome_blob_storage_context.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/extensions/extension_info_map.h" -#include "chrome/browser/file_system/browser_file_system_context.h" #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_cookie_policy.h" @@ -27,6 +26,7 @@ #include "net/base/cookie_policy.h" #include "net/url_request/url_request_context.h" #include "webkit/database/database_tracker.h" +#include "webkit/fileapi/sandboxed_file_system_context.h" class CommandLine; class PrefService; @@ -71,8 +71,8 @@ class ChromeURLRequestContext : public URLRequestContext { } // Gets the file system host context with this context's profile. - BrowserFileSystemContext* browser_file_system_context() const { - return browser_file_system_context_.get(); + fileapi::SandboxedFileSystemContext* file_system_context() const { + return file_system_context_.get(); } bool is_off_the_record() const { @@ -177,8 +177,8 @@ class ChromeURLRequestContext : public URLRequestContext { void set_blob_storage_context(ChromeBlobStorageContext* context) { blob_storage_context_ = context; } - void set_browser_file_system_context(BrowserFileSystemContext* context) { - browser_file_system_context_ = context; + void set_file_system_context(fileapi::SandboxedFileSystemContext* context) { + file_system_context_ = context; } void set_extension_info_map(ExtensionInfoMap* map) { extension_info_map_ = map; @@ -207,7 +207,7 @@ class ChromeURLRequestContext : public URLRequestContext { scoped_refptr<HostContentSettingsMap> host_content_settings_map_; scoped_refptr<HostZoomMap> host_zoom_map_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; - scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; scoped_refptr<ExtensionInfoMap> extension_info_map_; bool is_media_; @@ -376,7 +376,7 @@ class ChromeURLRequestContextFactory { scoped_refptr<net::SSLConfigService> ssl_config_service_; scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; - scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; scoped_refptr<ExtensionInfoMap> extension_info_map_; FilePath profile_dir_path_; diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index d2087fc..f555a17f 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -19,7 +19,7 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_process_manager.h" -#include "chrome/browser/file_system/browser_file_system_context.h" +#include "chrome/browser/file_system/browser_file_system_helper.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -337,12 +337,12 @@ class OffTheRecordProfileImpl : public Profile, return NULL; } - virtual BrowserFileSystemContext* GetFileSystemContext() { - if (!browser_file_system_context_) - browser_file_system_context_ = new BrowserFileSystemContext( + virtual fileapi::SandboxedFileSystemContext* GetFileSystemContext() { + if (!file_system_context_) + file_system_context_ = CreateFileSystemContext( GetPath(), IsOffTheRecord()); - DCHECK(browser_file_system_context_.get()); - return browser_file_system_context_.get(); + DCHECK(file_system_context_.get()); + return file_system_context_.get(); } virtual void InitThemes() { @@ -669,7 +669,7 @@ class OffTheRecordProfileImpl : public Profile, scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; // The file_system context for this profile. - scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); }; diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 9bf0f3e5..ad11285 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -39,6 +39,10 @@ namespace webkit_database { class DatabaseTracker; } +namespace fileapi { +class SandboxedFileSystemContext; +} + class AutocompleteClassifier; class BackgroundContentsService; class BackgroundModeManager; @@ -54,47 +58,48 @@ class DownloadManager; class Extension; class ExtensionDevToolsManager; class ExtensionEventRouter; +class ExtensionInfoMap; class ExtensionMessageService; class ExtensionProcessManager; class ExtensionsService; class FaviconService; class FilePath; -class BrowserFileSystemContext; class FindBarState; class GeolocationContentSettingsMap; class GeolocationPermissionContext; class HistoryService; class HostContentSettingsMap; class HostZoomMap; -class NavigationController; class NTPResourceCache; +class NavigationController; class PasswordStore; class PersonalDataManager; class PinnedTabService; -class PrefService; -class ExtensionInfoMap; class PrefProxyConfigTracker; +class PrefService; class PrerenderManager; -class PromoCounter; -class ProfileSyncService; class ProfileSyncFactory; -class SessionService; -class SpellCheckHost; +class ProfileSyncService; +class ProfileSyncService; +class PromoCounter; +class PromoCounter; +class SQLitePersistentCookieStore; class SSLConfigServiceManager; class SSLHostState; +class SessionService; +class SpellCheckHost; class StatusTray; -class TransportSecurityPersister; -class SQLitePersistentCookieStore; class TabRestoreService; class TemplateURLFetcher; class TemplateURLModel; class ThemeProvider; class TokenService; +class TransportSecurityPersister; class URLRequestContextGetter; class UserScriptMaster; class UserStyleSheetWatcher; -class VisitedLinkMaster; class VisitedLinkEventListener; +class VisitedLinkMaster; class WebDataService; class WebKitContext; class WebResourceService; @@ -298,7 +303,7 @@ class Profile { // Returns the FileSystemContext associated to this profile. The context // is lazily created the first time this method is called. This is owned // by the profile. - virtual BrowserFileSystemContext* GetFileSystemContext() = 0; + virtual fileapi::SandboxedFileSystemContext* GetFileSystemContext() = 0; // Returns the BrowserSignin object assigned to this profile. virtual BrowserSignin* GetBrowserSignin() = 0; diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 20c8166..f2f9cde 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -40,7 +40,7 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/favicon_service.h" -#include "chrome/browser/file_system/browser_file_system_context.h" +#include "chrome/browser/file_system/browser_file_system_helper.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" #include "chrome/browser/history/history.h" @@ -1012,12 +1012,12 @@ PersonalDataManager* ProfileImpl::GetPersonalDataManager() { return personal_data_manager_.get(); } -BrowserFileSystemContext* ProfileImpl::GetFileSystemContext() { - if (!browser_file_system_context_.get()) - browser_file_system_context_ = new BrowserFileSystemContext( +fileapi::SandboxedFileSystemContext* ProfileImpl::GetFileSystemContext() { + if (!file_system_context_.get()) + file_system_context_ = CreateFileSystemContext( GetPath(), IsOffTheRecord()); - DCHECK(browser_file_system_context_.get()); - return browser_file_system_context_.get(); + DCHECK(file_system_context_.get()); + return file_system_context_.get(); } void ProfileImpl::InitThemes() { diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 59a1695..3f4d587 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -71,7 +71,7 @@ class ProfileImpl : public Profile, virtual TemplateURLFetcher* GetTemplateURLFetcher(); virtual DownloadManager* GetDownloadManager(); virtual PersonalDataManager* GetPersonalDataManager(); - virtual BrowserFileSystemContext* GetFileSystemContext(); + virtual fileapi::SandboxedFileSystemContext* GetFileSystemContext(); virtual void InitThemes(); virtual void SetTheme(const Extension* extension); virtual void SetNativeTheme(); @@ -235,7 +235,7 @@ class ProfileImpl : public Profile, scoped_ptr<StatusTray> status_tray_; scoped_refptr<PersonalDataManager> personal_data_manager_; scoped_ptr<PinnedTabService> pinned_tab_service_; - scoped_refptr<BrowserFileSystemContext> browser_file_system_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; scoped_ptr<BrowserSignin> browser_signin_; bool history_service_created_; bool favicon_service_created_; diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 4d71d27..c1359cb 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -175,7 +175,7 @@ bool WorkerProcessHost::Init() { // requests them. ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( id(), - request_context_->browser_file_system_context()-> + request_context_->file_system_context()-> path_manager()->base_path(), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_CREATE | diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index ac73805..dc082a3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1228,8 +1228,8 @@ 'browser/file_path_watcher/file_path_watcher_win.cc', 'browser/file_select_helper.cc', 'browser/file_select_helper.h', - 'browser/file_system/browser_file_system_context.cc', - 'browser/file_system/browser_file_system_context.h', + 'browser/file_system/browser_file_system_helper.cc', + 'browser/file_system/browser_file_system_helper.h', 'browser/file_system/file_system_dispatcher_host.cc', 'browser/file_system/file_system_dispatcher_host.h', 'browser/first_run/first_run.cc', diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 4f53925..53a1fb6 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -200,7 +200,9 @@ class TestingProfile : public Profile { } virtual DownloadManager* GetDownloadManager() { return NULL; } virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } - virtual BrowserFileSystemContext* GetFileSystemContext() { return NULL; } + virtual fileapi::SandboxedFileSystemContext* GetFileSystemContext() { + return NULL; + } virtual BrowserSignin* GetBrowserSignin() { return NULL; } virtual bool HasCreatedDownloadManager() const { return false; } virtual void InitThemes(); diff --git a/webkit/fileapi/sandboxed_file_system_context.cc b/webkit/fileapi/sandboxed_file_system_context.cc index b3b009e..16232d5 100644 --- a/webkit/fileapi/sandboxed_file_system_context.cc +++ b/webkit/fileapi/sandboxed_file_system_context.cc @@ -13,11 +13,13 @@ namespace fileapi { SandboxedFileSystemContext::SandboxedFileSystemContext( scoped_refptr<base::MessageLoopProxy> file_message_loop, + scoped_refptr<base::MessageLoopProxy> io_message_loop, const FilePath& profile_path, bool is_incognito, bool allow_file_access, bool unlimited_quota) : file_message_loop_(file_message_loop), + io_message_loop_(io_message_loop), path_manager_(new FileSystemPathManager( file_message_loop, profile_path, is_incognito, allow_file_access)), quota_manager_(new FileSystemQuotaManager( @@ -28,6 +30,7 @@ SandboxedFileSystemContext::~SandboxedFileSystemContext() { } void SandboxedFileSystemContext::Shutdown() { + DCHECK(io_message_loop_->BelongsToCurrentThread()); path_manager_.reset(); quota_manager_.reset(); } @@ -45,4 +48,22 @@ void SandboxedFileSystemContext::DeleteDataForOriginOnFileThread( file_util::Delete(path_for_origin, true /* recursive */); } +void SandboxedFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) { + DCHECK(io_message_loop_->BelongsToCurrentThread()); + quota_manager()->SetOriginQuotaUnlimited(url); +} + +void SandboxedFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) { + DCHECK(io_message_loop_->BelongsToCurrentThread()); + quota_manager()->ResetOriginQuotaUnlimited(url); +} + +void SandboxedFileSystemContext::DeleteOnCorrectThread() const { + if (!io_message_loop_->BelongsToCurrentThread()) { + io_message_loop_->DeleteSoon(FROM_HERE, this); + return; + } + delete this; +} + } // namespace fileapi diff --git a/webkit/fileapi/sandboxed_file_system_context.h b/webkit/fileapi/sandboxed_file_system_context.h index 6c72bc0..fcb90bb 100644 --- a/webkit/fileapi/sandboxed_file_system_context.h +++ b/webkit/fileapi/sandboxed_file_system_context.h @@ -24,10 +24,13 @@ class SandboxedFileSystemContext; struct DefaultContextDeleter; // This class keeps and provides a sandboxed file system context. -class SandboxedFileSystemContext { +class SandboxedFileSystemContext + : public base::RefCountedThreadSafe<SandboxedFileSystemContext, + DefaultContextDeleter> { public: SandboxedFileSystemContext( scoped_refptr<base::MessageLoopProxy> file_message_loop, + scoped_refptr<base::MessageLoopProxy> io_message_loop, const FilePath& profile_path, bool is_incognito, bool allow_file_access_from_files, @@ -38,6 +41,10 @@ class SandboxedFileSystemContext { void DeleteDataForOriginOnFileThread(const GURL& origin_url); + // Quota related methods. + void SetOriginQuotaUnlimited(const GURL& url); + void ResetOriginQuotaUnlimited(const GURL& url); + FileSystemPathManager* path_manager() { return path_manager_.get(); } FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); } @@ -47,12 +54,19 @@ class SandboxedFileSystemContext { bool allow_file_access_from_files_; scoped_refptr<base::MessageLoopProxy> file_message_loop_; + scoped_refptr<base::MessageLoopProxy> io_message_loop_; scoped_ptr<FileSystemPathManager> path_manager_; scoped_ptr<FileSystemQuotaManager> quota_manager_; DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxedFileSystemContext); }; +struct DefaultContextDeleter { + static void Destruct(const SandboxedFileSystemContext* context) { + context->DeleteOnCorrectThread(); + } +}; + } // namespace fileapi #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ diff --git a/webkit/fileapi/sandboxed_file_system_operation.cc b/webkit/fileapi/sandboxed_file_system_operation.cc index ef7c752..d866512 100644 --- a/webkit/fileapi/sandboxed_file_system_operation.cc +++ b/webkit/fileapi/sandboxed_file_system_operation.cc @@ -15,7 +15,7 @@ namespace fileapi { SandboxedFileSystemOperation::SandboxedFileSystemOperation( FileSystemCallbackDispatcher* dispatcher, scoped_refptr<base::MessageLoopProxy> proxy, - SandboxedFileSystemContext* file_system_context) + scoped_refptr<SandboxedFileSystemContext> file_system_context) : FileSystemOperation(dispatcher, proxy), file_system_context_(file_system_context), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { diff --git a/webkit/fileapi/sandboxed_file_system_operation.h b/webkit/fileapi/sandboxed_file_system_operation.h index c6c905d..d3e1ce9 100644 --- a/webkit/fileapi/sandboxed_file_system_operation.h +++ b/webkit/fileapi/sandboxed_file_system_operation.h @@ -21,14 +21,10 @@ class SandboxedFileSystemContext; // via |file_system_context|. class SandboxedFileSystemOperation : public FileSystemOperation { public: - // This class doesn't hold a reference or ownership of |file_system_context|. - // It is the caller's responsibility to keep the pointer alive *until* - // it calls any of the operation methods. The |file_system_context| won't be - // used in the callback path and can be deleted after the operation is - // made (e.g. after one of CreateFile, CreateDirectory, Copy, etc is called). - SandboxedFileSystemOperation(FileSystemCallbackDispatcher* dispatcher, - scoped_refptr<base::MessageLoopProxy> proxy, - SandboxedFileSystemContext* file_system_context); + SandboxedFileSystemOperation( + FileSystemCallbackDispatcher* dispatcher, + scoped_refptr<base::MessageLoopProxy> proxy, + scoped_refptr<SandboxedFileSystemContext> file_system_context); virtual ~SandboxedFileSystemOperation(); void OpenFileSystem(const GURL& origin_url, @@ -94,8 +90,7 @@ class SandboxedFileSystemOperation : public FileSystemOperation { bool create, int64 growth); - // Not owned. See the comment at the constructor. - SandboxedFileSystemContext* file_system_context_; + scoped_refptr<SandboxedFileSystemContext> file_system_context_; base::ScopedCallbackFactory<SandboxedFileSystemOperation> callback_factory_; diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc index 94269b9..ee8c72c 100644 --- a/webkit/tools/test_shell/simple_file_system.cc +++ b/webkit/tools/test_shell/simple_file_system.cc @@ -5,6 +5,7 @@ #include "webkit/tools/test_shell/simple_file_system.h" #include "base/file_path.h" +#include "base/message_loop.h" #include "base/message_loop_proxy.h" #include "base/scoped_callback_factory.h" #include "base/time.h" @@ -117,12 +118,13 @@ class SimpleFileSystemCallbackDispatcher SimpleFileSystem::SimpleFileSystem() { if (file_system_dir_.CreateUniqueTempDir()) { - sandboxed_context_.reset(new SandboxedFileSystemContext( + sandboxed_context_ = new SandboxedFileSystemContext( + base::MessageLoopProxy::CreateForCurrentThread(), base::MessageLoopProxy::CreateForCurrentThread(), file_system_dir_.path(), false /* incognito */, true /* allow_file_access */, - false /* unlimited_quota */)); + false /* unlimited_quota */); } else { LOG(WARNING) << "Failed to create a temp dir for the filesystem." "FileSystem feature will be disabled."; diff --git a/webkit/tools/test_shell/simple_file_system.h b/webkit/tools/test_shell/simple_file_system.h index 9a6758c..b875a76 100644 --- a/webkit/tools/test_shell/simple_file_system.h +++ b/webkit/tools/test_shell/simple_file_system.h @@ -72,7 +72,7 @@ class SimpleFileSystem // A temporary directory for FileSystem API. ScopedTempDir file_system_dir_; - scoped_ptr<fileapi::SandboxedFileSystemContext> sandboxed_context_; + scoped_refptr<fileapi::SandboxedFileSystemContext> sandboxed_context_; DISALLOW_COPY_AND_ASSIGN(SimpleFileSystem); }; |