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

Unified Diff: content/browser/host_zoom_map_observer.cc

Issue 2581143002: Maintain HostZoom connection per-frame on browser side (Closed)
Patch Set: Handle unittest Created 4 years 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_observer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/host_zoom_map_observer.cc
diff --git a/content/browser/host_zoom_map_observer.cc b/content/browser/host_zoom_map_observer.cc
index 88d42dfb6b825f27965b4206b8cf3f5e40ddb139..2c2d2af66ad3c0fe38bd5f9490569c2874e1cc4a 100644
--- a/content/browser/host_zoom_map_observer.cc
+++ b/content/browser/host_zoom_map_observer.cc
@@ -23,23 +23,40 @@ void HostZoomMapObserver::ReadyToCommitNavigation(
if (!navigation_handle->IsInMainFrame())
return;
- DCHECK(host_zoom_.is_bound());
- if (!host_zoom_.is_bound())
- return;
-
RenderFrameHost* render_frame_host =
navigation_handle->GetRenderFrameHost();
+ const auto& entry = host_zoom_ptrs_.find(render_frame_host);
+ if (entry == host_zoom_ptrs_.end())
+ return;
+
+ const mojom::HostZoomAssociatedPtr& host_zoom = entry->second;
+ DCHECK(host_zoom.is_bound());
+ DCHECK(!host_zoom.encountered_error());
+
RenderProcessHost* render_process_host = render_frame_host->GetProcess();
HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
render_process_host->GetStoragePartition()->GetHostZoomMap());
double zoom_level = host_zoom_map->GetZoomLevelForView(
navigation_handle->GetURL(), render_process_host->GetID(),
render_frame_host->GetRenderViewHost()->GetRoutingID());
- host_zoom_->SetHostZoomLevel(navigation_handle->GetURL(), zoom_level);
+ host_zoom->SetHostZoomLevel(navigation_handle->GetURL(), zoom_level);
}
void HostZoomMapObserver::RenderFrameCreated(RenderFrameHost* rfh) {
- rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom_);
+ mojom::HostZoomAssociatedPtr host_zoom;
+ rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom);
+ host_zoom.set_connection_error_handler(
+ base::Bind(&HostZoomMapObserver::OnConnectionError,
+ base::Unretained(this), base::Unretained(rfh)));
+ host_zoom_ptrs_[rfh] = std::move(host_zoom);
+}
+
+void HostZoomMapObserver::OnConnectionError(RenderFrameHost* rfh) {
+ // NOTE: It is not safe to do anything with |rfh| other than use it as a
+ // key here.
wjmaclean 2016/12/16 14:45:35 Presumably this is on account of a rfh being delet
ncarter (slow) 2016/12/16 18:21:12 The scenario wjmaclean describes seems plausible.
blundell 2016/12/19 17:03:14 Changed. For my own curiosity: the case where this
ncarter (slow) 2016/12/19 19:21:16 I would hope we don't do ReadyToCommitNavigation o
+ const auto& entry = host_zoom_ptrs_.find(rfh);
+ DCHECK(entry != host_zoom_ptrs_.end());
+ host_zoom_ptrs_.erase(entry);
}
} // namespace content
« no previous file with comments | « content/browser/host_zoom_map_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698