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

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

Issue 1858533002: Introduce WebCachePolicy to merge cache policy enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hiroshige review Created 4 years, 8 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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #include "media/blink/webmediaplayer_impl.h" 141 #include "media/blink/webmediaplayer_impl.h"
142 #include "media/renderers/gpu_video_accelerator_factories.h" 142 #include "media/renderers/gpu_video_accelerator_factories.h"
143 #include "mojo/common/url_type_converters.h" 143 #include "mojo/common/url_type_converters.h"
144 #include "mojo/edk/js/core.h" 144 #include "mojo/edk/js/core.h"
145 #include "mojo/edk/js/support.h" 145 #include "mojo/edk/js/support.h"
146 #include "net/base/data_url.h" 146 #include "net/base/data_url.h"
147 #include "net/base/net_errors.h" 147 #include "net/base/net_errors.h"
148 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 148 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
149 #include "net/http/http_util.h" 149 #include "net/http/http_util.h"
150 #include "third_party/WebKit/public/platform/URLConversion.h" 150 #include "third_party/WebKit/public/platform/URLConversion.h"
151 #include "third_party/WebKit/public/platform/WebCachePolicy.h"
151 #include "third_party/WebKit/public/platform/WebData.h" 152 #include "third_party/WebKit/public/platform/WebData.h"
152 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 153 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
153 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 154 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
154 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 155 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
155 #include "third_party/WebKit/public/platform/WebString.h" 156 #include "third_party/WebKit/public/platform/WebString.h"
156 #include "third_party/WebKit/public/platform/WebURL.h" 157 #include "third_party/WebKit/public/platform/WebURL.h"
157 #include "third_party/WebKit/public/platform/WebURLError.h" 158 #include "third_party/WebKit/public/platform/WebURLError.h"
158 #include "third_party/WebKit/public/platform/WebURLResponse.h" 159 #include "third_party/WebKit/public/platform/WebURLResponse.h"
159 #include "third_party/WebKit/public/platform/WebVector.h" 160 #include "third_party/WebKit/public/platform/WebVector.h"
160 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" 161 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 #endif 236 #endif
236 237
237 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) 238 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER)
238 #include "media/mojo/services/mojo_decoder_factory.h" // nogncheck 239 #include "media/mojo/services/mojo_decoder_factory.h" // nogncheck
239 #endif 240 #endif
240 241
241 #if defined(ENABLE_WEBVR) 242 #if defined(ENABLE_WEBVR)
242 #include "content/renderer/vr/vr_dispatcher.h" 243 #include "content/renderer/vr/vr_dispatcher.h"
243 #endif 244 #endif
244 245
246 using blink::WebCachePolicy;
245 using blink::WebContentDecryptionModule; 247 using blink::WebContentDecryptionModule;
246 using blink::WebContextMenuData; 248 using blink::WebContextMenuData;
247 using blink::WebCString; 249 using blink::WebCString;
248 using blink::WebData; 250 using blink::WebData;
249 using blink::WebDataSource; 251 using blink::WebDataSource;
250 using blink::WebDocument; 252 using blink::WebDocument;
251 using blink::WebDOMEvent; 253 using blink::WebDOMEvent;
252 using blink::WebDOMMessageEvent; 254 using blink::WebDOMMessageEvent;
253 using blink::WebElement; 255 using blink::WebElement;
254 using blink::WebExternalPopupMenu; 256 using blink::WebExternalPopupMenu;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 bool IsTopLevelNavigation(WebFrame* frame) { 502 bool IsTopLevelNavigation(WebFrame* frame) {
501 return frame->parent() == NULL; 503 return frame->parent() == NULL;
502 } 504 }
503 505
504 WebURLRequest CreateURLRequestForNavigation( 506 WebURLRequest CreateURLRequestForNavigation(
505 const CommonNavigationParams& common_params, 507 const CommonNavigationParams& common_params,
506 scoped_ptr<StreamOverrideParameters> stream_override, 508 scoped_ptr<StreamOverrideParameters> stream_override,
507 bool is_view_source_mode_enabled) { 509 bool is_view_source_mode_enabled) {
508 WebURLRequest request(common_params.url); 510 WebURLRequest request(common_params.url);
509 if (is_view_source_mode_enabled) 511 if (is_view_source_mode_enabled)
510 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); 512 request.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad);
511 513
512 if (common_params.referrer.url.is_valid()) { 514 if (common_params.referrer.url.is_valid()) {
513 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader( 515 WebString web_referrer = WebSecurityPolicy::generateReferrerHeader(
514 common_params.referrer.policy, 516 common_params.referrer.policy,
515 common_params.url, 517 common_params.url,
516 WebString::fromUTF8(common_params.referrer.url.spec())); 518 WebString::fromUTF8(common_params.referrer.url.spec()));
517 if (!web_referrer.isEmpty()) 519 if (!web_referrer.isEmpty())
518 request.setHTTPReferrer(web_referrer, common_params.referrer.policy); 520 request.setHTTPReferrer(web_referrer, common_params.referrer.policy);
519 } 521 }
520 522
(...skipping 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 break; 2929 break;
2928 } 2930 }
2929 } 2931 }
2930 } 2932 }
2931 } 2933 }
2932 } 2934 }
2933 2935
2934 if (content_initiated) { 2936 if (content_initiated) {
2935 const WebURLRequest& request = datasource->request(); 2937 const WebURLRequest& request = datasource->request();
2936 switch (request.getCachePolicy()) { 2938 switch (request.getCachePolicy()) {
2937 case WebURLRequest::UseProtocolCachePolicy: // normal load. 2939 case WebCachePolicy::UseProtocolCachePolicy: // normal load.
2938 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); 2940 document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL);
2939 break; 2941 break;
2940 case WebURLRequest::ValidatingCacheData: // reload. 2942 case WebCachePolicy::ValidatingCacheData: // reload.
2941 case WebURLRequest::BypassingCache: // end-to-end reload. 2943 case WebCachePolicy::BypassingCache: // end-to-end reload.
2942 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); 2944 document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD);
2943 break; 2945 break;
2944 case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. 2946 case WebCachePolicy::ReturnCacheDataElseLoad: // allow stale data.
2945 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); 2947 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK);
2946 break; 2948 break;
2947 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. 2949 case WebCachePolicy::ReturnCacheDataDontLoad: // Don't re-post.
2948 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); 2950 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY);
2949 break; 2951 break;
2950 default: 2952 default:
2951 NOTREACHED(); 2953 NOTREACHED();
2952 } 2954 }
2953 } 2955 }
2954 2956
2955 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( 2957 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
2956 document_state->navigation_state()); 2958 document_state->navigation_state());
2957 2959
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
4626 } 4628 }
4627 4629
4628 // PlzNavigate 4630 // PlzNavigate
4629 void RenderFrameImpl::OnFailedNavigation( 4631 void RenderFrameImpl::OnFailedNavigation(
4630 const CommonNavigationParams& common_params, 4632 const CommonNavigationParams& common_params,
4631 const RequestNavigationParams& request_params, 4633 const RequestNavigationParams& request_params,
4632 bool has_stale_copy_in_cache, 4634 bool has_stale_copy_in_cache,
4633 int error_code) { 4635 int error_code) {
4634 DCHECK(IsBrowserSideNavigationEnabled()); 4636 DCHECK(IsBrowserSideNavigationEnabled());
4635 bool is_reload = IsReload(common_params.navigation_type); 4637 bool is_reload = IsReload(common_params.navigation_type);
4636 WebURLRequest::CachePolicy cache_policy =
4637 WebURLRequest::UseProtocolCachePolicy;
4638 RenderFrameImpl::PrepareRenderViewForNavigation( 4638 RenderFrameImpl::PrepareRenderViewForNavigation(
4639 common_params.url, request_params, &is_reload, &cache_policy); 4639 common_params.url, request_params);
4640 4640
4641 GetContentClient()->SetActiveURL(common_params.url); 4641 GetContentClient()->SetActiveURL(common_params.url);
4642 4642
4643 // If this frame isn't in the same process as the main frame, it may naively 4643 // If this frame isn't in the same process as the main frame, it may naively
4644 // assume that this is the first navigation in the iframe, but this may not 4644 // assume that this is the first navigation in the iframe, but this may not
4645 // actually be the case. Inform the frame's state machine if this frame has 4645 // actually be the case. Inform the frame's state machine if this frame has
4646 // already committed other loads. 4646 // already committed other loads.
4647 if (request_params.has_committed_real_load && frame_->parent()) 4647 if (request_params.has_committed_real_load && frame_->parent())
4648 frame_->setCommittedFirstRealLoad(); 4648 frame_->setCommittedFirstRealLoad();
4649 4649
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
5216 const CommonNavigationParams& common_params, 5216 const CommonNavigationParams& common_params,
5217 const StartNavigationParams& start_params, 5217 const StartNavigationParams& start_params,
5218 const RequestNavigationParams& request_params, 5218 const RequestNavigationParams& request_params,
5219 scoped_ptr<StreamOverrideParameters> stream_params) { 5219 scoped_ptr<StreamOverrideParameters> stream_params) {
5220 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); 5220 bool browser_side_navigation = IsBrowserSideNavigationEnabled();
5221 5221
5222 // Lower bound for browser initiated navigation start time. 5222 // Lower bound for browser initiated navigation start time.
5223 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 5223 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
5224 bool is_reload = IsReload(common_params.navigation_type); 5224 bool is_reload = IsReload(common_params.navigation_type);
5225 bool is_history_navigation = request_params.page_state.IsValid(); 5225 bool is_history_navigation = request_params.page_state.IsValid();
5226 WebURLRequest::CachePolicy cache_policy = 5226 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy;
5227 WebURLRequest::UseProtocolCachePolicy;
5228 RenderFrameImpl::PrepareRenderViewForNavigation( 5227 RenderFrameImpl::PrepareRenderViewForNavigation(
5229 common_params.url, request_params, &is_reload, &cache_policy); 5228 common_params.url, request_params);
5230 5229
5231 GetContentClient()->SetActiveURL(common_params.url); 5230 GetContentClient()->SetActiveURL(common_params.url);
5232 5231
5233 // If this frame isn't in the same process as the main frame, it may naively 5232 // If this frame isn't in the same process as the main frame, it may naively
5234 // assume that this is the first navigation in the iframe, but this may not 5233 // assume that this is the first navigation in the iframe, but this may not
5235 // actually be the case. Inform the frame's state machine if this frame has 5234 // actually be the case. Inform the frame's state machine if this frame has
5236 // already committed other loads. 5235 // already committed other loads.
5237 if (request_params.has_committed_real_load && frame_->parent()) 5236 if (request_params.has_committed_real_load && frame_->parent())
5238 frame_->setCommittedFirstRealLoad(); 5237 frame_->setCommittedFirstRealLoad();
5239 5238
5240 bool no_current_entry = 5239 bool no_current_entry =
5241 SiteIsolationPolicy::UseSubframeNavigationEntries() 5240 SiteIsolationPolicy::UseSubframeNavigationEntries()
5242 ? current_history_item_.isNull() 5241 ? current_history_item_.isNull()
5243 : !render_view_->history_controller()->GetCurrentEntry(); 5242 : !render_view_->history_controller()->GetCurrentEntry();
5244 if (is_reload && no_current_entry) { 5243 if (is_reload && no_current_entry) {
5245 // We cannot reload if we do not have any history state. This happens, for 5244 // We cannot reload if we do not have any history state. This happens, for
5246 // example, when recovering from a crash. 5245 // example, when recovering from a crash.
5247 is_reload = false; 5246 is_reload = false;
5248 cache_policy = WebURLRequest::ValidatingCacheData; 5247 cache_policy = WebCachePolicy::ValidatingCacheData;
5249 } 5248 }
5250 5249
5251 // If the navigation is for "view source", the WebLocalFrame needs to be put 5250 // If the navigation is for "view source", the WebLocalFrame needs to be put
5252 // in a special mode. 5251 // in a special mode.
5253 if (request_params.is_view_source) 5252 if (request_params.is_view_source)
5254 frame_->enableViewSourceMode(true); 5253 frame_->enableViewSourceMode(true);
5255 5254
5256 pending_navigation_params_.reset( 5255 pending_navigation_params_.reset(
5257 new NavigationParams(common_params, start_params, request_params)); 5256 new NavigationParams(common_params, start_params, request_params));
5258 5257
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 return scoped_ptr<MediaStreamRendererFactory>( 5558 return scoped_ptr<MediaStreamRendererFactory>(
5560 new MediaStreamRendererFactoryImpl()); 5559 new MediaStreamRendererFactoryImpl());
5561 #else 5560 #else
5562 return scoped_ptr<MediaStreamRendererFactory>( 5561 return scoped_ptr<MediaStreamRendererFactory>(
5563 static_cast<MediaStreamRendererFactory*>(NULL)); 5562 static_cast<MediaStreamRendererFactory*>(NULL));
5564 #endif 5563 #endif
5565 } 5564 }
5566 5565
5567 void RenderFrameImpl::PrepareRenderViewForNavigation( 5566 void RenderFrameImpl::PrepareRenderViewForNavigation(
5568 const GURL& url, 5567 const GURL& url,
5569 const RequestNavigationParams& request_params, 5568 const RequestNavigationParams& request_params) {
5570 bool* is_reload,
5571 WebURLRequest::CachePolicy* cache_policy) {
5572 DCHECK(render_view_->webview()); 5569 DCHECK(render_view_->webview());
5573 5570
5574 MaybeHandleDebugURL(url); 5571 MaybeHandleDebugURL(url);
5575 5572
5576 FOR_EACH_OBSERVER( 5573 FOR_EACH_OBSERVER(
5577 RenderViewObserver, render_view_->observers_, Navigate(url)); 5574 RenderViewObserver, render_view_->observers_, Navigate(url));
5578 5575
5579 render_view_->history_list_offset_ = 5576 render_view_->history_list_offset_ =
5580 request_params.current_history_list_offset; 5577 request_params.current_history_list_offset;
5581 render_view_->history_list_length_ = 5578 render_view_->history_list_length_ =
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5792 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which 5789 // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which
5793 // can result in stale data for pages that are set to expire. We explicitly 5790 // can result in stale data for pages that are set to expire. We explicitly
5794 // override that by setting the policy here so that as necessary we load 5791 // override that by setting the policy here so that as necessary we load
5795 // from the network. 5792 // from the network.
5796 // 5793 //
5797 // TODO(davidben): Remove this in favor of passing a cache policy to the 5794 // TODO(davidben): Remove this in favor of passing a cache policy to the
5798 // loadHistoryItem call in OnNavigate. That requires not overloading 5795 // loadHistoryItem call in OnNavigate. That requires not overloading
5799 // UseProtocolCachePolicy to mean both "normal load" and "determine cache 5796 // UseProtocolCachePolicy to mean both "normal load" and "determine cache
5800 // policy based on load type, etc". 5797 // policy based on load type, etc".
5801 internal_data->set_cache_policy_override( 5798 internal_data->set_cache_policy_override(
5802 WebURLRequest::UseProtocolCachePolicy); 5799 WebCachePolicy::UseProtocolCachePolicy);
5803 } 5800 }
5804 5801
5805 if (IsReload(pending_navigation_params_->common_params.navigation_type)) 5802 if (IsReload(pending_navigation_params_->common_params.navigation_type))
5806 document_state->set_load_type(DocumentState::RELOAD); 5803 document_state->set_load_type(DocumentState::RELOAD);
5807 else if (pending_navigation_params_->request_params.page_state.IsValid()) 5804 else if (pending_navigation_params_->request_params.page_state.IsValid())
5808 document_state->set_load_type(DocumentState::HISTORY_LOAD); 5805 document_state->set_load_type(DocumentState::HISTORY_LOAD);
5809 else 5806 else
5810 document_state->set_load_type(DocumentState::NORMAL_LOAD); 5807 document_state->set_load_type(DocumentState::NORMAL_LOAD);
5811 5808
5812 internal_data->set_is_overriding_user_agent( 5809 internal_data->set_is_overriding_user_agent(
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
6027 int match_count, 6024 int match_count,
6028 int ordinal, 6025 int ordinal,
6029 const WebRect& selection_rect, 6026 const WebRect& selection_rect,
6030 bool final_status_update) { 6027 bool final_status_update) {
6031 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6028 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6032 selection_rect, ordinal, 6029 selection_rect, ordinal,
6033 final_status_update)); 6030 final_status_update));
6034 } 6031 }
6035 6032
6036 } // namespace content 6033 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | third_party/WebKit/Source/core/fetch/FetchContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698