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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1149793002: Detach old frame on WebFrame::swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renaming enum Created 5 years, 6 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 118 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
119 #include "net/http/http_util.h" 119 #include "net/http/http_util.h"
120 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 120 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
121 #include "third_party/WebKit/public/platform/WebString.h" 121 #include "third_party/WebKit/public/platform/WebString.h"
122 #include "third_party/WebKit/public/platform/WebURL.h" 122 #include "third_party/WebKit/public/platform/WebURL.h"
123 #include "third_party/WebKit/public/platform/WebURLError.h" 123 #include "third_party/WebKit/public/platform/WebURLError.h"
124 #include "third_party/WebKit/public/platform/WebURLResponse.h" 124 #include "third_party/WebKit/public/platform/WebURLResponse.h"
125 #include "third_party/WebKit/public/platform/WebVector.h" 125 #include "third_party/WebKit/public/platform/WebVector.h"
126 #include "third_party/WebKit/public/web/WebColorSuggestion.h" 126 #include "third_party/WebKit/public/web/WebColorSuggestion.h"
127 #include "third_party/WebKit/public/web/WebDocument.h" 127 #include "third_party/WebKit/public/web/WebDocument.h"
128 #include "third_party/WebKit/public/web/WebFrameClient.h"
dcheng 2015/06/01 21:15:54 You shouldn't need this include, since it should a
lfg 2015/06/01 21:34:19 Done.
128 #include "third_party/WebKit/public/web/WebFrameWidget.h" 129 #include "third_party/WebKit/public/web/WebFrameWidget.h"
129 #include "third_party/WebKit/public/web/WebGlyphCache.h" 130 #include "third_party/WebKit/public/web/WebGlyphCache.h"
130 #include "third_party/WebKit/public/web/WebKit.h" 131 #include "third_party/WebKit/public/web/WebKit.h"
131 #include "third_party/WebKit/public/web/WebLocalFrame.h" 132 #include "third_party/WebKit/public/web/WebLocalFrame.h"
132 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" 133 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h"
133 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" 134 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
134 #include "third_party/WebKit/public/web/WebPlugin.h" 135 #include "third_party/WebKit/public/web/WebPlugin.h"
135 #include "third_party/WebKit/public/web/WebPluginParams.h" 136 #include "third_party/WebKit/public/web/WebPluginParams.h"
136 #include "third_party/WebKit/public/web/WebPluginPlaceholder.h" 137 #include "third_party/WebKit/public/web/WebPluginPlaceholder.h"
137 #include "third_party/WebKit/public/web/WebRange.h" 138 #include "third_party/WebKit/public/web/WebRange.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (contains_media_player_) 686 if (contains_media_player_)
686 render_view_->UnregisterVideoHoleFrame(this); 687 render_view_->UnregisterVideoHoleFrame(this);
687 #endif 688 #endif
688 689
689 if (!is_subframe_) { 690 if (!is_subframe_) {
690 // RenderFrameProxy is "owned" by RenderFrameImpl in the case it is 691 // RenderFrameProxy is "owned" by RenderFrameImpl in the case it is
691 // the main frame. Ensure it is deleted along with this object. 692 // the main frame. Ensure it is deleted along with this object.
692 if (render_frame_proxy_) { 693 if (render_frame_proxy_) {
693 // The following method calls back into this object and clears 694 // The following method calls back into this object and clears
694 // |render_frame_proxy_|. 695 // |render_frame_proxy_|.
695 render_frame_proxy_->frameDetached(); 696 render_frame_proxy_->frameDetached(
697 blink::WebRemoteFrameClient::DetachType::Remove);
696 } 698 }
697 699
698 // Ensure the RenderView doesn't point to this object, once it is destroyed. 700 // Ensure the RenderView doesn't point to this object, once it is destroyed.
699 CHECK_EQ(render_view_->main_render_frame_, this); 701 CHECK_EQ(render_view_->main_render_frame_, this);
700 render_view_->main_render_frame_ = nullptr; 702 render_view_->main_render_frame_ = nullptr;
701 } 703 }
702 704
703 render_view_->UnregisterRenderFrame(this); 705 render_view_->UnregisterRenderFrame(this);
704 g_routing_id_frame_map.Get().erase(routing_id_); 706 g_routing_id_frame_map.Get().erase(routing_id_);
705 RenderThread::Get()->RemoveRoute(routing_id_); 707 RenderThread::Get()->RemoveRoute(routing_id_);
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 // opener after hearing about it from the browser, and the browser does not 2115 // opener after hearing about it from the browser, and the browser does not
2114 // (yet) care about subframe openers. 2116 // (yet) care about subframe openers.
2115 if (is_swapped_out_ || frame->parent()) 2117 if (is_swapped_out_ || frame->parent())
2116 return; 2118 return;
2117 2119
2118 // Notify WebContents and all its swapped out RenderViews. 2120 // Notify WebContents and all its swapped out RenderViews.
2119 Send(new FrameHostMsg_DidDisownOpener(routing_id_)); 2121 Send(new FrameHostMsg_DidDisownOpener(routing_id_));
2120 } 2122 }
2121 2123
2122 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { 2124 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) {
2125 frameDetached(frame, blink::WebFrameClient::DetachType::Remove);
2126 }
2127
2128 void RenderFrameImpl::frameDetached(
2129 blink::WebFrame* frame,
2130 blink::WebFrameClient::DetachType type) {
2123 // NOTE: This function is called on the frame that is being detached and not 2131 // NOTE: This function is called on the frame that is being detached and not
2124 // the parent frame. This is different from createChildFrame() which is 2132 // the parent frame. This is different from createChildFrame() which is
2125 // called on the parent frame. 2133 // called on the parent frame.
2126 CHECK(!is_detaching_); 2134 CHECK(!is_detaching_);
2127 DCHECK(!frame_ || frame_ == frame); 2135 DCHECK(!frame_ || frame_ == frame);
2128 2136
2129 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached()); 2137 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached());
2130 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2138 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2131 FrameDetached(frame)); 2139 FrameDetached(frame));
2132 2140
2133 Send(new FrameHostMsg_Detach(routing_id_)); 2141 if (type == blink::WebFrameClient::DetachType::Remove)
2142 Send(new FrameHostMsg_Detach(routing_id_));
2134 2143
2135 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be 2144 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be
2136 // sent before setting |is_detaching_| to true. 2145 // sent before setting |is_detaching_| to true.
2137 is_detaching_ = true; 2146 is_detaching_ = true;
2138 2147
2139 // We need to clean up subframes by removing them from the map and deleting 2148 // We need to clean up subframes by removing them from the map and deleting
2140 // the RenderFrameImpl. In contrast, the main frame is owned by its 2149 // the RenderFrameImpl. In contrast, the main frame is owned by its
2141 // containing RenderViewHost (so that they have the same lifetime), so only 2150 // containing RenderViewHost (so that they have the same lifetime), so only
2142 // removal from the map is needed and no deletion. 2151 // removal from the map is needed and no deletion.
2143 FrameMap::iterator it = g_frame_map.Get().find(frame); 2152 FrameMap::iterator it = g_frame_map.Get().find(frame);
2144 CHECK(it != g_frame_map.Get().end()); 2153 CHECK(it != g_frame_map.Get().end());
2145 CHECK_EQ(it->second, this); 2154 CHECK_EQ(it->second, this);
2146 g_frame_map.Get().erase(it); 2155 g_frame_map.Get().erase(it);
2147 2156
2148 if (is_subframe_) { 2157 if (is_subframe_) {
2149 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2158 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2150 switches::kSitePerProcess) && render_widget_) { 2159 switches::kSitePerProcess) && render_widget_) {
2151 render_widget_->UnregisterRenderFrame(this); 2160 render_widget_->UnregisterRenderFrame(this);
2152 } 2161 }
2153 frame->parent()->removeChild(frame); 2162
2163 if (type == blink::WebFrameClient::DetachType::Remove)
2164 frame->parent()->removeChild(frame);
2154 } 2165 }
2155 2166
2156 // |frame| is invalid after here. Be sure to clear frame_ as well, since this 2167 // |frame| is invalid after here. Be sure to clear frame_ as well, since this
2157 // object may not be deleted immediately and other methods may try to access 2168 // object may not be deleted immediately and other methods may try to access
2158 // it. 2169 // it.
2159 frame->close(); 2170 frame->close();
2160 frame_ = nullptr; 2171 frame_ = nullptr;
2161 2172
2162 delete this; 2173 delete this;
2163 // Object is invalid after this point. 2174 // Object is invalid after this point.
(...skipping 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4870 #elif defined(ENABLE_BROWSER_CDMS) 4881 #elif defined(ENABLE_BROWSER_CDMS)
4871 cdm_manager_, 4882 cdm_manager_,
4872 #endif 4883 #endif
4873 this); 4884 this);
4874 } 4885 }
4875 4886
4876 return cdm_factory_; 4887 return cdm_factory_;
4877 } 4888 }
4878 4889
4879 } // namespace content 4890 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698