summaryrefslogtreecommitdiffstats
path: root/content/browser/storage_partition_impl.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 08:54:34 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-18 08:54:34 +0000
commit4c3a235850730f45ee734eef73e79fe386826950 (patch)
tree953f9688e8bd31fd156178ef3715433cabf8fc61 /content/browser/storage_partition_impl.cc
parent9b4ba94c9d95328e811771e74b8a8bb8580731d8 (diff)
downloadchromium_src-4c3a235850730f45ee734eef73e79fe386826950.zip
chromium_src-4c3a235850730f45ee734eef73e79fe386826950.tar.gz
chromium_src-4c3a235850730f45ee734eef73e79fe386826950.tar.bz2
Move StoragePartition into content/public and remove BrowserContext::GetDOMStorageContext().
Eventually all the storage context accessors will be removed from BrowserContext. Instead, users should retrieve the storage context from the StoragePartition. This also changes RenderProcessHost to take in a StoragePartition removing the need for a re-lookup its storage contexts. BUG=85121,143486 Review URL: https://chromiumcodereview.appspot.com/10837230 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/storage_partition_impl.cc')
-rw-r--r--content/browser/storage_partition_impl.cc126
1 files changed, 126 insertions, 0 deletions
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
new file mode 100644
index 0000000..e906a6a
--- /dev/null
+++ b/content/browser/storage_partition_impl.cc
@@ -0,0 +1,126 @@
+// Copyright (c) 2012 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 "content/browser/storage_partition_impl.h"
+
+#include "content/browser/fileapi/browser_file_system_helper.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "webkit/database/database_tracker.h"
+#include "webkit/quota/quota_manager.h"
+
+namespace content {
+
+StoragePartitionImpl::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)
+ : partition_path_(partition_path),
+ quota_manager_(quota_manager),
+ appcache_service_(appcache_service),
+ filesystem_context_(filesystem_context),
+ database_tracker_(database_tracker),
+ dom_storage_context_(dom_storage_context),
+ indexed_db_context_(indexed_db_context) {
+}
+
+StoragePartitionImpl::~StoragePartitionImpl() {
+ // These message loop checks are just to avoid leaks in unittests.
+ if (GetDatabaseTracker() &&
+ BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&webkit_database::DatabaseTracker::Shutdown,
+ GetDatabaseTracker()));
+ }
+
+ if (GetDOMStorageContext())
+ GetDOMStorageContext()->Shutdown();
+}
+
+// TODO(ajwong): Break the direct dependency on |context|. We only
+// need 3 pieces of info from it.
+StoragePartitionImpl* StoragePartitionImpl::Create(
+ BrowserContext* context,
+ const FilePath& partition_path) {
+ // Ensure that these methods are called on the UI thread, except for
+ // unittests where a UI thread might not have been created.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
+ !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
+
+ // All of the clients have to be created and registered with the
+ // QuotaManager prior to the QuotaManger being used. We do them
+ // all together here prior to handing out a reference to anything
+ // that utilizes the QuotaManager.
+ scoped_refptr<quota::QuotaManager> quota_manager =
+ new quota::QuotaManager(
+ context->IsOffTheRecord(), partition_path,
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
+ context->GetSpecialStoragePolicy());
+
+ // Each consumer is responsible for registering its QuotaClient during
+ // its construction.
+ scoped_refptr<fileapi::FileSystemContext> filesystem_context =
+ CreateFileSystemContext(partition_path, context->IsOffTheRecord(),
+ context->GetSpecialStoragePolicy(),
+ quota_manager->proxy());
+
+ scoped_refptr<webkit_database::DatabaseTracker> database_tracker =
+ new webkit_database::DatabaseTracker(
+ partition_path, context->IsOffTheRecord(),
+ context->GetSpecialStoragePolicy(), quota_manager->proxy(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+
+ FilePath path = context->IsOffTheRecord() ? FilePath() : partition_path;
+ scoped_refptr<DOMStorageContextImpl> dom_storage_context =
+ new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy());
+
+ scoped_refptr<IndexedDBContextImpl> indexed_db_context =
+ new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(),
+ quota_manager->proxy(),
+ BrowserThread::GetMessageLoopProxyForThread(
+ BrowserThread::WEBKIT_DEPRECATED));
+
+ scoped_refptr<ChromeAppCacheService> appcache_service =
+ new ChromeAppCacheService(quota_manager->proxy());
+
+ return new StoragePartitionImpl(partition_path,
+ quota_manager,
+ appcache_service,
+ filesystem_context,
+ database_tracker,
+ dom_storage_context,
+ indexed_db_context);
+}
+
+quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() {
+ return quota_manager_;
+}
+
+ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() {
+ return appcache_service_;
+}
+
+fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() {
+ return filesystem_context_;
+}
+
+webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() {
+ return database_tracker_;
+}
+
+DOMStorageContextImpl* StoragePartitionImpl::GetDOMStorageContext() {
+ return dom_storage_context_;
+}
+
+IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
+ return indexed_db_context_;
+}
+
+} // namespace content