Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 if (contains_media_player_) | 685 if (contains_media_player_) |
| 686 render_view_->UnregisterVideoHoleFrame(this); | 686 render_view_->UnregisterVideoHoleFrame(this); |
| 687 #endif | 687 #endif |
| 688 | 688 |
| 689 if (!is_subframe_) { | 689 if (!is_subframe_) { |
| 690 // RenderFrameProxy is "owned" by RenderFrameImpl in the case it is | 690 // RenderFrameProxy is "owned" by RenderFrameImpl in the case it is |
| 691 // the main frame. Ensure it is deleted along with this object. | 691 // the main frame. Ensure it is deleted along with this object. |
| 692 if (render_frame_proxy_) { | 692 if (render_frame_proxy_) { |
| 693 // The following method calls back into this object and clears | 693 // The following method calls back into this object and clears |
| 694 // |render_frame_proxy_|. | 694 // |render_frame_proxy_|. |
| 695 render_frame_proxy_->frameDetached(); | 695 render_frame_proxy_->frameDetached( |
| 696 blink::WebRemoteFrameClient::DetachType::Remove); | |
| 696 } | 697 } |
| 697 | 698 |
| 698 // Ensure the RenderView doesn't point to this object, once it is destroyed. | 699 // Ensure the RenderView doesn't point to this object, once it is destroyed. |
| 699 CHECK_EQ(render_view_->main_render_frame_, this); | 700 CHECK_EQ(render_view_->main_render_frame_, this); |
| 700 render_view_->main_render_frame_ = nullptr; | 701 render_view_->main_render_frame_ = nullptr; |
| 701 } | 702 } |
| 702 | 703 |
| 703 render_view_->UnregisterRenderFrame(this); | 704 render_view_->UnregisterRenderFrame(this); |
| 704 g_routing_id_frame_map.Get().erase(routing_id_); | 705 g_routing_id_frame_map.Get().erase(routing_id_); |
| 705 RenderThread::Get()->RemoveRoute(routing_id_); | 706 RenderThread::Get()->RemoveRoute(routing_id_); |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2113 // opener after hearing about it from the browser, and the browser does not | 2114 // opener after hearing about it from the browser, and the browser does not |
| 2114 // (yet) care about subframe openers. | 2115 // (yet) care about subframe openers. |
| 2115 if (is_swapped_out_ || frame->parent()) | 2116 if (is_swapped_out_ || frame->parent()) |
| 2116 return; | 2117 return; |
| 2117 | 2118 |
| 2118 // Notify WebContents and all its swapped out RenderViews. | 2119 // Notify WebContents and all its swapped out RenderViews. |
| 2119 Send(new FrameHostMsg_DidDisownOpener(routing_id_)); | 2120 Send(new FrameHostMsg_DidDisownOpener(routing_id_)); |
| 2120 } | 2121 } |
| 2121 | 2122 |
| 2122 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { | 2123 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { |
| 2124 frameDetached(frame, DetachType::Remove); | |
| 2125 } | |
| 2126 | |
| 2127 void RenderFrameImpl::frameDetached(blink::WebFrame* frame, DetachType type) { | |
| 2123 // NOTE: This function is called on the frame that is being detached and not | 2128 // 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 | 2129 // the parent frame. This is different from createChildFrame() which is |
| 2125 // called on the parent frame. | 2130 // called on the parent frame. |
| 2126 CHECK(!is_detaching_); | 2131 CHECK(!is_detaching_); |
| 2127 DCHECK(!frame_ || frame_ == frame); | 2132 DCHECK(!frame_ || frame_ == frame); |
| 2128 | 2133 |
| 2129 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached()); | 2134 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameDetached()); |
| 2130 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2135 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2131 FrameDetached(frame)); | 2136 FrameDetached(frame)); |
| 2132 | 2137 |
| 2133 Send(new FrameHostMsg_Detach(routing_id_)); | 2138 if (type == DetachType::Remove) |
|
Charlie Reis
2015/06/01 23:41:46
What other values can it be, and why would this me
lfg
2015/06/02 16:00:01
I've added some comments, please take a look.
Charlie Reis
2015/06/02 17:05:27
Much better, thanks.
| |
| 2139 Send(new FrameHostMsg_Detach(routing_id_)); | |
| 2134 | 2140 |
| 2135 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be | 2141 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
| 2136 // sent before setting |is_detaching_| to true. | 2142 // sent before setting |is_detaching_| to true. |
| 2137 is_detaching_ = true; | 2143 is_detaching_ = true; |
| 2138 | 2144 |
| 2139 // We need to clean up subframes by removing them from the map and deleting | 2145 // 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 | 2146 // the RenderFrameImpl. In contrast, the main frame is owned by its |
| 2141 // containing RenderViewHost (so that they have the same lifetime), so only | 2147 // containing RenderViewHost (so that they have the same lifetime), so only |
| 2142 // removal from the map is needed and no deletion. | 2148 // removal from the map is needed and no deletion. |
| 2143 FrameMap::iterator it = g_frame_map.Get().find(frame); | 2149 FrameMap::iterator it = g_frame_map.Get().find(frame); |
| 2144 CHECK(it != g_frame_map.Get().end()); | 2150 CHECK(it != g_frame_map.Get().end()); |
| 2145 CHECK_EQ(it->second, this); | 2151 CHECK_EQ(it->second, this); |
| 2146 g_frame_map.Get().erase(it); | 2152 g_frame_map.Get().erase(it); |
| 2147 | 2153 |
| 2148 if (is_subframe_) { | 2154 if (is_subframe_) { |
| 2149 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2155 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2150 switches::kSitePerProcess) && render_widget_) { | 2156 switches::kSitePerProcess) && render_widget_) { |
| 2151 render_widget_->UnregisterRenderFrame(this); | 2157 render_widget_->UnregisterRenderFrame(this); |
| 2152 } | 2158 } |
| 2153 frame->parent()->removeChild(frame); | 2159 |
| 2160 if (type == DetachType::Remove) | |
| 2161 frame->parent()->removeChild(frame); | |
| 2154 } | 2162 } |
| 2155 | 2163 |
| 2156 // |frame| is invalid after here. Be sure to clear frame_ as well, since this | 2164 // |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 | 2165 // object may not be deleted immediately and other methods may try to access |
| 2158 // it. | 2166 // it. |
| 2159 frame->close(); | 2167 frame->close(); |
| 2160 frame_ = nullptr; | 2168 frame_ = nullptr; |
| 2161 | 2169 |
| 2162 delete this; | 2170 delete this; |
| 2163 // Object is invalid after this point. | 2171 // Object is invalid after this point. |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4877 #elif defined(ENABLE_BROWSER_CDMS) | 4885 #elif defined(ENABLE_BROWSER_CDMS) |
| 4878 cdm_manager_, | 4886 cdm_manager_, |
| 4879 #endif | 4887 #endif |
| 4880 this); | 4888 this); |
| 4881 } | 4889 } |
| 4882 | 4890 |
| 4883 return cdm_factory_; | 4891 return cdm_factory_; |
| 4884 } | 4892 } |
| 4885 | 4893 |
| 4886 } // namespace content | 4894 } // namespace content |
| OLD | NEW |