summaryrefslogtreecommitdiffstats
path: root/content/browser/resource_context_impl.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 03:57:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 03:57:42 +0000
commit314c3e2d86a4595db7b1ab02b2acd4decf21d65f (patch)
tree593431d4dad2fa3c944d8e8f97da3f6fc56140f6 /content/browser/resource_context_impl.cc
parentc537090136d23d0064488c27de3bb2ba0f1ac120 (diff)
downloadchromium_src-314c3e2d86a4595db7b1ab02b2acd4decf21d65f.zip
chromium_src-314c3e2d86a4595db7b1ab02b2acd4decf21d65f.tar.gz
chromium_src-314c3e2d86a4595db7b1ab02b2acd4decf21d65f.tar.bz2
Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't used by chrome, so they can be hidden from chrome. The rest were accessed by chrome, but we don't need every embedder to store this data on their ResourceContext implementation. Instead have content associate the data itself to simplify the work for embedders.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9425026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/resource_context_impl.cc')
-rw-r--r--content/browser/resource_context_impl.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc
new file mode 100644
index 0000000..d7cbeab
--- /dev/null
+++ b/content/browser/resource_context_impl.cc
@@ -0,0 +1,92 @@
+// 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/resource_context_impl.h"
+
+#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/browser/chrome_blob_storage_context.h"
+#include "content/browser/file_system/browser_file_system_helper.h"
+#include "content/browser/in_process_webkit/webkit_context.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "webkit/database/database_tracker.h"
+
+// Key names on ResourceContext.
+static const char* kAppCacheServicKeyName = "content_appcache_service_tracker";
+static const char* kBlobStorageContextKeyName = "content_blob_storage_context";
+static const char* kDatabaseTrackerKeyName = "content_database_tracker";
+static const char* kFileSystemContextKeyName = "content_file_system_context";
+static const char* kWebKitContextKeyName = "content_webkit_context";
+
+using appcache::AppCacheService;
+using base::UserDataAdapter;
+using content::BrowserThread;
+using fileapi::FileSystemContext;
+using webkit_blob::BlobStorageController;
+using webkit_database::DatabaseTracker;
+
+namespace content {
+
+AppCacheService* ResourceContext::GetAppCacheService(ResourceContext* context) {
+ return UserDataAdapter<ChromeAppCacheService>::Get(
+ context, kAppCacheServicKeyName);
+}
+
+FileSystemContext* ResourceContext::GetFileSystemContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<FileSystemContext>::Get(
+ resource_context, kFileSystemContextKeyName);
+}
+
+BlobStorageController* ResourceContext::GetBlobStorageController(
+ ResourceContext* resource_context) {
+ return GetChromeBlobStorageContextForResourceContext(resource_context)->
+ controller();
+}
+
+DatabaseTracker* GetDatabaseTrackerForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<DatabaseTracker>::Get(
+ resource_context, kDatabaseTrackerKeyName);
+}
+
+WebKitContext* GetWebKitContextForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<WebKitContext>::Get(
+ resource_context, kWebKitContextKeyName);
+}
+
+ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext(
+ ResourceContext* resource_context) {
+ return UserDataAdapter<ChromeBlobStorageContext>::Get(
+ resource_context, kBlobStorageContextKeyName);
+}
+
+void InitializeResourceContext(BrowserContext* browser_context) {
+ ResourceContext* resource_context = browser_context->GetResourceContext();
+ DCHECK(!resource_context->GetUserData(kWebKitContextKeyName));
+ resource_context->SetUserData(
+ kWebKitContextKeyName,
+ new UserDataAdapter<WebKitContext>(
+ BrowserContext::GetWebKitContext(browser_context)));
+ resource_context->SetUserData(
+ kDatabaseTrackerKeyName,
+ new UserDataAdapter<webkit_database::DatabaseTracker>(
+ BrowserContext::GetDatabaseTracker(browser_context)));
+ resource_context->SetUserData(
+ kAppCacheServicKeyName,
+ new UserDataAdapter<ChromeAppCacheService>(
+ static_cast<ChromeAppCacheService*>(
+ BrowserContext::GetAppCacheService(browser_context))));
+ resource_context->SetUserData(
+ kFileSystemContextKeyName,
+ new UserDataAdapter<FileSystemContext>(
+ BrowserContext::GetFileSystemContext(browser_context)));
+ resource_context->SetUserData(
+ kBlobStorageContextKeyName,
+ new UserDataAdapter<ChromeBlobStorageContext>(
+ ChromeBlobStorageContext::GetFor(browser_context)));
+}
+
+} // namespace content