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

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

Issue 1310743003: Consistently use LoFi for an entire page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 5 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
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 22 matching lines...) Expand all
33 #include "content/child/web_url_loader_impl.h" 33 #include "content/child/web_url_loader_impl.h"
34 #include "content/child/web_url_request_util.h" 34 #include "content/child/web_url_request_util.h"
35 #include "content/child/webmessageportchannel_impl.h" 35 #include "content/child/webmessageportchannel_impl.h"
36 #include "content/child/websocket_bridge.h" 36 #include "content/child/websocket_bridge.h"
37 #include "content/child/weburlresponse_extradata_impl.h" 37 #include "content/child/weburlresponse_extradata_impl.h"
38 #include "content/common/accessibility_messages.h" 38 #include "content/common/accessibility_messages.h"
39 #include "content/common/clipboard_messages.h" 39 #include "content/common/clipboard_messages.h"
40 #include "content/common/frame_messages.h" 40 #include "content/common/frame_messages.h"
41 #include "content/common/frame_replication_state.h" 41 #include "content/common/frame_replication_state.h"
42 #include "content/common/input_messages.h" 42 #include "content/common/input_messages.h"
43 #include "content/common/navigation_params.h"
44 #include "content/common/service_worker/service_worker_types.h" 43 #include "content/common/service_worker/service_worker_types.h"
45 #include "content/common/site_isolation_policy.h" 44 #include "content/common/site_isolation_policy.h"
46 #include "content/common/swapped_out_messages.h" 45 #include "content/common/swapped_out_messages.h"
47 #include "content/common/view_messages.h" 46 #include "content/common/view_messages.h"
48 #include "content/public/common/bindings_policy.h" 47 #include "content/public/common/bindings_policy.h"
49 #include "content/public/common/content_constants.h" 48 #include "content/public/common/content_constants.h"
50 #include "content/public/common/content_switches.h" 49 #include "content/public/common/content_switches.h"
51 #include "content/public/common/context_menu_params.h" 50 #include "content/public/common/context_menu_params.h"
52 #include "content/public/common/isolated_world_ids.h" 51 #include "content/public/common/isolated_world_ids.h"
53 #include "content/public/common/page_state.h" 52 #include "content/public/common/page_state.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 render_frame->render_widget_ = RenderWidget::CreateForFrame( 628 render_frame->render_widget_ = RenderWidget::CreateForFrame(
630 widget_params.routing_id, widget_params.surface_id, 629 widget_params.routing_id, widget_params.surface_id,
631 widget_params.hidden, render_frame->render_view_->screen_info(), 630 widget_params.hidden, render_frame->render_view_->screen_info(),
632 compositor_deps, web_frame); 631 compositor_deps, web_frame);
633 // TODO(kenrb): Observing shouldn't be necessary when we sort out 632 // TODO(kenrb): Observing shouldn't be necessary when we sort out
634 // WasShown and WasHidden, separating page-level visibility from 633 // WasShown and WasHidden, separating page-level visibility from
635 // frame-level visibility. 634 // frame-level visibility.
636 render_frame->render_widget_->RegisterRenderFrame(render_frame); 635 render_frame->render_widget_->RegisterRenderFrame(render_frame);
637 } 636 }
638 637
639 render_frame->Initialize(); 638 render_frame->Initialize(LOFI_DEFAULT);
640 } 639 }
641 640
642 // static 641 // static
643 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { 642 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
644 return RenderFrameImpl::FromWebFrame(web_frame); 643 return RenderFrameImpl::FromWebFrame(web_frame);
645 } 644 }
646 645
647 // static 646 // static
648 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { 647 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) {
649 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); 648 FrameMap::iterator iter = g_frame_map.Get().find(web_frame);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 #endif 729 #endif
731 has_played_media_(false), 730 has_played_media_(false),
732 devtools_agent_(nullptr), 731 devtools_agent_(nullptr),
733 geolocation_dispatcher_(NULL), 732 geolocation_dispatcher_(NULL),
734 push_messaging_dispatcher_(NULL), 733 push_messaging_dispatcher_(NULL),
735 presentation_dispatcher_(NULL), 734 presentation_dispatcher_(NULL),
736 screen_orientation_dispatcher_(NULL), 735 screen_orientation_dispatcher_(NULL),
737 manifest_manager_(NULL), 736 manifest_manager_(NULL),
738 accessibility_mode_(AccessibilityModeOff), 737 accessibility_mode_(AccessibilityModeOff),
739 renderer_accessibility_(NULL), 738 renderer_accessibility_(NULL),
739 lofi_state_(LOFI_DEFAULT),
740 weak_factory_(this) { 740 weak_factory_(this) {
741 std::pair<RoutingIDFrameMap::iterator, bool> result = 741 std::pair<RoutingIDFrameMap::iterator, bool> result =
742 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 742 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
743 CHECK(result.second) << "Inserting a duplicate item."; 743 CHECK(result.second) << "Inserting a duplicate item.";
744 744
745 RenderThread::Get()->AddRoute(routing_id_, this); 745 RenderThread::Get()->AddRoute(routing_id_, this);
746 746
747 render_view_->RegisterRenderFrame(this); 747 render_view_->RegisterRenderFrame(this);
748 748
749 // Everything below subclasses RenderFrameObserver and is automatically 749 // Everything below subclasses RenderFrameObserver and is automatically
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { 797 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) {
798 DCHECK(!frame_); 798 DCHECK(!frame_);
799 799
800 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( 800 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert(
801 std::make_pair(web_frame, this)); 801 std::make_pair(web_frame, this));
802 CHECK(result.second) << "Inserting a duplicate item."; 802 CHECK(result.second) << "Inserting a duplicate item.";
803 803
804 frame_ = web_frame; 804 frame_ = web_frame;
805 } 805 }
806 806
807 void RenderFrameImpl::Initialize() { 807 void RenderFrameImpl::Initialize(LoFiState lofi_state) {
808 is_subframe_ = !!frame_->parent(); 808 is_subframe_ = !!frame_->parent();
809 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); 809 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame();
810 lofi_state_ = lofi_state;
810 811
811 #if defined(ENABLE_PLUGINS) 812 #if defined(ENABLE_PLUGINS)
812 new PepperBrowserConnection(this); 813 new PepperBrowserConnection(this);
813 #endif 814 #endif
814 new SharedWorkerRepository(this); 815 new SharedWorkerRepository(this);
815 816
816 if (is_local_root_ && !render_frame_proxy_) { 817 if (is_local_root_ && !render_frame_proxy_) {
817 // DevToolsAgent is a RenderFrameObserver, and will destruct itself 818 // DevToolsAgent is a RenderFrameObserver, and will destruct itself
818 // when |this| is deleted. 819 // when |this| is deleted.
819 devtools_agent_ = new DevToolsAgent(this); 820 devtools_agent_ = new DevToolsAgent(this);
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 2217
2217 // Create the RenderFrame and WebLocalFrame, linking the two. 2218 // Create the RenderFrame and WebLocalFrame, linking the two.
2218 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( 2219 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(
2219 render_view_.get(), child_routing_id); 2220 render_view_.get(), child_routing_id);
2220 blink::WebLocalFrame* web_frame = 2221 blink::WebLocalFrame* web_frame =
2221 WebLocalFrame::create(scope, child_render_frame); 2222 WebLocalFrame::create(scope, child_render_frame);
2222 child_render_frame->SetWebFrame(web_frame); 2223 child_render_frame->SetWebFrame(web_frame);
2223 2224
2224 // Add the frame to the frame tree and initialize it. 2225 // Add the frame to the frame tree and initialize it.
2225 parent->appendChild(web_frame); 2226 parent->appendChild(web_frame);
2226 child_render_frame->Initialize(); 2227 child_render_frame->Initialize(lofi_state_);
2227 2228
2228 return web_frame; 2229 return web_frame;
2229 } 2230 }
2230 2231
2231 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { 2232 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) {
2232 // Only active frames are able to disown their opener. 2233 // Only active frames are able to disown their opener.
2233 if (!opener && is_swapped_out_) 2234 if (!opener && is_swapped_out_)
2234 return; 2235 return;
2235 2236
2236 // Only a local frame should be able to update another frame's opener. 2237 // Only a local frame should be able to update another frame's opener.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 2297
2297 void RenderFrameImpl::frameFocused() { 2298 void RenderFrameImpl::frameFocused() {
2298 Send(new FrameHostMsg_FrameFocused(routing_id_)); 2299 Send(new FrameHostMsg_FrameFocused(routing_id_));
2299 } 2300 }
2300 2301
2301 void RenderFrameImpl::willClose(blink::WebFrame* frame) { 2302 void RenderFrameImpl::willClose(blink::WebFrame* frame) {
2302 DCHECK(!frame_ || frame_ == frame); 2303 DCHECK(!frame_ || frame_ == frame);
2303 2304
2304 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); 2305 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose());
2305 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2306 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2306 FrameWillClose(frame)); 2307 FrameWillClose(frame, lofi_state_ == LOFI_ON));
2307 } 2308 }
2308 2309
2309 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame, 2310 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame,
2310 const blink::WebString& name) { 2311 const blink::WebString& name) {
2311 DCHECK(!frame_ || frame_ == frame); 2312 DCHECK(!frame_ || frame_ == frame);
2312 2313
2313 // TODO(alexmos): According to https://crbug.com/169110, sending window.name 2314 // TODO(alexmos): According to https://crbug.com/169110, sending window.name
2314 // updates may have performance implications for benchmarks like SunSpider. 2315 // updates may have performance implications for benchmarks like SunSpider.
2315 // For now, send these updates only for --site-per-process, which needs to 2316 // For now, send these updates only for --site-per-process, which needs to
2316 // replicate frame names to frame proxies, and when 2317 // replicate frame names to frame proxies, and when
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 const blink::WebHistoryItem& item, 2689 const blink::WebHistoryItem& item,
2689 blink::WebHistoryCommitType commit_type) { 2690 blink::WebHistoryCommitType commit_type) {
2690 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", 2691 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad",
2691 "id", routing_id_, 2692 "id", routing_id_,
2692 "url", GetLoadingUrl().possibly_invalid_spec()); 2693 "url", GetLoadingUrl().possibly_invalid_spec());
2693 DCHECK(!frame_ || frame_ == frame); 2694 DCHECK(!frame_ || frame_ == frame);
2694 DocumentState* document_state = 2695 DocumentState* document_state =
2695 DocumentState::FromDataSource(frame->dataSource()); 2696 DocumentState::FromDataSource(frame->dataSource());
2696 NavigationStateImpl* navigation_state = 2697 NavigationStateImpl* navigation_state =
2697 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 2698 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2699 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(
2700 frame->dataSource()->response());
2701 if (extra_data && extra_data->is_lofi())
nasko 2015/09/04 22:47:42 nit: Maybe use tertiary operator, which will fit a
megjablon 2015/09/09 20:54:16 Done.
2702 lofi_state_ = LOFI_ON;
2703 else
2704 lofi_state_ = LOFI_OFF;
2698 2705
2699 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 2706 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
2700 RenderFrameProxy* proxy = 2707 RenderFrameProxy* proxy =
2701 RenderFrameProxy::FromRoutingID(proxy_routing_id_); 2708 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
2702 CHECK(proxy); 2709 CHECK(proxy);
2703 proxy->web_frame()->swap(frame_); 2710 proxy->web_frame()->swap(frame_);
2704 proxy_routing_id_ = MSG_ROUTING_NONE; 2711 proxy_routing_id_ = MSG_ROUTING_NONE;
2705 2712
2706 // If this is the main frame going from a remote frame to a local frame, 2713 // If this is the main frame going from a remote frame to a local frame,
2707 // it needs to set RenderViewImpl's pointer for the main frame to itself 2714 // it needs to set RenderViewImpl's pointer for the main frame to itself
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 extra_data->set_allow_download( 3349 extra_data->set_allow_download(
3343 navigation_state->common_params().allow_download); 3350 navigation_state->common_params().allow_download);
3344 extra_data->set_transition_type(transition_type); 3351 extra_data->set_transition_type(transition_type);
3345 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3352 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3346 extra_data->set_transferred_request_child_id( 3353 extra_data->set_transferred_request_child_id(
3347 navigation_state->start_params().transferred_request_child_id); 3354 navigation_state->start_params().transferred_request_child_id);
3348 extra_data->set_transferred_request_request_id( 3355 extra_data->set_transferred_request_request_id(
3349 navigation_state->start_params().transferred_request_request_id); 3356 navigation_state->start_params().transferred_request_request_id);
3350 extra_data->set_service_worker_provider_id(provider_id); 3357 extra_data->set_service_worker_provider_id(provider_id);
3351 extra_data->set_stream_override(stream_override.Pass()); 3358 extra_data->set_stream_override(stream_override.Pass());
3359 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache)
3360 extra_data->set_lofi_state(LOFI_OFF);
3361 else
3362 extra_data->set_lofi_state(lofi_state_);
3352 request.setExtraData(extra_data); 3363 request.setExtraData(extra_data);
3353 3364
3354 // TODO(creis): Update prefetching to work with out-of-process iframes. 3365 // TODO(creis): Update prefetching to work with out-of-process iframes.
3355 WebFrame* top_frame = frame->top(); 3366 WebFrame* top_frame = frame->top();
3356 if (top_frame && top_frame->isWebLocalFrame()) { 3367 if (top_frame && top_frame->isWebLocalFrame()) {
3357 DocumentState* top_document_state = 3368 DocumentState* top_document_state =
3358 DocumentState::FromDataSource(top_frame->dataSource()); 3369 DocumentState::FromDataSource(top_frame->dataSource());
3359 if (top_document_state) { 3370 if (top_document_state) {
3360 // TODO(gavinp): separate out prefetching and prerender field trials 3371 // TODO(gavinp): separate out prefetching and prerender field trials
3361 // if the rel=prerender rel type is sticking around. 3372 // if the rel=prerender rel type is sticking around.
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4477 switches::kEnableBrowserSideNavigation); 4488 switches::kEnableBrowserSideNavigation);
4478 bool is_reload = IsReload(common_params.navigation_type); 4489 bool is_reload = IsReload(common_params.navigation_type);
4479 bool is_history_navigation = request_params.page_state.IsValid(); 4490 bool is_history_navigation = request_params.page_state.IsValid();
4480 WebURLRequest::CachePolicy cache_policy = 4491 WebURLRequest::CachePolicy cache_policy =
4481 WebURLRequest::UseProtocolCachePolicy; 4492 WebURLRequest::UseProtocolCachePolicy;
4482 RenderFrameImpl::PrepareRenderViewForNavigation( 4493 RenderFrameImpl::PrepareRenderViewForNavigation(
4483 common_params.url, request_params, &is_reload, &cache_policy); 4494 common_params.url, request_params, &is_reload, &cache_policy);
4484 4495
4485 GetContentClient()->SetActiveURL(common_params.url); 4496 GetContentClient()->SetActiveURL(common_params.url);
4486 4497
4498 lofi_state_ = (LoFiState) request_params.lofi_state;
4499
4487 // If this frame isn't in the same process as the main frame, it may naively 4500 // If this frame isn't in the same process as the main frame, it may naively
4488 // assume that this is the first navigation in the iframe, but this may not 4501 // assume that this is the first navigation in the iframe, but this may not
4489 // actually be the case. Inform the frame's state machine if this frame has 4502 // actually be the case. Inform the frame's state machine if this frame has
4490 // already committed other loads. 4503 // already committed other loads.
4491 if (request_params.has_committed_real_load && frame_->parent()) 4504 if (request_params.has_committed_real_load && frame_->parent())
4492 frame_->setCommittedFirstRealLoad(); 4505 frame_->setCommittedFirstRealLoad();
4493 4506
4494 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 4507 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
4495 // We cannot reload if we do not have any history state. This happens, for 4508 // We cannot reload if we do not have any history state. This happens, for
4496 // example, when recovering from a crash. 4509 // example, when recovering from a crash.
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
5113 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_)); 5126 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&mojo_shell_));
5114 mojo::ServiceProviderPtr service_provider; 5127 mojo::ServiceProviderPtr service_provider;
5115 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5128 mojo::URLRequestPtr request(mojo::URLRequest::New());
5116 request->url = mojo::String::From(url); 5129 request->url = mojo::String::From(url);
5117 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5130 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5118 nullptr, nullptr); 5131 nullptr, nullptr);
5119 return service_provider.Pass(); 5132 return service_provider.Pass();
5120 } 5133 }
5121 5134
5122 } // namespace content 5135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698