Chromium Code Reviews| 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 |