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

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: remove log statement and fix ResponseInfo::DeepCopy 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 #endif 719 #endif
721 has_played_media_(false), 720 has_played_media_(false),
722 devtools_agent_(nullptr), 721 devtools_agent_(nullptr),
723 geolocation_dispatcher_(NULL), 722 geolocation_dispatcher_(NULL),
724 push_messaging_dispatcher_(NULL), 723 push_messaging_dispatcher_(NULL),
725 presentation_dispatcher_(NULL), 724 presentation_dispatcher_(NULL),
726 screen_orientation_dispatcher_(NULL), 725 screen_orientation_dispatcher_(NULL),
727 manifest_manager_(NULL), 726 manifest_manager_(NULL),
728 accessibility_mode_(AccessibilityModeOff), 727 accessibility_mode_(AccessibilityModeOff),
729 renderer_accessibility_(NULL), 728 renderer_accessibility_(NULL),
730 weak_factory_(this) { 729 weak_factory_(this) {
davidben 2015/08/27 18:53:50 lofi_state_ is not initialized.
megjablon 2015/08/27 23:11:02 Done.
731 std::pair<RoutingIDFrameMap::iterator, bool> result = 730 std::pair<RoutingIDFrameMap::iterator, bool> result =
732 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 731 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
733 CHECK(result.second) << "Inserting a duplicate item."; 732 CHECK(result.second) << "Inserting a duplicate item.";
734 733
735 RenderThread::Get()->AddRoute(routing_id_, this); 734 RenderThread::Get()->AddRoute(routing_id_, this);
736 735
737 render_view_->RegisterRenderFrame(this); 736 render_view_->RegisterRenderFrame(this);
738 737
739 // Everything below subclasses RenderFrameObserver and is automatically 738 // Everything below subclasses RenderFrameObserver and is automatically
740 // deleted when the RenderFrame gets deleted. 739 // deleted when the RenderFrame gets deleted.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { 788 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) {
790 DCHECK(!frame_); 789 DCHECK(!frame_);
791 790
792 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( 791 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert(
793 std::make_pair(web_frame, this)); 792 std::make_pair(web_frame, this));
794 CHECK(result.second) << "Inserting a duplicate item."; 793 CHECK(result.second) << "Inserting a duplicate item.";
795 794
796 frame_ = web_frame; 795 frame_ = web_frame;
797 } 796 }
798 797
799 void RenderFrameImpl::Initialize() { 798 void RenderFrameImpl::Initialize(LoFiState lofi_state) {
800 is_subframe_ = !!frame_->parent(); 799 is_subframe_ = !!frame_->parent();
801 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame(); 800 is_local_root_ = !frame_->parent() || frame_->parent()->isWebRemoteFrame();
801 lofi_state_ = lofi_state;
802 802
803 #if defined(ENABLE_PLUGINS) 803 #if defined(ENABLE_PLUGINS)
804 new PepperBrowserConnection(this); 804 new PepperBrowserConnection(this);
805 #endif 805 #endif
806 new SharedWorkerRepository(this); 806 new SharedWorkerRepository(this);
807 807
808 if (is_local_root_ && !render_frame_proxy_) { 808 if (is_local_root_ && !render_frame_proxy_) {
809 // DevToolsAgent is a RenderFrameObserver, and will destruct itself 809 // DevToolsAgent is a RenderFrameObserver, and will destruct itself
810 // when |this| is deleted. 810 // when |this| is deleted.
811 devtools_agent_ = new DevToolsAgent(this); 811 devtools_agent_ = new DevToolsAgent(this);
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 2211
2212 // Create the RenderFrame and WebLocalFrame, linking the two. 2212 // Create the RenderFrame and WebLocalFrame, linking the two.
2213 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create( 2213 RenderFrameImpl* child_render_frame = RenderFrameImpl::Create(
2214 render_view_.get(), child_routing_id); 2214 render_view_.get(), child_routing_id);
2215 blink::WebLocalFrame* web_frame = 2215 blink::WebLocalFrame* web_frame =
2216 WebLocalFrame::create(scope, child_render_frame); 2216 WebLocalFrame::create(scope, child_render_frame);
2217 child_render_frame->SetWebFrame(web_frame); 2217 child_render_frame->SetWebFrame(web_frame);
2218 2218
2219 // Add the frame to the frame tree and initialize it. 2219 // Add the frame to the frame tree and initialize it.
2220 parent->appendChild(web_frame); 2220 parent->appendChild(web_frame);
2221 child_render_frame->Initialize(); 2221 child_render_frame->Initialize(lofi_state_);
2222 2222
2223 return web_frame; 2223 return web_frame;
2224 } 2224 }
2225 2225
2226 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) { 2226 void RenderFrameImpl::didChangeOpener(blink::WebFrame* opener) {
2227 // Only active frames are able to disown their opener. 2227 // Only active frames are able to disown their opener.
2228 if (!opener && is_swapped_out_) 2228 if (!opener && is_swapped_out_)
2229 return; 2229 return;
2230 2230
2231 // Only a local frame should be able to update another frame's opener. 2231 // 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
2291 2291
2292 void RenderFrameImpl::frameFocused() { 2292 void RenderFrameImpl::frameFocused() {
2293 Send(new FrameHostMsg_FrameFocused(routing_id_)); 2293 Send(new FrameHostMsg_FrameFocused(routing_id_));
2294 } 2294 }
2295 2295
2296 void RenderFrameImpl::willClose(blink::WebFrame* frame) { 2296 void RenderFrameImpl::willClose(blink::WebFrame* frame) {
2297 DCHECK(!frame_ || frame_ == frame); 2297 DCHECK(!frame_ || frame_ == frame);
2298 2298
2299 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose()); 2299 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, FrameWillClose());
2300 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 2300 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
2301 FrameWillClose(frame)); 2301 FrameWillClose(frame, lofi_state_ == LOFI_ON));
2302 } 2302 }
2303 2303
2304 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame, 2304 void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame,
2305 const blink::WebString& name) { 2305 const blink::WebString& name) {
2306 DCHECK(!frame_ || frame_ == frame); 2306 DCHECK(!frame_ || frame_ == frame);
2307 2307
2308 // TODO(alexmos): According to https://crbug.com/169110, sending window.name 2308 // TODO(alexmos): According to https://crbug.com/169110, sending window.name
2309 // updates may have performance implications for benchmarks like SunSpider. 2309 // updates may have performance implications for benchmarks like SunSpider.
2310 // For now, send these updates only for --site-per-process, which needs to 2310 // For now, send these updates only for --site-per-process, which needs to
2311 // replicate frame names to frame proxies, and when 2311 // replicate frame names to frame proxies, and when
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 const blink::WebHistoryItem& item, 2683 const blink::WebHistoryItem& item,
2684 blink::WebHistoryCommitType commit_type) { 2684 blink::WebHistoryCommitType commit_type) {
2685 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", 2685 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad",
2686 "id", routing_id_, 2686 "id", routing_id_,
2687 "url", GetLoadingUrl().possibly_invalid_spec()); 2687 "url", GetLoadingUrl().possibly_invalid_spec());
2688 DCHECK(!frame_ || frame_ == frame); 2688 DCHECK(!frame_ || frame_ == frame);
2689 DocumentState* document_state = 2689 DocumentState* document_state =
2690 DocumentState::FromDataSource(frame->dataSource()); 2690 DocumentState::FromDataSource(frame->dataSource());
2691 NavigationStateImpl* navigation_state = 2691 NavigationStateImpl* navigation_state =
2692 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 2692 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2693 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(
2694 frame->dataSource()->response());
2695 if (extra_data && extra_data->is_lofi())
2696 lofi_state_ = LOFI_ON;
2697 else
2698 lofi_state_ = LOFI_OFF;
2693 2699
2694 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 2700 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
2695 RenderFrameProxy* proxy = 2701 RenderFrameProxy* proxy =
2696 RenderFrameProxy::FromRoutingID(proxy_routing_id_); 2702 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
2697 CHECK(proxy); 2703 CHECK(proxy);
2698 proxy->web_frame()->swap(frame_); 2704 proxy->web_frame()->swap(frame_);
2699 proxy_routing_id_ = MSG_ROUTING_NONE; 2705 proxy_routing_id_ = MSG_ROUTING_NONE;
2700 2706
2701 // If this is the main frame going from a remote frame to a local frame, 2707 // If this is the main frame going from a remote frame to a local frame,
2702 // it needs to set RenderViewImpl's pointer for the main frame to itself 2708 // 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
3337 extra_data->set_allow_download( 3343 extra_data->set_allow_download(
3338 navigation_state->common_params().allow_download); 3344 navigation_state->common_params().allow_download);
3339 extra_data->set_transition_type(transition_type); 3345 extra_data->set_transition_type(transition_type);
3340 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3346 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3341 extra_data->set_transferred_request_child_id( 3347 extra_data->set_transferred_request_child_id(
3342 navigation_state->start_params().transferred_request_child_id); 3348 navigation_state->start_params().transferred_request_child_id);
3343 extra_data->set_transferred_request_request_id( 3349 extra_data->set_transferred_request_request_id(
3344 navigation_state->start_params().transferred_request_request_id); 3350 navigation_state->start_params().transferred_request_request_id);
3345 extra_data->set_service_worker_provider_id(provider_id); 3351 extra_data->set_service_worker_provider_id(provider_id);
3346 extra_data->set_stream_override(stream_override.Pass()); 3352 extra_data->set_stream_override(stream_override.Pass());
3353 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache)
davidben 2015/08/31 23:43:24 Why isn't this coming from the navigation paramete
megjablon 2015/09/02 21:25:42 This is for the single image and page reloads whic
davidben 2015/09/04 14:41:22 I see. This should at least have a TODO comment wi
megjablon 2015/09/09 20:54:16 Done.
3354 extra_data->set_lofi_state(LOFI_OFF);
3355 else
3356 extra_data->set_lofi_state(lofi_state_);
3347 request.setExtraData(extra_data); 3357 request.setExtraData(extra_data);
3348 3358
3349 // TODO(creis): Update prefetching to work with out-of-process iframes. 3359 // TODO(creis): Update prefetching to work with out-of-process iframes.
3350 WebFrame* top_frame = frame->top(); 3360 WebFrame* top_frame = frame->top();
3351 if (top_frame && top_frame->isWebLocalFrame()) { 3361 if (top_frame && top_frame->isWebLocalFrame()) {
3352 DocumentState* top_document_state = 3362 DocumentState* top_document_state =
3353 DocumentState::FromDataSource(top_frame->dataSource()); 3363 DocumentState::FromDataSource(top_frame->dataSource());
3354 if (top_document_state) { 3364 if (top_document_state) {
3355 // TODO(gavinp): separate out prefetching and prerender field trials 3365 // TODO(gavinp): separate out prefetching and prerender field trials
3356 // if the rel=prerender rel type is sticking around. 3366 // if the rel=prerender rel type is sticking around.
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 switches::kEnableBrowserSideNavigation); 4489 switches::kEnableBrowserSideNavigation);
4480 bool is_reload = IsReload(common_params.navigation_type); 4490 bool is_reload = IsReload(common_params.navigation_type);
4481 bool is_history_navigation = request_params.page_state.IsValid(); 4491 bool is_history_navigation = request_params.page_state.IsValid();
4482 WebURLRequest::CachePolicy cache_policy = 4492 WebURLRequest::CachePolicy cache_policy =
4483 WebURLRequest::UseProtocolCachePolicy; 4493 WebURLRequest::UseProtocolCachePolicy;
4484 RenderFrameImpl::PrepareRenderViewForNavigation( 4494 RenderFrameImpl::PrepareRenderViewForNavigation(
4485 common_params.url, request_params, &is_reload, &cache_policy); 4495 common_params.url, request_params, &is_reload, &cache_policy);
4486 4496
4487 GetContentClient()->SetActiveURL(common_params.url); 4497 GetContentClient()->SetActiveURL(common_params.url);
4488 4498
4499 lofi_state_ = (LoFiState) request_params.lofi_state;
4500
4489 // If this frame isn't in the same process as the main frame, it may naively 4501 // If this frame isn't in the same process as the main frame, it may naively
4490 // assume that this is the first navigation in the iframe, but this may not 4502 // assume that this is the first navigation in the iframe, but this may not
4491 // actually be the case. Inform the frame's state machine if this frame has 4503 // actually be the case. Inform the frame's state machine if this frame has
4492 // already committed other loads. 4504 // already committed other loads.
4493 if (request_params.has_committed_real_load && frame_->parent()) 4505 if (request_params.has_committed_real_load && frame_->parent())
4494 frame_->setCommittedFirstRealLoad(); 4506 frame_->setCommittedFirstRealLoad();
4495 4507
4496 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 4508 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
4497 // We cannot reload if we do not have any history state. This happens, for 4509 // We cannot reload if we do not have any history state. This happens, for
4498 // example, when recovering from a crash. 4510 // example, when recovering from a crash.
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
5120 DCHECK(mojo_shell_); 5132 DCHECK(mojo_shell_);
5121 mojo::ServiceProviderPtr service_provider; 5133 mojo::ServiceProviderPtr service_provider;
5122 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5134 mojo::URLRequestPtr request(mojo::URLRequest::New());
5123 request->url = mojo::String::From(url); 5135 request->url = mojo::String::From(url);
5124 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5136 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5125 nullptr, nullptr); 5137 nullptr, nullptr);
5126 return service_provider.Pass(); 5138 return service_provider.Pass();
5127 } 5139 }
5128 5140
5129 } // namespace content 5141 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698