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

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

Issue 1229083002: Clean up some detach logic in RenderFrameImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 // We only notify the browser process when the frame is being detached for 2160 // We only notify the browser process when the frame is being detached for
2161 // removal. If the frame is being detached for swap, we don't need to do this 2161 // removal. If the frame is being detached for swap, we don't need to do this
2162 // since we are not modifiying the frame tree. 2162 // since we are not modifiying the frame tree.
2163 if (type == DetachType::Remove) 2163 if (type == DetachType::Remove)
2164 Send(new FrameHostMsg_Detach(routing_id_)); 2164 Send(new FrameHostMsg_Detach(routing_id_));
2165 2165
2166 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be 2166 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be
2167 // sent before setting |is_detaching_| to true. 2167 // sent before setting |is_detaching_| to true.
2168 is_detaching_ = true; 2168 is_detaching_ = true;
2169 2169
2170 if (render_widget_) {
Charlie Reis 2015/07/09 21:06:19 nit: No braces. Same below.
2171 render_widget_->UnregisterRenderFrame(this);
2172 }
2173
2170 // We need to clean up subframes by removing them from the map and deleting 2174 // We need to clean up subframes by removing them from the map and deleting
2171 // the RenderFrameImpl. In contrast, the main frame is owned by its 2175 // the RenderFrameImpl. In contrast, the main frame is owned by its
2172 // containing RenderViewHost (so that they have the same lifetime), so only 2176 // containing RenderViewHost (so that they have the same lifetime), so only
2173 // removal from the map is needed and no deletion. 2177 // removal from the map is needed and no deletion.
2174 FrameMap::iterator it = g_frame_map.Get().find(frame); 2178 FrameMap::iterator it = g_frame_map.Get().find(frame);
2175 CHECK(it != g_frame_map.Get().end()); 2179 CHECK(it != g_frame_map.Get().end());
2176 CHECK_EQ(it->second, this); 2180 CHECK_EQ(it->second, this);
2177 g_frame_map.Get().erase(it); 2181 g_frame_map.Get().erase(it);
2178 2182
2179 if (is_subframe_) { 2183 // Only remove the frame from the renderer's frame tree if the frame is
2180 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2184 // being detached for removal. In the case of a swap, the frame needs to
2181 switches::kSitePerProcess) && render_widget_) { 2185 // remain in the tree so WebFrame::swap() can replace it with the new frame.
2182 render_widget_->UnregisterRenderFrame(this); 2186 if (is_subframe_ && type == DetachType::Remove) {
2183 } 2187 frame->parent()->removeChild(frame);
2184
2185 // Only remove the frame from the renderer's frame tree if the frame is
2186 // being detached for removal. For swaps, WebFrame::swap already takes care
2187 // of replacing the frame with a RemoteFrame.
2188 if (type == DetachType::Remove)
2189 frame->parent()->removeChild(frame);
2190 } 2188 }
2191 2189
2192 // |frame| is invalid after here. Be sure to clear frame_ as well, since this 2190 // |frame| is invalid after here. Be sure to clear frame_ as well, since this
2193 // object may not be deleted immediately and other methods may try to access 2191 // object may not be deleted immediately and other methods may try to access
2194 // it. 2192 // it.
2195 frame->close(); 2193 frame->close();
2196 frame_ = nullptr; 2194 frame_ = nullptr;
2197 2195
2198 delete this; 2196 delete this;
2199 // Object is invalid after this point. 2197 // Object is invalid after this point.
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 void RenderFrameImpl::RegisterMojoServices() { 5019 void RenderFrameImpl::RegisterMojoServices() {
5022 // Only main frame have ImageDownloader service. 5020 // Only main frame have ImageDownloader service.
5023 if (!frame_->parent()) { 5021 if (!frame_->parent()) {
5024 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( 5022 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>(
5025 base::Bind(&ImageDownloaderImpl::CreateMojoService, 5023 base::Bind(&ImageDownloaderImpl::CreateMojoService,
5026 base::Unretained(this))); 5024 base::Unretained(this)));
5027 } 5025 }
5028 } 5026 }
5029 5027
5030 } // namespace content 5028 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698