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

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

Issue 23841002: Create a new RenderFrameHost per child frame when --site-per-process is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and add some comments. Created 7 years, 3 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 | Annotate | Revision Log
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/child/appcache/appcache_dispatcher.h" 10 #include "content/child/appcache/appcache_dispatcher.h"
11 #include "content/child/quota_dispatcher.h" 11 #include "content/child/quota_dispatcher.h"
12 #include "content/child/request_extra_data.h" 12 #include "content/child/request_extra_data.h"
13 #include "content/common/frame_messages.h"
13 #include "content/common/socket_stream_handle_data.h" 14 #include "content/common/socket_stream_handle_data.h"
14 #include "content/common/swapped_out_messages.h" 15 #include "content/common/swapped_out_messages.h"
15 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
16 #include "content/public/common/content_constants.h" 17 #include "content/public/common/content_constants.h"
17 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
18 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
19 #include "content/public/renderer/content_renderer_client.h" 20 #include "content/public/renderer/content_renderer_client.h"
20 #include "content/public/renderer/document_state.h" 21 #include "content/public/renderer/document_state.h"
21 #include "content/public/renderer/navigation_state.h" 22 #include "content/public/renderer/navigation_state.h"
22 #include "content/renderer/browser_plugin/browser_plugin.h" 23 #include "content/renderer/browser_plugin/browser_plugin.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 using WebKit::WebURLResponse; 66 using WebKit::WebURLResponse;
66 using WebKit::WebUserGestureIndicator; 67 using WebKit::WebUserGestureIndicator;
67 using WebKit::WebVector; 68 using WebKit::WebVector;
68 using WebKit::WebView; 69 using WebKit::WebView;
69 using base::Time; 70 using base::Time;
70 using base::TimeDelta; 71 using base::TimeDelta;
71 using webkit_glue::WebURLResponseExtraDataImpl; 72 using webkit_glue::WebURLResponseExtraDataImpl;
72 73
73 namespace content { 74 namespace content {
74 75
76 namespace {
77
78 // NOTE: -1 is used by content::FrameTreeNode as an invalid ID.
79 long long GenerateFrameIdentifier() {
80 static long long next = 0;
81 return ++next;
82 }
83
84 typedef std::map<WebKit::WebFrame*, RenderFrameImpl*> FrameMap;
85 base::LazyInstance<FrameMap> g_child_frame_map = LAZY_INSTANCE_INITIALIZER;
86
87 } // namespace
88
75 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) = 89 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) =
76 NULL; 90 NULL;
77 91
78 // static 92 // static
79 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 93 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
80 int32 routing_id) { 94 int32 routing_id) {
81 DCHECK(routing_id != MSG_ROUTING_NONE); 95 DCHECK(routing_id != MSG_ROUTING_NONE);
82 96
83 RenderFrameImpl* render_frame = NULL; 97 RenderFrameImpl* render_frame = NULL;
84 if (g_create_render_frame_impl) 98 if (g_create_render_frame_impl)
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 224 }
211 225
212 WebKit::WebCookieJar* RenderFrameImpl::cookieJar(WebKit::WebFrame* frame) { 226 WebKit::WebCookieJar* RenderFrameImpl::cookieJar(WebKit::WebFrame* frame) {
213 return render_view_->cookieJar(frame); 227 return render_view_->cookieJar(frame);
214 } 228 }
215 229
216 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) { 230 void RenderFrameImpl::didAccessInitialDocument(WebKit::WebFrame* frame) {
217 render_view_->didAccessInitialDocument(frame); 231 render_view_->didAccessInitialDocument(frame);
218 } 232 }
219 233
220 void RenderFrameImpl::didCreateFrame(WebKit::WebFrame* parent, 234 WebKit::WebFrame* RenderFrameImpl::createMainFrame() {
221 WebKit::WebFrame* child) { 235 return WebFrame::create(this, GenerateFrameIdentifier());
222 render_view_->Send(new ViewHostMsg_FrameAttached( 236 }
223 render_view_->GetRoutingID(), parent->identifier(), child->identifier(), 237
224 UTF16ToUTF8(child->assignedName()))); 238 WebKit::WebFrame* RenderFrameImpl::createChildFrame(WebKit::WebFrame* parent,
239 WebKit::WebString name) {
240 RenderFrameImpl* child_render_frame = this;
241 long long child_frame_identifier = GenerateFrameIdentifier();
242 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
243 int routing_id;
244 Send(new FrameHostMsg_CreateChildFrame(GetRoutingID(),
Charlie Reis 2013/09/11 22:25:04 Maybe emphasize that this is sync?
awong 2013/09/21 01:19:56 We don't seem to do this in other spots that have
245 parent->identifier(),
246 child_frame_identifier,
247 UTF16ToUTF8(name),
248 &routing_id));
249 child_render_frame = RenderFrameImpl::Create(render_view_, routing_id);
250 }
251
252 WebKit::WebFrame* web_frame = WebFrame::create(child_render_frame,
253 child_frame_identifier);
254 g_child_frame_map.Get().insert(std::make_pair(web_frame, child_render_frame));
255
256 return web_frame;
225 } 257 }
226 258
227 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) { 259 void RenderFrameImpl::didDisownOpener(WebKit::WebFrame* frame) {
228 render_view_->didDisownOpener(frame); 260 render_view_->didDisownOpener(frame);
229 } 261 }
230 262
231 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) { 263 void RenderFrameImpl::frameDetached(WebKit::WebFrame* frame) {
232 // Currently multiple WebCore::Frames can send frameDetached to a single 264 // Currently multiple WebCore::Frames can send frameDetached to a single
233 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served 265 // RenderFrameImpl. This is legacy behavior from when RenderViewImpl served
234 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also 266 // as a shared WebFrameClient for multiple Webcore::Frame objects. It also
235 // prevents this class from entering the |is_detaching_| state because 267 // prevents this class from entering the |is_detaching_| state because
236 // even though one WebCore::Frame may have detached itself, others will 268 // even though one WebCore::Frame may have detached itself, others will
237 // still need to use this object. 269 // still need to use this object.
238 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 270 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
239 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each 271 // TODO(ajwong): Add CHECK(!is_detaching_) once we guarantee each
240 // RenderFrameImpl is only used by one WebCore::Frame. 272 // RenderFrameImpl is only used by one WebCore::Frame.
241 is_detaching_ = true; 273 is_detaching_ = true;
242 } 274 }
243 275
244 int64 parent_frame_id = -1; 276 int64 parent_frame_id = -1;
245 if (frame->parent()) 277 if (frame->parent())
246 parent_frame_id = frame->parent()->identifier(); 278 parent_frame_id = frame->parent()->identifier();
247 279
248 render_view_->Send(new ViewHostMsg_FrameDetached(render_view_->GetRoutingID(), 280 render_view_->Send(new FrameHostMsg_Detach(GetRoutingID(), parent_frame_id,
249 parent_frame_id, 281 frame->identifier()));
250 frame->identifier()));
251 282
252 // Call back to RenderViewImpl for observers to be notified. 283 // Call back to RenderViewImpl for observers to be notified.
253 // TODO(nasko): Remove once we have RenderFrameObserver. 284 // TODO(nasko): Remove once we have RenderFrameObserver.
254 render_view_->frameDetached(frame); 285 render_view_->frameDetached(frame);
286 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
287 FrameMap::iterator it = g_child_frame_map.Get().find(frame);
288 DCHECK(it != g_child_frame_map.Get().end());
289 DCHECK_EQ(it->second, this);
290 delete it->second;
291 g_child_frame_map.Get().erase(it);
292 }
255 } 293 }
256 294
257 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) { 295 void RenderFrameImpl::willClose(WebKit::WebFrame* frame) {
258 // Call back to RenderViewImpl for observers to be notified. 296 // Call back to RenderViewImpl for observers to be notified.
259 // TODO(nasko): Remove once we have RenderFrameObserver. 297 // TODO(nasko): Remove once we have RenderFrameObserver.
260 render_view_->willClose(frame); 298 render_view_->willClose(frame);
261 } 299 }
262 300
263 void RenderFrameImpl::didChangeName(WebKit::WebFrame* frame, 301 void RenderFrameImpl::didChangeName(WebKit::WebFrame* frame,
264 const WebKit::WebString& name) { 302 const WebKit::WebString& name) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 898
861 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame, 899 void RenderFrameImpl::didLoseWebGLContext(WebKit::WebFrame* frame,
862 int arb_robustness_status_code) { 900 int arb_robustness_status_code) {
863 render_view_->Send(new ViewHostMsg_DidLose3DContext( 901 render_view_->Send(new ViewHostMsg_DidLose3DContext(
864 GURL(frame->top()->document().securityOrigin().toString()), 902 GURL(frame->top()->document().securityOrigin().toString()),
865 THREE_D_API_TYPE_WEBGL, 903 THREE_D_API_TYPE_WEBGL,
866 arb_robustness_status_code)); 904 arb_robustness_status_code));
867 } 905 }
868 906
869 } // namespace content 907 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698