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

Unified Diff: content/browser/host_zoom_map_impl.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments; patch for landing. Created 6 years, 1 month 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/host_zoom_map_impl.h ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/host_zoom_map_impl.cc
diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc
index 81f8182924d58d4d7700b3e072a914cd3c572d4d..b6595b97bd1de766c53569d57591f1bef0d728e2 100644
--- a/content/browser/host_zoom_map_impl.cc
+++ b/content/browser/host_zoom_map_impl.cc
@@ -20,6 +20,8 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/resource_context.h"
+#include "content/public/browser/site_instance.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/url_constants.h"
#include "net/base/net_util.h"
@@ -28,8 +30,6 @@ namespace content {
namespace {
-const char kHostZoomMapKeyName[] = "content_host_zoom_map";
-
std::string GetHostFromProcessView(int render_process_id, int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
RenderViewHost* render_view_host =
@@ -61,29 +61,39 @@ GURL HostZoomMap::GetURLFromEntry(const NavigationEntry* entry) {
}
HostZoomMap* HostZoomMap::GetDefaultForBrowserContext(BrowserContext* context) {
- HostZoomMapImpl* rv = static_cast<HostZoomMapImpl*>(
- context->GetUserData(kHostZoomMapKeyName));
- if (!rv) {
- rv = new HostZoomMapImpl();
- context->SetUserData(kHostZoomMapKeyName, rv);
- }
- return rv;
+ StoragePartition* partition =
+ BrowserContext::GetDefaultStoragePartition(context);
+ DCHECK(partition);
+ return partition->GetHostZoomMap();
+}
+
+HostZoomMap* HostZoomMap::Get(SiteInstance* instance) {
+ StoragePartition* partition = BrowserContext::GetStoragePartition(
+ instance->GetBrowserContext(), instance);
+ DCHECK(partition);
+ return partition->GetHostZoomMap();
+}
+
+HostZoomMap* HostZoomMap::GetForWebContents(const WebContents* contents) {
+ StoragePartition* partition =
+ BrowserContext::GetStoragePartition(contents->GetBrowserContext(),
+ contents->GetSiteInstance());
+ DCHECK(partition);
+ return partition->GetHostZoomMap();
}
// Helper function for setting/getting zoom levels for WebContents without
// having to import HostZoomMapImpl everywhere.
double HostZoomMap::GetZoomLevel(const WebContents* web_contents) {
- HostZoomMapImpl* host_zoom_map =
- static_cast<HostZoomMapImpl*>(HostZoomMap::GetDefaultForBrowserContext(
- web_contents->GetBrowserContext()));
+ HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
+ HostZoomMap::GetForWebContents(web_contents));
return host_zoom_map->GetZoomLevelForWebContents(
*static_cast<const WebContentsImpl*>(web_contents));
}
void HostZoomMap::SetZoomLevel(const WebContents* web_contents, double level) {
- HostZoomMapImpl* host_zoom_map =
- static_cast<HostZoomMapImpl*>(HostZoomMap::GetDefaultForBrowserContext(
- web_contents->GetBrowserContext()));
+ HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
+ HostZoomMap::GetForWebContents(web_contents));
host_zoom_map->SetZoomLevelForWebContents(
*static_cast<const WebContentsImpl*>(web_contents), level);
}
@@ -243,10 +253,12 @@ void HostZoomMapImpl::SetZoomLevelForHostAndScheme(const std::string& scheme,
}
double HostZoomMapImpl::GetDefaultZoomLevel() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
return default_zoom_level_;
}
void HostZoomMapImpl::SetDefaultZoomLevel(double level) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
default_zoom_level_ = level;
}
@@ -396,8 +408,10 @@ void HostZoomMapImpl::SendZoomLevelChange(const std::string& scheme,
for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
RenderProcessHost* render_process_host = i.GetCurrentValue();
- if (HostZoomMap::GetDefaultForBrowserContext(
- render_process_host->GetBrowserContext()) == this) {
+ // TODO(wjmaclean) This will need to be cleaned up when
+ // RenderProcessHost::GetStoragePartition() goes away. Perhaps have
+ // RenderProcessHost expose a GetHostZoomMap() function?
+ if (render_process_host->GetStoragePartition()->GetHostZoomMap() == this) {
render_process_host->Send(
new ViewMsg_SetZoomLevelForCurrentURL(scheme, host, level));
}
@@ -413,6 +427,7 @@ void HostZoomMapImpl::SendErrorPageZoomLevelRefresh() {
}
HostZoomMapImpl::~HostZoomMapImpl() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
} // namespace content
« no previous file with comments | « content/browser/host_zoom_map_impl.h ('k') | content/browser/loader/async_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698