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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 make_scoped_ptr(client)); | 215 make_scoped_ptr(client)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void RenderFrameImpl::didAccessInitialDocument(blink::WebFrame* frame) { | 218 void RenderFrameImpl::didAccessInitialDocument(blink::WebFrame* frame) { |
| 219 render_view_->didAccessInitialDocument(frame); | 219 render_view_->didAccessInitialDocument(frame); |
| 220 } | 220 } |
| 221 | 221 |
| 222 blink::WebFrame* RenderFrameImpl::createChildFrame( | 222 blink::WebFrame* RenderFrameImpl::createChildFrame( |
| 223 blink::WebFrame* parent, | 223 blink::WebFrame* parent, |
| 224 const blink::WebString& name) { | 224 const blink::WebString& name) { |
| 225 RenderFrameImpl* child_render_frame = this; | |
| 226 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); | 225 long long child_frame_identifier = WebFrame::generateEmbedderIdentifier(); |
| 227 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 226 // Synchronously notify the browser of a child frame creation to get the |
| 228 // Synchronously notify the browser of a child frame creation to get the | 227 // routing_id for the RenderFrame. |
| 229 // routing_id for the RenderFrame. | 228 int routing_id = MSG_ROUTING_NONE; |
|
Charlie Reis
2013/11/21 23:59:15
I added this since it didn't seem like a good idea
awong
2013/11/22 01:07:15
SGTM
| |
| 230 int routing_id; | 229 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), |
| 231 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(), | 230 parent->identifier(), |
| 232 parent->identifier(), | 231 child_frame_identifier, |
| 233 child_frame_identifier, | 232 UTF16ToUTF8(name), |
| 234 UTF16ToUTF8(name), | 233 &routing_id)); |
| 235 &routing_id)); | 234 if (routing_id == MSG_ROUTING_NONE) |
| 236 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id); | 235 return NULL; |
| 237 } | 236 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(render_view_, |
| 237 routing_id); | |
| 238 | 238 |
| 239 blink::WebFrame* web_frame = WebFrame::create(child_render_frame, | 239 blink::WebFrame* web_frame = WebFrame::create(child_render_frame, |
| 240 child_frame_identifier); | 240 child_frame_identifier); |
| 241 | 241 |
| 242 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 242 g_child_frame_map.Get().insert( |
| 243 g_child_frame_map.Get().insert( | 243 std::make_pair(web_frame, child_render_frame)); |
| 244 std::make_pair(web_frame, child_render_frame)); | |
| 245 } | |
| 246 | 244 |
| 247 return web_frame; | 245 return web_frame; |
| 248 } | 246 } |
| 249 | 247 |
| 250 void RenderFrameImpl::didDisownOpener(blink::WebFrame* frame) { | 248 void RenderFrameImpl::didDisownOpener(blink::WebFrame* frame) { |
| 251 render_view_->didDisownOpener(frame); | 249 render_view_->didDisownOpener(frame); |
| 252 } | 250 } |
| 253 | 251 |
| 254 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { | 252 void RenderFrameImpl::frameDetached(blink::WebFrame* frame) { |
| 255 // NOTE: This function is called on the frame that is being detached and not | 253 // NOTE: This function is called on the frame that is being detached and not |
| 256 // the parent frame. This is different from createChildFrame() which is | 254 // the parent frame. This is different from createChildFrame() which is |
| 257 // called on the parent frame. | 255 // called on the parent frame. |
| 258 CHECK(!is_detaching_); | 256 CHECK(!is_detaching_); |
| 259 | 257 |
| 260 int64 parent_frame_id = -1; | 258 int64 parent_frame_id = -1; |
| 261 if (frame->parent()) | 259 if (frame->parent()) |
| 262 parent_frame_id = frame->parent()->identifier(); | 260 parent_frame_id = frame->parent()->identifier(); |
| 263 | 261 |
| 264 Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, | 262 Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id, |
| 265 frame->identifier())); | 263 frame->identifier())); |
| 266 | 264 |
| 267 // Currently multiple WebCore::Frames can send frameDetached to a single | 265 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be |
|
nasko
2013/11/22 00:09:01
Any specific reason why the existing comment about
Charlie Reis
2013/11/22 00:13:21
That comment no longer applies. :) There's alway
nasko
2013/11/22 00:25:04
Albert, I recall you were getting multiple calls t
awong
2013/11/22 01:07:15
Daniel's reply is correct.
| |
| 268 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served | 266 // sent before setting |is_detaching_| to true. In contrast, Observers |
| 269 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also | 267 // should only be notified afterwards so they cannot call back into and |
| 270 // prevents this class from entering the |is_detaching_| state because | 268 // have IPCs fired off. |
| 271 // even though one WebCore::Frame may have detached itself, others will | 269 is_detaching_ = true; |
| 272 // still need to use this object. | |
| 273 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | |
| 274 // The |is_detaching_| flag disables Send(). FrameHostMsg_Detach must be | |
| 275 // sent before setting |is_detaching_| to true. In contrast, Observers | |
| 276 // should only be notified afterwards so they cannot call back into and | |
| 277 // have IPCs fired off. | |
| 278 is_detaching_ = true; | |
| 279 } | |
| 280 | 270 |
| 281 // Call back to RenderViewImpl for observers to be notified. | 271 // Call back to RenderViewImpl for observers to be notified. |
| 282 // TODO(nasko): Remove once we have RenderFrameObserver. | 272 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 283 render_view_->frameDetached(frame); | 273 render_view_->frameDetached(frame); |
| 284 | 274 |
| 285 frame->close(); | 275 frame->close(); |
| 286 | 276 |
| 287 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 277 // If the frame does not have a parent, it is the main frame. The main |
| 288 // If the frame does not have a parent, it is the main frame. The main | 278 // frame is owned by the containing RenderViewHost so it does not require |
| 289 // frame is owned by the containing RenderViewHost so it does not require | 279 // any cleanup here. |
| 290 // any cleanup here. | 280 if (frame->parent()) { |
| 291 if (frame->parent()) { | 281 FrameMap::iterator it = g_child_frame_map.Get().find(frame); |
| 292 FrameMap::iterator it = g_child_frame_map.Get().find(frame); | 282 DCHECK(it != g_child_frame_map.Get().end()); |
| 293 DCHECK(it != g_child_frame_map.Get().end()); | 283 DCHECK_EQ(it->second, this); |
| 294 DCHECK_EQ(it->second, this); | 284 g_child_frame_map.Get().erase(it); |
| 295 g_child_frame_map.Get().erase(it); | 285 delete this; |
| 296 delete this; | 286 // Object is invalid after this point. |
| 297 // Object is invalid after this point. | |
| 298 } | |
| 299 } | 287 } |
| 300 } | 288 } |
| 301 | 289 |
| 302 void RenderFrameImpl::willClose(blink::WebFrame* frame) { | 290 void RenderFrameImpl::willClose(blink::WebFrame* frame) { |
| 303 // Call back to RenderViewImpl for observers to be notified. | 291 // Call back to RenderViewImpl for observers to be notified. |
| 304 // TODO(nasko): Remove once we have RenderFrameObserver. | 292 // TODO(nasko): Remove once we have RenderFrameObserver. |
| 305 render_view_->willClose(frame); | 293 render_view_->willClose(frame); |
| 306 } | 294 } |
| 307 | 295 |
| 308 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, | 296 void RenderFrameImpl::didChangeName(blink::WebFrame* frame, |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 | 966 |
| 979 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame, | 967 void RenderFrameImpl::didLoseWebGLContext(blink::WebFrame* frame, |
| 980 int arb_robustness_status_code) { | 968 int arb_robustness_status_code) { |
| 981 render_view_->Send(new ViewHostMsg_DidLose3DContext( | 969 render_view_->Send(new ViewHostMsg_DidLose3DContext( |
| 982 GURL(frame->top()->document().securityOrigin().toString()), | 970 GURL(frame->top()->document().securityOrigin().toString()), |
| 983 THREE_D_API_TYPE_WEBGL, | 971 THREE_D_API_TYPE_WEBGL, |
| 984 arb_robustness_status_code)); | 972 arb_robustness_status_code)); |
| 985 } | 973 } |
| 986 | 974 |
| 987 } // namespace content | 975 } // namespace content |
| OLD | NEW |