Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Unified Diff: content/browser/resource_context_impl.cc

Issue 9416070: Move creation and ownership of HostZoomMap to content instead of having every embedder do this. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac/cros browsertests Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/resource_context_impl.h ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/resource_context_impl.cc
===================================================================
--- content/browser/resource_context_impl.cc (revision 122827)
+++ content/browser/resource_context_impl.cc (working copy)
@@ -8,6 +8,7 @@
#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/browser/host_zoom_map_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "webkit/database/database_tracker.h"
@@ -17,6 +18,7 @@
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* kHostZoomMapKeyName = "content_host_zoom_map";
static const char* kWebKitContextKeyName = "content_webkit_context";
using appcache::AppCacheService;
@@ -28,6 +30,15 @@
namespace content {
+class NonOwningZoomData : public base::SupportsUserData::Data {
+ public:
+ explicit NonOwningZoomData(HostZoomMap* hzm) : host_zoom_map_(hzm) {}
+ HostZoomMap* host_zoom_map() { return host_zoom_map_; }
+
+ private:
+ HostZoomMap* host_zoom_map_;
+};
+
AppCacheService* ResourceContext::GetAppCacheService(ResourceContext* context) {
return UserDataAdapter<ChromeAppCacheService>::Get(
context, kAppCacheServicKeyName);
@@ -63,6 +74,11 @@
resource_context, kBlobStorageContextKeyName);
}
+HostZoomMap* GetHostZoomMapForResourceContext(ResourceContext* context) {
+ return static_cast<NonOwningZoomData*>(
+ context->GetUserData(kHostZoomMapKeyName))->host_zoom_map();
+}
+
void InitializeResourceContext(BrowserContext* browser_context) {
ResourceContext* resource_context = browser_context->GetResourceContext();
DCHECK(!resource_context->GetUserData(kWebKitContextKeyName));
@@ -87,6 +103,13 @@
kBlobStorageContextKeyName,
new UserDataAdapter<ChromeBlobStorageContext>(
ChromeBlobStorageContext::GetFor(browser_context)));
+
+ // This object is owned by the BrowserContext and not ResourceContext, so
+ // store a non-owning pointer here.
+ resource_context->SetUserData(
+ kHostZoomMapKeyName,
+ new NonOwningZoomData(
+ HostZoomMap::GetForBrowserContext(browser_context)));
}
} // namespace content
« no previous file with comments | « content/browser/resource_context_impl.h ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698