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

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: mmenke comments 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
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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // CommitNavigation IPC, and then back to the browser again in the 487 // CommitNavigation IPC, and then back to the browser again in the
488 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. 488 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs.
489 base::TimeTicks ui_timestamp = 489 base::TimeTicks ui_timestamp =
490 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); 490 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime());
491 FrameMsg_UILoadMetricsReportType::Value report_type = 491 FrameMsg_UILoadMetricsReportType::Value report_type =
492 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 492 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
493 request->inputPerfMetricReportPolicy()); 493 request->inputPerfMetricReportPolicy());
494 return CommonNavigationParams( 494 return CommonNavigationParams(
495 request->url(), referrer, extra_data->transition_type(), 495 request->url(), referrer, extra_data->transition_type(),
496 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, 496 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry,
497 ui_timestamp, report_type, GURL(), GURL()); 497 ui_timestamp, report_type, GURL(), GURL(), LOFI_UNSPECIFIED);
498 } 498 }
499 499
500 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) 500 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID)
501 media::Context3D GetSharedMainThreadContext3D() { 501 media::Context3D GetSharedMainThreadContext3D() {
502 cc::ContextProvider* provider = 502 cc::ContextProvider* provider =
503 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); 503 RenderThreadImpl::current()->SharedMainThreadContextProvider().get();
504 if (!provider) 504 if (!provider)
505 return media::Context3D(); 505 return media::Context3D();
506 return media::Context3D(provider->ContextGL(), provider->GrContext()); 506 return media::Context3D(provider->ContextGL(), provider->GrContext());
507 } 507 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 #endif 714 #endif
715 has_played_media_(false), 715 has_played_media_(false),
716 devtools_agent_(nullptr), 716 devtools_agent_(nullptr),
717 geolocation_dispatcher_(NULL), 717 geolocation_dispatcher_(NULL),
718 push_messaging_dispatcher_(NULL), 718 push_messaging_dispatcher_(NULL),
719 presentation_dispatcher_(NULL), 719 presentation_dispatcher_(NULL),
720 screen_orientation_dispatcher_(NULL), 720 screen_orientation_dispatcher_(NULL),
721 manifest_manager_(NULL), 721 manifest_manager_(NULL),
722 accessibility_mode_(AccessibilityModeOff), 722 accessibility_mode_(AccessibilityModeOff),
723 renderer_accessibility_(NULL), 723 renderer_accessibility_(NULL),
724 is_using_lofi_(false),
724 weak_factory_(this) { 725 weak_factory_(this) {
725 std::pair<RoutingIDFrameMap::iterator, bool> result = 726 std::pair<RoutingIDFrameMap::iterator, bool> result =
726 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 727 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
727 CHECK(result.second) << "Inserting a duplicate item."; 728 CHECK(result.second) << "Inserting a duplicate item.";
728 729
729 RenderThread::Get()->AddRoute(routing_id_, this); 730 RenderThread::Get()->AddRoute(routing_id_, this);
730 731
731 render_view_->RegisterRenderFrame(this); 732 render_view_->RegisterRenderFrame(this);
732 733
733 // Everything below subclasses RenderFrameObserver and is automatically 734 // Everything below subclasses RenderFrameObserver and is automatically
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 std::make_pair(web_frame, this)); 789 std::make_pair(web_frame, this));
789 CHECK(result.second) << "Inserting a duplicate item."; 790 CHECK(result.second) << "Inserting a duplicate item.";
790 791
791 frame_ = web_frame; 792 frame_ = web_frame;
792 } 793 }
793 794
794 void RenderFrameImpl::Initialize() { 795 void RenderFrameImpl::Initialize() {
795 is_main_frame_ = !frame_->parent(); 796 is_main_frame_ = !frame_->parent();
796 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame(); 797 is_local_root_ = is_main_frame_ || frame_->parent()->isWebRemoteFrame();
797 798
799 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame(
800 frame_->parent());
801 if (parent_frame)
802 is_using_lofi_ = parent_frame->IsUsingLoFi();
803
798 bool is_tracing = false; 804 bool is_tracing = false;
799 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing); 805 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing);
800 if (is_tracing) { 806 if (is_tracing) {
801 int parent_id = MSG_ROUTING_NONE; 807 int parent_id = MSG_ROUTING_NONE;
802 if (!is_main_frame_) { 808 if (!is_main_frame_) {
803 if (frame_->parent()->isWebRemoteFrame()) { 809 if (frame_->parent()->isWebRemoteFrame()) {
804 RenderFrameProxy* parent_proxy = RenderFrameProxy::FromWebFrame( 810 RenderFrameProxy* parent_proxy = RenderFrameProxy::FromWebFrame(
805 frame_->parent()); 811 frame_->parent());
806 if (parent_proxy) 812 if (parent_proxy)
807 parent_id = parent_proxy->routing_id(); 813 parent_id = parent_proxy->routing_id();
808 } else { 814 } else {
809 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame(
810 frame_->parent());
811 if (parent_frame) 815 if (parent_frame)
812 parent_id = parent_frame->GetRoutingID(); 816 parent_id = parent_frame->GetRoutingID();
813 } 817 }
814 } 818 }
815 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize", 819 TRACE_EVENT2("navigation", "RenderFrameImpl::Initialize",
816 "id", routing_id_, 820 "id", routing_id_,
817 "parent", parent_id); 821 "parent", parent_id);
818 } 822 }
819 823
820 #if defined(ENABLE_PLUGINS) 824 #if defined(ENABLE_PLUGINS)
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 ServiceRegistryJsWrapper::kModuleName, 2019 ServiceRegistryJsWrapper::kModuleName,
2016 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8()); 2020 ServiceRegistryJsWrapper::Create(isolate, &service_registry_).ToV8());
2017 } 2021 }
2018 2022
2019 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, 2023 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level,
2020 const std::string& message) { 2024 const std::string& message) {
2021 if (devtools_agent_) 2025 if (devtools_agent_)
2022 devtools_agent_->AddMessageToConsole(level, message); 2026 devtools_agent_->AddMessageToConsole(level, message);
2023 } 2027 }
2024 2028
2029 const bool RenderFrameImpl::IsUsingLoFi() {
2030 return is_using_lofi_;
2031 }
2032
2025 // blink::WebFrameClient implementation ---------------------------------------- 2033 // blink::WebFrameClient implementation ----------------------------------------
2026 2034
2027 blink::WebPlugin* RenderFrameImpl::createPlugin( 2035 blink::WebPlugin* RenderFrameImpl::createPlugin(
2028 blink::WebLocalFrame* frame, 2036 blink::WebLocalFrame* frame,
2029 const blink::WebPluginParams& params) { 2037 const blink::WebPluginParams& params) {
2030 DCHECK_EQ(frame_, frame); 2038 DCHECK_EQ(frame_, frame);
2031 blink::WebPlugin* plugin = NULL; 2039 blink::WebPlugin* plugin = NULL;
2032 if (GetContentClient()->renderer()->OverrideCreatePlugin( 2040 if (GetContentClient()->renderer()->OverrideCreatePlugin(
2033 this, frame, params, &plugin)) { 2041 this, frame, params, &plugin)) {
2034 return plugin; 2042 return plugin;
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 const blink::WebHistoryItem& item, 2722 const blink::WebHistoryItem& item,
2715 blink::WebHistoryCommitType commit_type) { 2723 blink::WebHistoryCommitType commit_type) {
2716 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad", 2724 TRACE_EVENT2("navigation", "RenderFrameImpl::didCommitProvisionalLoad",
2717 "id", routing_id_, 2725 "id", routing_id_,
2718 "url", GetLoadingUrl().possibly_invalid_spec()); 2726 "url", GetLoadingUrl().possibly_invalid_spec());
2719 DCHECK(!frame_ || frame_ == frame); 2727 DCHECK(!frame_ || frame_ == frame);
2720 DocumentState* document_state = 2728 DocumentState* document_state =
2721 DocumentState::FromDataSource(frame->dataSource()); 2729 DocumentState::FromDataSource(frame->dataSource());
2722 NavigationStateImpl* navigation_state = 2730 NavigationStateImpl* navigation_state =
2723 static_cast<NavigationStateImpl*>(document_state->navigation_state()); 2731 static_cast<NavigationStateImpl*>(document_state->navigation_state());
2732 WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(
2733 frame->dataSource()->response());
2734 is_using_lofi_ = extra_data && extra_data->is_using_lofi();
2724 2735
2725 if (proxy_routing_id_ != MSG_ROUTING_NONE) { 2736 if (proxy_routing_id_ != MSG_ROUTING_NONE) {
2726 RenderFrameProxy* proxy = 2737 RenderFrameProxy* proxy =
2727 RenderFrameProxy::FromRoutingID(proxy_routing_id_); 2738 RenderFrameProxy::FromRoutingID(proxy_routing_id_);
2728 CHECK(proxy); 2739 CHECK(proxy);
2729 proxy->web_frame()->swap(frame_); 2740 proxy->web_frame()->swap(frame_);
2730 proxy_routing_id_ = MSG_ROUTING_NONE; 2741 proxy_routing_id_ = MSG_ROUTING_NONE;
2731 2742
2732 // If this is the main frame going from a remote frame to a local frame, 2743 // If this is the main frame going from a remote frame to a local frame,
2733 // it needs to set RenderViewImpl's pointer for the main frame to itself 2744 // it needs to set RenderViewImpl's pointer for the main frame to itself
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 extra_data->set_allow_download( 3392 extra_data->set_allow_download(
3382 navigation_state->common_params().allow_download); 3393 navigation_state->common_params().allow_download);
3383 extra_data->set_transition_type(transition_type); 3394 extra_data->set_transition_type(transition_type);
3384 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3395 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3385 extra_data->set_transferred_request_child_id( 3396 extra_data->set_transferred_request_child_id(
3386 navigation_state->start_params().transferred_request_child_id); 3397 navigation_state->start_params().transferred_request_child_id);
3387 extra_data->set_transferred_request_request_id( 3398 extra_data->set_transferred_request_request_id(
3388 navigation_state->start_params().transferred_request_request_id); 3399 navigation_state->start_params().transferred_request_request_id);
3389 extra_data->set_service_worker_provider_id(provider_id); 3400 extra_data->set_service_worker_provider_id(provider_id);
3390 extra_data->set_stream_override(stream_override.Pass()); 3401 extra_data->set_stream_override(stream_override.Pass());
3402 // TODO(megjablon): Set the navigation params for single image loads to
3403 // LOFI_OFF and remove the dependency on ReloadBypassingCache.
3404 if (request.cachePolicy() == WebURLRequest::ReloadBypassingCache)
3405 extra_data->set_lofi_state(LOFI_OFF);
3406 else if (is_main_frame_ && !navigation_state->request_committed())
3407 extra_data->set_lofi_state(navigation_state->common_params().lofi_state);
3408 else
3409 extra_data->set_lofi_state(is_using_lofi_ ? LOFI_ON : LOFI_OFF);
3391 request.setExtraData(extra_data); 3410 request.setExtraData(extra_data);
3392 3411
3393 // TODO(creis): Update prefetching to work with out-of-process iframes. 3412 // TODO(creis): Update prefetching to work with out-of-process iframes.
3394 WebFrame* top_frame = frame->top(); 3413 WebFrame* top_frame = frame->top();
3395 if (top_frame && top_frame->isWebLocalFrame()) { 3414 if (top_frame && top_frame->isWebLocalFrame()) {
3396 DocumentState* top_document_state = 3415 DocumentState* top_document_state =
3397 DocumentState::FromDataSource(top_frame->dataSource()); 3416 DocumentState::FromDataSource(top_frame->dataSource());
3398 if (top_document_state) { 3417 if (top_document_state) {
3399 // TODO(gavinp): separate out prefetching and prerender field trials 3418 // TODO(gavinp): separate out prefetching and prerender field trials
3400 // if the rel=prerender rel type is sticking around. 3419 // if the rel=prerender rel type is sticking around.
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
5214 mojo::ServiceProviderPtr service_provider(21); 5233 mojo::ServiceProviderPtr service_provider(21);
5215 mojo::URLRequestPtr request(mojo::URLRequest::New()); 5234 mojo::URLRequestPtr request(mojo::URLRequest::New());
5216 request->url = mojo::String::From(url); 5235 request->url = mojo::String::From(url);
5217 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), 5236 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider),
5218 nullptr, nullptr, 5237 nullptr, nullptr,
5219 base::Bind(&OnGotContentHandlerID)); 5238 base::Bind(&OnGotContentHandlerID));
5220 return service_provider.Pass(); 5239 return service_provider.Pass();
5221 } 5240 }
5222 5241
5223 } // namespace content 5242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698