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

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

Issue 1398443004: RenderFrameImpl: extract a helper function, GetRoutingIdForFrameOrProxy(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 5 years, 2 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 return media::Context3D(provider->ContextGL(), provider->GrContext()); 506 return media::Context3D(provider->ContextGL(), provider->GrContext());
507 } 507 }
508 #endif 508 #endif
509 509
510 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) { 510 bool IsReload(FrameMsg_Navigate_Type::Value navigation_type) {
511 return navigation_type == FrameMsg_Navigate_Type::RELOAD || 511 return navigation_type == FrameMsg_Navigate_Type::RELOAD ||
512 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || 512 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE ||
513 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; 513 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL;
514 } 514 }
515 515
516 // Returns the routing ID of the RenderFrameImpl or RenderFrameProxy
517 // associated with |web_frame|.
518 int GetRoutingIdForFrameOrProxy(WebFrame* web_frame) {
519 if (!web_frame)
520 return MSG_ROUTING_NONE;
521 if (web_frame->isWebRemoteFrame())
522 return RenderFrameProxy::FromWebFrame(web_frame)->routing_id();
523 return RenderFrameImpl::FromWebFrame(web_frame)->GetRoutingID();
524 }
525
516 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl = 526 RenderFrameImpl::CreateRenderFrameImplFunction g_create_render_frame_impl =
517 nullptr; 527 nullptr;
518 528
519 void OnGotContentHandlerID(uint32_t content_handler_id) {} 529 void OnGotContentHandlerID(uint32_t content_handler_id) {}
520 530
521 } // namespace 531 } // namespace
522 532
523 // static 533 // static
524 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 534 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
525 int32 routing_id) { 535 int32 routing_id) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 frame_ = web_frame; 801 frame_ = web_frame;
792 } 802 }
793 803
794 void RenderFrameImpl::Initialize() { 804 void RenderFrameImpl::Initialize() {
795 is_main_frame_ = !frame_->parent(); 805 is_main_frame_ = !frame_->parent();
796 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); 806 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame();
797 807
798 bool is_tracing = false; 808 bool is_tracing = false;
799 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); 809 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing);
800 if (is_tracing) { 810 if (is_tracing) {
801 int parent_id = MSG_ROUTING_NONE; 811 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent());
802 if (!is_main_frame_) {
803 if (frame_->parent()->isWebRemoteFrame()) {
804 RenderFrameProxy* parent_proxy = RenderFrameProxy::FromWebFrame(
805 frame_->parent());
806 if (parent_proxy)
807 parent_id = parent_proxy->routing_id();
808 } else {
809 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame(
810 frame_->parent());
811 if (parent_frame)
812 parent_id = parent_frame->GetRoutingID();
813 }
814 }
815 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", 812 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize",
816 "id", routing_id_, 813 "id", routing_id_,
817 "parent", parent_id); 814 "parent", parent_id);
818 } 815 }
819 816
820 #if defined(ENABLE_PLUGINS) 817 #if defined(ENABLE_PLUGINS)
821 new PepperBrowserConnection(this); 818 new PepperBrowserConnection(this);
822 #endif 819 #endif
823 new SharedWorkerRepository(this); 820 new SharedWorkerRepository(this);
824 821
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // updates are happening too frequently. 2338 // updates are happening too frequently.
2342 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || 2339 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
2343 render_view_->renderer_preferences_.report_frame_name_changes) { 2340 render_view_->renderer_preferences_.report_frame_name_changes) {
2344 Send(new FrameHostMsg_DidChangeName( 2341 Send(new FrameHostMsg_DidChangeName(
2345 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)))); 2342 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name))));
2346 } 2343 }
2347 } 2344 }
2348 2345
2349 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame, 2346 void RenderFrameImpl::didChangeSandboxFlags(blink::WebFrame* child_frame,
2350 blink::WebSandboxFlags flags) { 2347 blink::WebSandboxFlags flags) {
2351 int frame_routing_id = MSG_ROUTING_NONE; 2348 Send(new FrameHostMsg_DidChangeSandboxFlags(
2352 if (child_frame->isWebRemoteFrame()) { 2349 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), flags));
2353 frame_routing_id =
2354 RenderFrameProxy::FromWebFrame(child_frame)->routing_id();
2355 } else {
2356 frame_routing_id =
2357 RenderFrameImpl::FromWebFrame(child_frame)->GetRoutingID();
2358 }
2359
2360 Send(new FrameHostMsg_DidChangeSandboxFlags(routing_id_, frame_routing_id,
2361 flags));
2362 } 2350 }
2363 2351
2364 void RenderFrameImpl::didMatchCSS( 2352 void RenderFrameImpl::didMatchCSS(
2365 blink::WebLocalFrame* frame, 2353 blink::WebLocalFrame* frame,
2366 const blink::WebVector<blink::WebString>& newly_matching_selectors, 2354 const blink::WebVector<blink::WebString>& newly_matching_selectors,
2367 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 2355 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
2368 DCHECK(!frame_ || frame_ == frame); 2356 DCHECK(!frame_ || frame_ == frame);
2369 2357
2370 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 2358 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
2371 DidMatchCSS(newly_matching_selectors, 2359 DidMatchCSS(newly_matching_selectors,
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3339 ServiceWorkerNetworkProvider::FromDocumentState( 3327 ServiceWorkerNetworkProvider::FromDocumentState(
3340 DocumentState::FromDataSource(frame->dataSource())); 3328 DocumentState::FromDataSource(frame->dataSource()));
3341 provider_id = provider->provider_id(); 3329 provider_id = provider->provider_id();
3342 // Explicitly set the SkipServiceWorker flag here if the renderer process 3330 // Explicitly set the SkipServiceWorker flag here if the renderer process
3343 // hasn't received SetControllerServiceWorker message. 3331 // hasn't received SetControllerServiceWorker message.
3344 if (!provider->IsControlledByServiceWorker()) 3332 if (!provider->IsControlledByServiceWorker())
3345 request.setSkipServiceWorker(true); 3333 request.setSkipServiceWorker(true);
3346 } 3334 }
3347 3335
3348 WebFrame* parent = frame->parent(); 3336 WebFrame* parent = frame->parent();
3349 int parent_routing_id = MSG_ROUTING_NONE; 3337 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1;
3350 if (!parent) {
3351 parent_routing_id = -1;
3352 } else if (parent->isWebLocalFrame()) {
3353 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
3354 } else {
3355 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
3356 }
3357 3338
3358 RequestExtraData* extra_data = new RequestExtraData(); 3339 RequestExtraData* extra_data = new RequestExtraData();
3359 extra_data->set_visibility_state(render_view_->visibilityState()); 3340 extra_data->set_visibility_state(render_view_->visibilityState());
3360 extra_data->set_custom_user_agent(custom_user_agent); 3341 extra_data->set_custom_user_agent(custom_user_agent);
3361 extra_data->set_requested_with(requested_with); 3342 extra_data->set_requested_with(requested_with);
3362 extra_data->set_render_frame_id(routing_id_); 3343 extra_data->set_render_frame_id(routing_id_);
3363 extra_data->set_is_main_frame(!parent); 3344 extra_data->set_is_main_frame(!parent);
3364 extra_data->set_frame_origin( 3345 extra_data->set_frame_origin(
3365 GURL(frame->document().securityOrigin().toString())); 3346 GURL(frame->document().securityOrigin().toString()));
3366 extra_data->set_parent_is_main_frame(parent && !parent->parent()); 3347 extra_data->set_parent_is_main_frame(parent && !parent->parent());
(...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after
5174 mojo::ServiceProviderPtr service_provider; 5155 mojo::ServiceProviderPtr service_provider;
5175 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5156 mojo::URLRequestPtr request(mojo::URLRequest::New());
5176 request->url = mojo::String::From(url); 5157 request->url = mojo::String::From(url);
5177 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5158 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5178 nullptr, nullptr, 5159 nullptr, nullptr,
5179 base::Bind(&OnGotContentHandlerID)); 5160 base::Bind(&OnGotContentHandlerID));
5180 return service_provider.Pass(); 5161 return service_provider.Pass();
5181 } 5162 }
5182 5163
5183 } // namespace content 5164 } // 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