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

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

Issue 1907443006: PlzNavigate: store POST data in the FrameNavigationEntry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed comments Created 4 years, 7 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 | « content/renderer/render_frame_impl.h ('k') | content/test/test_render_frame.cc » ('j') | 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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #include "media/blink/webencryptedmediaclient_impl.h" 144 #include "media/blink/webencryptedmediaclient_impl.h"
145 #include "media/blink/webmediaplayer_impl.h" 145 #include "media/blink/webmediaplayer_impl.h"
146 #include "media/renderers/gpu_video_accelerator_factories.h" 146 #include "media/renderers/gpu_video_accelerator_factories.h"
147 #include "mojo/common/url_type_converters.h" 147 #include "mojo/common/url_type_converters.h"
148 #include "mojo/edk/js/core.h" 148 #include "mojo/edk/js/core.h"
149 #include "mojo/edk/js/support.h" 149 #include "mojo/edk/js/support.h"
150 #include "net/base/data_url.h" 150 #include "net/base/data_url.h"
151 #include "net/base/net_errors.h" 151 #include "net/base/net_errors.h"
152 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 152 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
153 #include "net/http/http_util.h" 153 #include "net/http/http_util.h"
154 #include "storage/common/data_element.h"
154 #include "third_party/WebKit/public/platform/URLConversion.h" 155 #include "third_party/WebKit/public/platform/URLConversion.h"
155 #include "third_party/WebKit/public/platform/WebCachePolicy.h" 156 #include "third_party/WebKit/public/platform/WebCachePolicy.h"
156 #include "third_party/WebKit/public/platform/WebData.h" 157 #include "third_party/WebKit/public/platform/WebData.h"
157 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 158 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
158 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" 159 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h"
159 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 160 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
160 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 161 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
161 #include "third_party/WebKit/public/platform/WebString.h" 162 #include "third_party/WebKit/public/platform/WebString.h"
162 #include "third_party/WebKit/public/platform/WebURL.h" 163 #include "third_party/WebKit/public/platform/WebURL.h"
163 #include "third_party/WebKit/public/platform/WebURLError.h" 164 #include "third_party/WebKit/public/platform/WebURLError.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // passed back to the browser in the DidCommitProvisionalLoad and the 534 // passed back to the browser in the DidCommitProvisionalLoad and the
534 // DocumentLoadComplete IPCs. 535 // DocumentLoadComplete IPCs.
535 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); 536 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks();
536 request.setUiStartTime(ui_timestamp.InSecondsF()); 537 request.setUiStartTime(ui_timestamp.InSecondsF());
537 request.setInputPerfMetricReportPolicy( 538 request.setInputPerfMetricReportPolicy(
538 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( 539 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>(
539 common_params.report_type)); 540 common_params.report_type));
540 return request; 541 return request;
541 } 542 }
542 543
544 // Converts the HTTP body data stored in ResourceRequestBody format to a
545 // WebHTTPBody, which is then added to the WebURLRequest.
546 // PlzNavigate: used to add the POST data sent by the renderer at commit time
547 // to the WebURLRequest used to commit the navigation. This ensures that the
548 // POST data will be in the PageState sent to the browser on commit.
549 void AddHTTPBodyToRequest(WebURLRequest* request,
550 scoped_refptr<ResourceRequestBody> body) {
551 WebHTTPBody http_body;
552 http_body.initialize();
553 http_body.setIdentifier(body->identifier());
554 for (const ResourceRequestBody::Element& element : *(body->elements())) {
555 long long length = -1;
556 switch (element.type()) {
557 case storage::DataElement::TYPE_BYTES:
558 http_body.appendData(WebData(element.bytes(), element.length()));
559 break;
560 case storage::DataElement::TYPE_FILE:
561 if (element.length() != std::numeric_limits<uint64_t>::max())
562 length = element.length();
563 http_body.appendFileRange(
564 element.path().AsUTF16Unsafe(), element.offset(), length,
565 element.expected_modification_time().ToDoubleT());
566 break;
567 case storage::DataElement::TYPE_FILE_FILESYSTEM:
568 http_body.appendFileSystemURLRange(
569 element.filesystem_url(), element.offset(), element.length(),
570 element.expected_modification_time().ToDoubleT());
571 break;
572 case storage::DataElement::TYPE_BLOB:
573 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid()));
574 break;
575 default:
576 // TYPE_BYTES_DESCRIPTION and TYPE_DISK_CACHE_ENTRY should not be
577 // encountered.
578 NOTREACHED();
579 break;
580 }
581 }
582 request->setHTTPBody(http_body);
583 }
584
543 // Sanitizes the navigation_start timestamp for browser-initiated navigations, 585 // Sanitizes the navigation_start timestamp for browser-initiated navigations,
544 // where the browser possibly has a better notion of start time than the 586 // where the browser possibly has a better notion of start time than the
545 // renderer. In the case of cross-process navigations, this carries over the 587 // renderer. In the case of cross-process navigations, this carries over the
546 // time of finishing the onbeforeunload handler of the previous page. 588 // time of finishing the onbeforeunload handler of the previous page.
547 // TimeTicks is sometimes not monotonic across processes, and because 589 // TimeTicks is sometimes not monotonic across processes, and because
548 // |browser_navigation_start| is likely before this process existed, 590 // |browser_navigation_start| is likely before this process existed,
549 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by 591 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by
550 // clamping it to renderer_navigation_start, initialized earlier in the call 592 // clamping it to renderer_navigation_start, initialized earlier in the call
551 // stack. 593 // stack.
552 base::TimeTicks SanitizeNavigationTiming( 594 base::TimeTicks SanitizeNavigationTiming(
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 } 1581 }
1540 1582
1541 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 1583 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
1542 // Can be NULL in tests. 1584 // Can be NULL in tests.
1543 if (render_thread_impl) 1585 if (render_thread_impl)
1544 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); 1586 render_thread_impl->GetRendererScheduler()->OnNavigationStarted();
1545 DCHECK(!IsBrowserSideNavigationEnabled()); 1587 DCHECK(!IsBrowserSideNavigationEnabled());
1546 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, 1588 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1547 "url", common_params.url.possibly_invalid_spec()); 1589 "url", common_params.url.possibly_invalid_spec());
1548 NavigateInternal(common_params, start_params, request_params, 1590 NavigateInternal(common_params, start_params, request_params,
1549 std::unique_ptr<StreamOverrideParameters>()); 1591 std::unique_ptr<StreamOverrideParameters>(), nullptr);
1550 } 1592 }
1551 1593
1552 void RenderFrameImpl::BindServiceRegistry( 1594 void RenderFrameImpl::BindServiceRegistry(
1553 shell::mojom::InterfaceProviderRequest services, 1595 shell::mojom::InterfaceProviderRequest services,
1554 shell::mojom::InterfaceProviderPtr exposed_services) { 1596 shell::mojom::InterfaceProviderPtr exposed_services) {
1555 service_registry_.Bind(std::move(services)); 1597 service_registry_.Bind(std::move(services));
1556 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); 1598 service_registry_.BindRemoteServiceProvider(std::move(exposed_services));
1557 } 1599 }
1558 1600
1559 ManifestManager* RenderFrameImpl::manifest_manager() { 1601 ManifestManager* RenderFrameImpl::manifest_manager() {
(...skipping 3117 matching lines...) Expand 10 before | Expand all | Expand 10 after
4677 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 4719 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
4678 if (renderer_accessibility()) 4720 if (renderer_accessibility())
4679 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); 4721 renderer_accessibility()->AccessibilityFocusedNodeChanged(node);
4680 } 4722 }
4681 4723
4682 // PlzNavigate 4724 // PlzNavigate
4683 void RenderFrameImpl::OnCommitNavigation( 4725 void RenderFrameImpl::OnCommitNavigation(
4684 const ResourceResponseHead& response, 4726 const ResourceResponseHead& response,
4685 const GURL& stream_url, 4727 const GURL& stream_url,
4686 const CommonNavigationParams& common_params, 4728 const CommonNavigationParams& common_params,
4687 const RequestNavigationParams& request_params) { 4729 const RequestNavigationParams& request_params,
4730 scoped_refptr<ResourceRequestBody> post_data) {
4688 CHECK(IsBrowserSideNavigationEnabled()); 4731 CHECK(IsBrowserSideNavigationEnabled());
4689 // This will override the url requested by the WebURLLoader, as well as 4732 // This will override the url requested by the WebURLLoader, as well as
4690 // provide it with the response to the request. 4733 // provide it with the response to the request.
4691 std::unique_ptr<StreamOverrideParameters> stream_override( 4734 std::unique_ptr<StreamOverrideParameters> stream_override(
4692 new StreamOverrideParameters()); 4735 new StreamOverrideParameters());
4693 stream_override->stream_url = stream_url; 4736 stream_override->stream_url = stream_url;
4694 stream_override->response = response; 4737 stream_override->response = response;
4695 4738
4696 NavigateInternal(common_params, StartNavigationParams(), request_params, 4739 NavigateInternal(common_params, StartNavigationParams(), request_params,
4697 std::move(stream_override)); 4740 std::move(stream_override), post_data);
4698 } 4741 }
4699 4742
4700 // PlzNavigate 4743 // PlzNavigate
4701 void RenderFrameImpl::OnFailedNavigation( 4744 void RenderFrameImpl::OnFailedNavigation(
4702 const CommonNavigationParams& common_params, 4745 const CommonNavigationParams& common_params,
4703 const RequestNavigationParams& request_params, 4746 const RequestNavigationParams& request_params,
4704 bool has_stale_copy_in_cache, 4747 bool has_stale_copy_in_cache,
4705 int error_code) { 4748 int error_code) {
4706 DCHECK(IsBrowserSideNavigationEnabled()); 4749 DCHECK(IsBrowserSideNavigationEnabled());
4707 bool is_reload = IsReload(common_params.navigation_type); 4750 bool is_reload = IsReload(common_params.navigation_type);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
5283 params.frame_unique_name = frame_->uniqueName().utf8(); 5326 params.frame_unique_name = frame_->uniqueName().utf8();
5284 } 5327 }
5285 5328
5286 Send(new FrameHostMsg_OpenURL(routing_id_, params)); 5329 Send(new FrameHostMsg_OpenURL(routing_id_, params));
5287 } 5330 }
5288 5331
5289 void RenderFrameImpl::NavigateInternal( 5332 void RenderFrameImpl::NavigateInternal(
5290 const CommonNavigationParams& common_params, 5333 const CommonNavigationParams& common_params,
5291 const StartNavigationParams& start_params, 5334 const StartNavigationParams& start_params,
5292 const RequestNavigationParams& request_params, 5335 const RequestNavigationParams& request_params,
5293 std::unique_ptr<StreamOverrideParameters> stream_params) { 5336 std::unique_ptr<StreamOverrideParameters> stream_params,
5337 scoped_refptr<ResourceRequestBody> post_data) {
5294 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); 5338 bool browser_side_navigation = IsBrowserSideNavigationEnabled();
5295 5339
5296 // Lower bound for browser initiated navigation start time. 5340 // Lower bound for browser initiated navigation start time.
5297 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 5341 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
5298 bool is_reload = IsReload(common_params.navigation_type); 5342 bool is_reload = IsReload(common_params.navigation_type);
5299 bool is_history_navigation = request_params.page_state.IsValid(); 5343 bool is_history_navigation = request_params.page_state.IsValid();
5300 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; 5344 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy;
5301 RenderFrameImpl::PrepareRenderViewForNavigation( 5345 RenderFrameImpl::PrepareRenderViewForNavigation(
5302 common_params.url, request_params); 5346 common_params.url, request_params);
5303 5347
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5344 ? blink::WebFrameLoadType::ReplaceCurrentItem 5388 ? blink::WebFrameLoadType::ReplaceCurrentItem
5345 : blink::WebFrameLoadType::Standard; 5389 : blink::WebFrameLoadType::Standard;
5346 blink::WebHistoryLoadType history_load_type = 5390 blink::WebHistoryLoadType history_load_type =
5347 blink::WebHistoryDifferentDocumentLoad; 5391 blink::WebHistoryDifferentDocumentLoad;
5348 bool should_load_request = false; 5392 bool should_load_request = false;
5349 WebHistoryItem item_for_history_navigation; 5393 WebHistoryItem item_for_history_navigation;
5350 WebURLRequest request = 5394 WebURLRequest request =
5351 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5395 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5352 frame_->isViewSourceModeEnabled()); 5396 frame_->isViewSourceModeEnabled());
5353 5397
5398 if (IsBrowserSideNavigationEnabled() && post_data)
5399 AddHTTPBodyToRequest(&request, post_data);
5400
5354 // Used to determine whether this frame is actually loading a request as part 5401 // Used to determine whether this frame is actually loading a request as part
5355 // of a history navigation. 5402 // of a history navigation.
5356 bool has_history_navigation_in_frame = false; 5403 bool has_history_navigation_in_frame = false;
5357 5404
5358 #if defined(OS_ANDROID) 5405 #if defined(OS_ANDROID)
5359 request.setHasUserGesture(start_params.has_user_gesture); 5406 request.setHasUserGesture(start_params.has_user_gesture);
5360 #endif 5407 #endif
5361 5408
5362 // PlzNavigate: Make sure that Blink's loader will not try to use browser side 5409 // PlzNavigate: Make sure that Blink's loader will not try to use browser side
5363 // navigation for this request (since it already went to the browser). 5410 // navigation for this request (since it already went to the browser).
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
6157 // event target. Potentially a Pepper plugin will receive the event. 6204 // event target. Potentially a Pepper plugin will receive the event.
6158 // In order to tell whether a plugin gets the last mouse event and which it 6205 // In order to tell whether a plugin gets the last mouse event and which it
6159 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6206 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6160 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6207 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6161 // |pepper_last_mouse_event_target_|. 6208 // |pepper_last_mouse_event_target_|.
6162 pepper_last_mouse_event_target_ = nullptr; 6209 pepper_last_mouse_event_target_ = nullptr;
6163 #endif 6210 #endif
6164 } 6211 }
6165 6212
6166 } // namespace content 6213 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/test/test_render_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698