diff options
12 files changed, 58 insertions, 41 deletions
diff --git a/chrome/browser/browsing_data/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data/browsing_data_indexed_db_helper.cc index 823c4878..12588af 100644 --- a/chrome/browser/browsing_data/browsing_data_indexed_db_helper.cc +++ b/chrome/browser/browsing_data/browsing_data_indexed_db_helper.cc @@ -13,13 +13,11 @@ #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 "content/public/browser/indexed_db_context.h" #include "webkit/database/database_util.h" #include "webkit/glue/webkit_glue.h" -using content::BrowserContext; using content::BrowserThread; using content::IndexedDBContext; using webkit_database::DatabaseUtil; @@ -28,7 +26,8 @@ namespace { class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { public: - explicit BrowsingDataIndexedDBHelperImpl(Profile* profile); + explicit BrowsingDataIndexedDBHelperImpl( + IndexedDBContext* indexed_db_context); virtual void StartFetching( const base::Callback<void(const std::list<IndexedDBInfo>&)>& @@ -68,8 +67,8 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { }; BrowsingDataIndexedDBHelperImpl::BrowsingDataIndexedDBHelperImpl( - Profile* profile) - : indexed_db_context_(BrowserContext::GetIndexedDBContext(profile)), + IndexedDBContext* indexed_db_context) + : indexed_db_context_(indexed_db_context), is_fetching_(false) { DCHECK(indexed_db_context_.get()); } @@ -151,8 +150,8 @@ BrowsingDataIndexedDBHelper::IndexedDBInfo::~IndexedDBInfo() {} // static BrowsingDataIndexedDBHelper* BrowsingDataIndexedDBHelper::Create( - Profile* profile) { - return new BrowsingDataIndexedDBHelperImpl(profile); + IndexedDBContext* indexed_db_context) { + return new BrowsingDataIndexedDBHelperImpl(indexed_db_context); } CannedBrowsingDataIndexedDBHelper:: diff --git a/chrome/browser/browsing_data/browsing_data_indexed_db_helper.h b/chrome/browser/browsing_data/browsing_data_indexed_db_helper.h index de0504c..35a2f1f 100644 --- a/chrome/browser/browsing_data/browsing_data_indexed_db_helper.h +++ b/chrome/browser/browsing_data/browsing_data_indexed_db_helper.h @@ -19,6 +19,10 @@ class Profile; +namespace content { +class IndexedDBContext; +} + // BrowsingDataIndexedDBHelper is an interface for classes dealing with // aggregating and deleting browsing data stored in indexed databases. A // client of this class need to call StartFetching from the UI thread to @@ -42,7 +46,8 @@ class BrowsingDataIndexedDBHelper // Create a BrowsingDataIndexedDBHelper instance for the indexed databases // stored in |profile|'s user data directory. - static BrowsingDataIndexedDBHelper* Create(Profile* profile); + static BrowsingDataIndexedDBHelper* Create( + content::IndexedDBContext* context); // Starts the fetching process, which will notify its completion via // callback. diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc index 38c3775..9ce58a8 100644 --- a/chrome/browser/extensions/data_deleter.cc +++ b/chrome/browser/extensions/data_deleter.cc @@ -54,8 +54,7 @@ void DataDeleter::StartDeleting(Profile* profile, BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind( &DataDeleter::DeleteIndexedDBOnWebkitThread, - deleter, - make_scoped_refptr(BrowserContext::GetIndexedDBContext(profile)))); + deleter)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, @@ -88,6 +87,8 @@ DataDeleter::DataDeleter( GetDatabaseTracker(); // Pick the right request context depending on whether it's an extension, // isolated app, or regular app. + content::StoragePartition* storage_partition = + BrowserContext::GetDefaultStoragePartition(profile); if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { extension_request_context_ = profile->GetRequestContextForExtensions(); } else if (is_storage_isolated) { @@ -99,7 +100,10 @@ DataDeleter::DataDeleter( } else { extension_request_context_ = profile->GetRequestContext(); } + file_system_context_ = BrowserContext::GetFileSystemContext(profile); + indexed_db_context_ = storage_partition->GetIndexedDBContext(); + storage_origin_ = storage_origin; origin_id_ = webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_); @@ -125,10 +129,9 @@ void DataDeleter::DeleteDatabaseOnFileThread() { DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING); } -void DataDeleter::DeleteIndexedDBOnWebkitThread( - scoped_refptr<IndexedDBContext> indexed_db_context) { +void DataDeleter::DeleteIndexedDBOnWebkitThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); - indexed_db_context->DeleteForOrigin(storage_origin_); + indexed_db_context_->DeleteForOrigin(storage_origin_); } void DataDeleter::DeleteFileSystemOnFileThread() { diff --git a/chrome/browser/extensions/data_deleter.h b/chrome/browser/extensions/data_deleter.h index 6a87c3c..25b942d 100644 --- a/chrome/browser/extensions/data_deleter.h +++ b/chrome/browser/extensions/data_deleter.h @@ -74,8 +74,7 @@ class DataDeleter : public base::RefCountedThreadSafe< // Deletes indexed db files for the extension. May only be called on the // webkit thread. - void DeleteIndexedDBOnWebkitThread( - scoped_refptr<content::IndexedDBContext> indexed_db_context); + void DeleteIndexedDBOnWebkitThread(); // Deletes filesystem files for the extension. May only be called on the // file thread. @@ -102,6 +101,8 @@ class DataDeleter : public base::RefCountedThreadSafe< scoped_refptr<fileapi::FileSystemContext> file_system_context_; + scoped_refptr<content::IndexedDBContext> indexed_db_context_; + // If non-empty, the extension we're deleting is an isolated app, and this // is its directory which we should delete. FilePath isolated_app_path_; diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index 32adcc9..9e650c1 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -3626,8 +3626,9 @@ TEST_F(ExtensionServiceTest, ClearExtensionData) { // Create indexed db. Similarly, it is enough to only simulate this by // creating the directory on the disk. - IndexedDBContext* idb_context = BrowserContext::GetIndexedDBContext( - profile_.get()); + IndexedDBContext* idb_context = + BrowserContext::GetDefaultStoragePartition(profile_.get())-> + GetIndexedDBContext(); FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); EXPECT_TRUE(file_util::CreateDirectory(idb_path)); EXPECT_TRUE(file_util::DirectoryExists(idb_path)); @@ -3738,8 +3739,9 @@ TEST_F(ExtensionServiceTest, ClearAppData) { // Create indexed db. Similarly, it is enough to only simulate this by // creating the directory on the disk. - IndexedDBContext* idb_context = BrowserContext::GetIndexedDBContext( - profile_.get()); + IndexedDBContext* idb_context = + BrowserContext::GetDefaultStoragePartition(profile_.get())-> + GetIndexedDBContext(); FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); EXPECT_TRUE(file_util::CreateDirectory(idb_path)); EXPECT_TRUE(file_util::DirectoryExists(idb_path)); diff --git a/chrome/browser/ui/webui/options/cookies_view_handler.cc b/chrome/browser/ui/webui/options/cookies_view_handler.cc index 8bf447d0..6cb5721 100644 --- a/chrome/browser/ui/webui/options/cookies_view_handler.cc +++ b/chrome/browser/ui/webui/options/cookies_view_handler.cc @@ -24,6 +24,8 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/cookies_tree_model_util.h" +#include "content/public/browser/browser_context.h" +#include "content/public/browser/storage_partition.h" #include "content/public/browser/web_ui.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -188,6 +190,10 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { if (!app_context_ && !cookies_tree_model_.get()) { Profile* profile = Profile::FromWebUI(web_ui()); ContainerMap apps_map; + content::StoragePartition* storage_partition = + content::BrowserContext::GetDefaultStoragePartition(profile); + content::IndexedDBContext* indexed_db_context = + storage_partition->GetIndexedDBContext(); apps_map[std::string()] = new LocalDataContainer( "Site Data", std::string(), new BrowsingDataCookieHelper(profile->GetRequestContext()), @@ -195,7 +201,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { new BrowsingDataLocalStorageHelper(profile), NULL, new BrowsingDataAppCacheHelper(profile), - BrowsingDataIndexedDBHelper::Create(profile), + BrowsingDataIndexedDBHelper::Create(indexed_db_context), BrowsingDataFileSystemHelper::Create(profile), BrowsingDataQuotaHelper::Create(profile), BrowsingDataServerBoundCertHelper::Create(profile), diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc index 8e4c9b75..3b33c31 100644 --- a/content/browser/browser_context.cc +++ b/content/browser/browser_context.cc @@ -103,13 +103,6 @@ DownloadManager* BrowserContext::GetDownloadManager( context, kDownloadManagerKeyName); } -IndexedDBContext* BrowserContext::GetIndexedDBContext( - BrowserContext* browser_context) { - // TODO(ajwong): Change this API to require a SiteInstance instead of - // using GetDefaultStoragePartition(). - return GetDefaultStoragePartition(browser_context)->GetIndexedDBContext(); -} - fileapi::FileSystemContext* BrowserContext::GetFileSystemContext( BrowserContext* browser_context) { // TODO(ajwong): Change this API to require a SiteInstance instead of @@ -173,6 +166,8 @@ void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { void BrowserContext::SaveSessionState(BrowserContext* browser_context) { GetDefaultStoragePartition(browser_context)->GetDatabaseTracker()-> SetForceKeepSessionState(); + StoragePartition* storage_partition = + BrowserContext::GetDefaultStoragePartition(browser_context); if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { BrowserThread::PostTask( @@ -180,18 +175,17 @@ void BrowserContext::SaveSessionState(BrowserContext* browser_context) { base::Bind( &SaveSessionStateOnIOThread, make_scoped_refptr(browser_context->GetRequestContext()), - BrowserContext::GetDefaultStoragePartition(browser_context)-> - GetAppCacheService())); + storage_partition->GetAppCacheService())); } DOMStorageContextImpl* dom_storage_context_impl = static_cast<DOMStorageContextImpl*>( - GetDefaultStoragePartition(browser_context)->GetDOMStorageContext()); + storage_partition->GetDOMStorageContext()); dom_storage_context_impl->SetForceKeepSessionState(); if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( - GetIndexedDBContext(browser_context)); + storage_partition->GetIndexedDBContext()); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind(&SaveSessionStateOnWebkitThread, diff --git a/content/browser/in_process_webkit/indexed_db_browsertest.cc b/content/browser/in_process_webkit/indexed_db_browsertest.cc index 71a50f5..2f00a8b 100644 --- a/content/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/content/browser/in_process_webkit/indexed_db_browsertest.cc @@ -194,8 +194,9 @@ class IndexedDBBrowserTestWithVersion0Schema : public IndexedDBBrowserTest { public: virtual void SetUpOnMainThread() { scoped_refptr<IndexedDBContext> context = - BrowserContext::GetIndexedDBContext( - shell()->web_contents()->GetBrowserContext()); + BrowserContext::GetDefaultStoragePartition( + shell()->web_contents()->GetBrowserContext())-> + GetIndexedDBContext(); BrowserThread::PostTask( BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, base::Bind( diff --git a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc index 9ba83b1..37a60f4 100644 --- a/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc +++ b/content/browser/in_process_webkit/indexed_db_quota_client_unittest.cc @@ -13,6 +13,7 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.h" #include "content/browser/in_process_webkit/indexed_db_quota_client.h" +#include "content/public/browser/storage_partition.h" #include "content/public/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/database/database_util.h" @@ -49,7 +50,8 @@ class IndexedDBQuotaClientTest : public testing::Test { io_thread_(BrowserThread::IO, &message_loop_) { browser_context_.reset(new content::TestBrowserContext()); idb_context_ = static_cast<IndexedDBContextImpl*>( - BrowserContext::GetIndexedDBContext(browser_context_.get())); + BrowserContext::GetDefaultStoragePartition(browser_context_.get())-> + GetIndexedDBContext()); message_loop_.RunAllPending(); setup_temp_dir(); } diff --git a/content/browser/in_process_webkit/indexed_db_unittest.cc b/content/browser/in_process_webkit/indexed_db_unittest.cc index 05d74c5..89b3e92a 100644 --- a/content/browser/in_process_webkit/indexed_db_unittest.cc +++ b/content/browser/in_process_webkit/indexed_db_unittest.cc @@ -6,6 +6,7 @@ #include "base/scoped_temp_dir.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/in_process_webkit/indexed_db_context_impl.h" +#include "content/public/browser/storage_partition.h" #include "content/public/common/url_constants.h" #include "content/public/test/test_browser_context.h" #include "testing/gtest/include/gtest/gtest.h" @@ -60,7 +61,8 @@ TEST_F(IndexedDBTest, ClearSessionOnlyDatabases) { // With the levelDB backend, these are directories. IndexedDBContextImpl* idb_context = static_cast<IndexedDBContextImpl*>( - BrowserContext::GetIndexedDBContext(&browser_context)); + BrowserContext::GetDefaultStoragePartition(&browser_context)-> + GetIndexedDBContext()); // Override the storage policy with our own. idb_context->special_storage_policy_ = special_storage_policy; @@ -103,7 +105,8 @@ TEST_F(IndexedDBTest, SetForceKeepSessionState) { // With the levelDB backend, these are directories. IndexedDBContextImpl* idb_context = static_cast<IndexedDBContextImpl*>( - BrowserContext::GetIndexedDBContext(&browser_context)); + BrowserContext::GetDefaultStoragePartition(&browser_context)-> + GetIndexedDBContext()); // Override the storage policy with our own. idb_context->special_storage_policy_ = special_storage_policy; @@ -168,7 +171,8 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) { IndexedDBContextImpl* idb_context = static_cast<IndexedDBContextImpl*>( - BrowserContext::GetIndexedDBContext(&browser_context)); + BrowserContext::GetDefaultStoragePartition(&browser_context)-> + GetIndexedDBContext()); idb_context->quota_manager_proxy_ = NULL; idb_context->set_data_path_for_testing(temp_dir.path()); diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 458754b..8ea4adf 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -549,9 +549,10 @@ void RenderProcessHostImpl::CreateMessageFilters() { new DOMStorageMessageFilter( GetID(), storage_partition_impl_->GetDOMStorageContext())); - channel_->AddFilter(new IndexedDBDispatcherHost(GetID(), - static_cast<IndexedDBContextImpl*>( - BrowserContext::GetIndexedDBContext(browser_context)))); + channel_->AddFilter( + new IndexedDBDispatcherHost( + GetID(), + storage_partition_impl_->GetIndexedDBContext())); channel_->AddFilter(GeolocationDispatcherHost::New( GetID(), browser_context->GetGeolocationPermissionContext())); gpu_message_filter_ = new GpuMessageFilter(GetID(), widget_helper_.get()); diff --git a/content/public/browser/browser_context.h b/content/public/browser/browser_context.h index 4258125..275ad42 100644 --- a/content/public/browser/browser_context.h +++ b/content/public/browser/browser_context.h @@ -47,7 +47,6 @@ class CONTENT_EXPORT BrowserContext : public base::SupportsUserData { StoragePartitionCallback; static DownloadManager* GetDownloadManager(BrowserContext* browser_context); - static IndexedDBContext* GetIndexedDBContext(BrowserContext* browser_context); static fileapi::FileSystemContext* GetFileSystemContext( BrowserContext* browser_context); |