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 2154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 // We only notify the browser process when the frame is being detached for | 2165 // We only notify the browser process when the frame is being detached for |
2166 // removal. If the frame is being detached for swap, we don't need to do this | 2166 // removal. If the frame is being detached for swap, we don't need to do this |
2167 // since we are not modifiying the frame tree. | 2167 // since we are not modifiying the frame tree. |
2168 if (type == DetachType::Remove) | 2168 if (type == DetachType::Remove) |
2169 Send(new FrameHostMsg_Detach(routing_id_)); | 2169 Send(new FrameHostMsg_Detach(routing_id_)); |
2170 | 2170 |
2171 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be | 2171 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
2172 // sent before setting |is_detaching_| to true. | 2172 // sent before setting |is_detaching_| to true. |
2173 is_detaching_ = true; | 2173 is_detaching_ = true; |
2174 | 2174 |
| 2175 if (render_widget_) |
| 2176 render_widget_->UnregisterRenderFrame(this); |
| 2177 |
2175 // We need to clean up subframes by removing them from the map and deleting | 2178 // We need to clean up subframes by removing them from the map and deleting |
2176 // the RenderFrameImpl. In contrast, the main frame is owned by its | 2179 // the RenderFrameImpl. In contrast, the main frame is owned by its |
2177 // containing RenderViewHost (so that they have the same lifetime), so only | 2180 // containing RenderViewHost (so that they have the same lifetime), so only |
2178 // removal from the map is needed and no deletion. | 2181 // removal from the map is needed and no deletion. |
2179 FrameMap::iterator it = g_frame_map.Get().find(frame); | 2182 FrameMap::iterator it = g_frame_map.Get().find(frame); |
2180 CHECK(it != g_frame_map.Get().end()); | 2183 CHECK(it != g_frame_map.Get().end()); |
2181 CHECK_EQ(it->second, this); | 2184 CHECK_EQ(it->second, this); |
2182 g_frame_map.Get().erase(it); | 2185 g_frame_map.Get().erase(it); |
2183 | 2186 |
2184 if (is_subframe_) { | 2187 // Only remove the frame from the renderer's frame tree if the frame is |
2185 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2188 // being detached for removal. In the case of a swap, the frame needs to |
2186 switches::kSitePerProcess) && render_widget_) { | 2189 // remain in the tree so WebFrame::swap() can replace it with the new frame. |
2187 render_widget_->UnregisterRenderFrame(this); | 2190 if (is_subframe_ && type == DetachType::Remove) |
2188 } | 2191 frame->parent()->removeChild(frame); |
2189 | |
2190 // Only remove the frame from the renderer's frame tree if the frame is | |
2191 // being detached for removal. For swaps, WebFrame::swap already takes care | |
2192 // of replacing the frame with a RemoteFrame. | |
2193 if (type == DetachType::Remove) | |
2194 frame->parent()->removeChild(frame); | |
2195 } | |
2196 | 2192 |
2197 // |frame| is invalid after here. Be sure to clear frame_ as well, since this | 2193 // |frame| is invalid after here. Be sure to clear frame_ as well, since this |
2198 // object may not be deleted immediately and other methods may try to access | 2194 // object may not be deleted immediately and other methods may try to access |
2199 // it. | 2195 // it. |
2200 frame->close(); | 2196 frame->close(); |
2201 frame_ = nullptr; | 2197 frame_ = nullptr; |
2202 | 2198 |
2203 delete this; | 2199 delete this; |
2204 // Object is invalid after this point. | 2200 // Object is invalid after this point. |
2205 } | 2201 } |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5026 void RenderFrameImpl::RegisterMojoServices() { | 5022 void RenderFrameImpl::RegisterMojoServices() { |
5027 // Only main frame have ImageDownloader service. | 5023 // Only main frame have ImageDownloader service. |
5028 if (!frame_->parent()) { | 5024 if (!frame_->parent()) { |
5029 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 5025 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
5030 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 5026 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
5031 base::Unretained(this))); | 5027 base::Unretained(this))); |
5032 } | 5028 } |
5033 } | 5029 } |
5034 | 5030 |
5035 } // namespace content | 5031 } // namespace content |
OLD | NEW |