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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 921443003: Fix RenderFrameCreated and RenderFrameDeleted WebContentsObserver methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete pending callbacks in ManifestManagerHost destructor. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 render_frame_host_->GetSiteInstance()->GetId()); 80 render_frame_host_->GetSiteInstance()->GetId());
81 } 81 }
82 82
83 // Delete any RenderFrameProxyHosts and swapped out RenderFrameHosts. 83 // Delete any RenderFrameProxyHosts and swapped out RenderFrameHosts.
84 // It is important to delete those prior to deleting the current 84 // It is important to delete those prior to deleting the current
85 // RenderFrameHost, since the CrossProcessFrameConnector (owned by 85 // RenderFrameHost, since the CrossProcessFrameConnector (owned by
86 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with 86 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with
87 // the current RenderFrameHost and uses it during its destructor. 87 // the current RenderFrameHost and uses it during its destructor.
88 STLDeleteValues(&proxy_hosts_); 88 STLDeleteValues(&proxy_hosts_);
89 89
90 // Release the WebUI prior to resetting the current RenderFrameHost, as the
91 // WebUI accesses the RenderFrameHost during cleanup.
92 web_ui_.reset();
93
90 // We should always have a current RenderFrameHost except in some tests. 94 // We should always have a current RenderFrameHost except in some tests.
91 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); 95 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>());
92 } 96 }
93 97
94 void RenderFrameHostManager::Init(BrowserContext* browser_context, 98 void RenderFrameHostManager::Init(BrowserContext* browser_context,
95 SiteInstance* site_instance, 99 SiteInstance* site_instance,
96 int view_routing_id, 100 int view_routing_id,
97 int frame_routing_id) { 101 int frame_routing_id) {
98 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It 102 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It
99 // is important to immediately give this SiteInstance to a RenderViewHost so 103 // is important to immediately give this SiteInstance to a RenderViewHost so
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 } else if (!swapped_out) { 1408 } else if (!swapped_out) {
1405 // Init the RFH, so a RenderFrame is created in the renderer. 1409 // Init the RFH, so a RenderFrame is created in the renderer.
1406 DCHECK(new_render_frame_host.get()); 1410 DCHECK(new_render_frame_host.get());
1407 success = InitRenderFrame(new_render_frame_host.get()); 1411 success = InitRenderFrame(new_render_frame_host.get());
1408 } 1412 }
1409 } 1413 }
1410 1414
1411 if (success) { 1415 if (success) {
1412 if (view_routing_id_ptr) 1416 if (view_routing_id_ptr)
1413 *view_routing_id_ptr = render_view_host->GetRoutingID(); 1417 *view_routing_id_ptr = render_view_host->GetRoutingID();
1414
1415 // A brand new RenderFrame was created by one of the Init calls above.
1416 // Announce it to observers.
1417 if (swapped_out)
1418 render_frame_delegate_->RenderFrameCreated(proxy->render_frame_host());
1419 else
1420 render_frame_delegate_->RenderFrameCreated(new_render_frame_host.get());
1421 } 1418 }
1422 } 1419 }
1423 1420
1424 // Returns the new RFH if it isn't swapped out. 1421 // Returns the new RFH if it isn't swapped out.
1425 if (success && !swapped_out) { 1422 if (success && !swapped_out) {
1426 DCHECK(new_render_frame_host->GetSiteInstance() == instance); 1423 DCHECK(new_render_frame_host->GetSiteInstance() == instance);
1427 return new_render_frame_host.Pass(); 1424 return new_render_frame_host.Pass();
1428 } 1425 }
1429 return nullptr; 1426 return nullptr;
1430 } 1427 }
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1950 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1954 SiteInstance* instance) { 1951 SiteInstance* instance) {
1955 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1952 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1956 if (iter != proxy_hosts_.end()) { 1953 if (iter != proxy_hosts_.end()) {
1957 delete iter->second; 1954 delete iter->second;
1958 proxy_hosts_.erase(iter); 1955 proxy_hosts_.erase(iter);
1959 } 1956 }
1960 } 1957 }
1961 1958
1962 } // namespace content 1959 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/manifest/manifest_manager_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698