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

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: 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/webencryptedmediaclient_impl.h" 141 #include "media/blink/webencryptedmediaclient_impl.h"
142 #include "media/blink/webmediaplayer_impl.h" 142 #include "media/blink/webmediaplayer_impl.h"
143 #include "media/renderers/gpu_video_accelerator_factories.h" 143 #include "media/renderers/gpu_video_accelerator_factories.h"
144 #include "mojo/common/url_type_converters.h" 144 #include "mojo/common/url_type_converters.h"
145 #include "mojo/edk/js/core.h" 145 #include "mojo/edk/js/core.h"
146 #include "mojo/edk/js/support.h" 146 #include "mojo/edk/js/support.h"
147 #include "net/base/data_url.h" 147 #include "net/base/data_url.h"
148 #include "net/base/net_errors.h" 148 #include "net/base/net_errors.h"
149 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 149 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
150 #include "net/http/http_util.h" 150 #include "net/http/http_util.h"
151 #include "storage/common/data_element.h"
151 #include "third_party/WebKit/public/platform/URLConversion.h" 152 #include "third_party/WebKit/public/platform/URLConversion.h"
152 #include "third_party/WebKit/public/platform/WebCachePolicy.h" 153 #include "third_party/WebKit/public/platform/WebCachePolicy.h"
153 #include "third_party/WebKit/public/platform/WebData.h" 154 #include "third_party/WebKit/public/platform/WebData.h"
154 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 155 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
155 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" 156 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h"
156 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 157 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
157 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 158 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
158 #include "third_party/WebKit/public/platform/WebString.h" 159 #include "third_party/WebKit/public/platform/WebString.h"
159 #include "third_party/WebKit/public/platform/WebURL.h" 160 #include "third_party/WebKit/public/platform/WebURL.h"
160 #include "third_party/WebKit/public/platform/WebURLError.h" 161 #include "third_party/WebKit/public/platform/WebURLError.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // passed back to the browser in the DidCommitProvisionalLoad and the 536 // passed back to the browser in the DidCommitProvisionalLoad and the
536 // DocumentLoadComplete IPCs. 537 // DocumentLoadComplete IPCs.
537 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); 538 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks();
538 request.setUiStartTime(ui_timestamp.InSecondsF()); 539 request.setUiStartTime(ui_timestamp.InSecondsF());
539 request.setInputPerfMetricReportPolicy( 540 request.setInputPerfMetricReportPolicy(
540 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( 541 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>(
541 common_params.report_type)); 542 common_params.report_type));
542 return request; 543 return request;
543 } 544 }
544 545
546 void AddHTTPBodyToRequest(WebURLRequest* request,
Charlie Reis 2016/04/27 23:00:56 I'm not sure I understand this either. Where is t
clamy 2016/04/29 16:07:16 This is new code. We have a way to convert a WebHT
547 scoped_refptr<ResourceRequestBody> body) {
548 WebHTTPBody http_body;
549 http_body.initialize();
550 http_body.setIdentifier(body->identifier());
551 for (auto element : *(body->elements())) {
552 switch (element.type()) {
553 case storage::DataElement::TYPE_BYTES:
554 http_body.appendData(WebData(
555 reinterpret_cast<const char*>(element.bytes()), element.length()));
556 break;
557 case storage::DataElement::TYPE_FILE:
558 http_body.appendFileRange(
559 element.path().AsUTF16Unsafe(), element.offset(), element.length(),
560 element.expected_modification_time().ToDoubleT());
561 break;
562 case storage::DataElement::TYPE_FILE_FILESYSTEM:
563 http_body.appendFileSystemURLRange(
564 element.filesystem_url(), element.offset(), element.length(),
565 element.expected_modification_time().ToDoubleT());
566 break;
567 case storage::DataElement::TYPE_BLOB:
568 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid()));
569 break;
570 default:
571 NOTREACHED();
572 break;
573 }
574 }
575 request->setHTTPBody(http_body);
576 }
577
545 // Sanitizes the navigation_start timestamp for browser-initiated navigations, 578 // Sanitizes the navigation_start timestamp for browser-initiated navigations,
546 // where the browser possibly has a better notion of start time than the 579 // where the browser possibly has a better notion of start time than the
547 // renderer. In the case of cross-process navigations, this carries over the 580 // renderer. In the case of cross-process navigations, this carries over the
548 // time of finishing the onbeforeunload handler of the previous page. 581 // time of finishing the onbeforeunload handler of the previous page.
549 // TimeTicks is sometimes not monotonic across processes, and because 582 // TimeTicks is sometimes not monotonic across processes, and because
550 // |browser_navigation_start| is likely before this process existed, 583 // |browser_navigation_start| is likely before this process existed,
551 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by 584 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by
552 // clamping it to renderer_navigation_start, initialized earlier in the call 585 // clamping it to renderer_navigation_start, initialized earlier in the call
553 // stack. 586 // stack.
554 base::TimeTicks SanitizeNavigationTiming( 587 base::TimeTicks SanitizeNavigationTiming(
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 } 1514 }
1482 1515
1483 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 1516 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
1484 // Can be NULL in tests. 1517 // Can be NULL in tests.
1485 if (render_thread_impl) 1518 if (render_thread_impl)
1486 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); 1519 render_thread_impl->GetRendererScheduler()->OnNavigationStarted();
1487 DCHECK(!IsBrowserSideNavigationEnabled()); 1520 DCHECK(!IsBrowserSideNavigationEnabled());
1488 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, 1521 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
1489 "url", common_params.url.possibly_invalid_spec()); 1522 "url", common_params.url.possibly_invalid_spec());
1490 NavigateInternal(common_params, start_params, request_params, 1523 NavigateInternal(common_params, start_params, request_params,
1491 std::unique_ptr<StreamOverrideParameters>()); 1524 std::unique_ptr<StreamOverrideParameters>(), nullptr);
1492 } 1525 }
1493 1526
1494 void RenderFrameImpl::BindServiceRegistry( 1527 void RenderFrameImpl::BindServiceRegistry(
1495 shell::mojom::InterfaceProviderRequest services, 1528 shell::mojom::InterfaceProviderRequest services,
1496 shell::mojom::InterfaceProviderPtr exposed_services) { 1529 shell::mojom::InterfaceProviderPtr exposed_services) {
1497 service_registry_.Bind(std::move(services)); 1530 service_registry_.Bind(std::move(services));
1498 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); 1531 service_registry_.BindRemoteServiceProvider(std::move(exposed_services));
1499 } 1532 }
1500 1533
1501 ManifestManager* RenderFrameImpl::manifest_manager() { 1534 ManifestManager* RenderFrameImpl::manifest_manager() {
(...skipping 3064 matching lines...) Expand 10 before | Expand all | Expand 10 after
4566 if (commit_type == blink::WebStandardCommit) 4599 if (commit_type == blink::WebStandardCommit)
4567 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; 4600 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
4568 else 4601 else
4569 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; 4602 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
4570 4603
4571 DCHECK(!navigation_state->request_params().should_clear_history_list); 4604 DCHECK(!navigation_state->request_params().should_clear_history_list);
4572 params.history_list_was_cleared = false; 4605 params.history_list_was_cleared = false;
4573 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; 4606 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT;
4574 } 4607 }
4575 4608
4609 scoped_refptr<ResourceRequestBody> post_data;
4610 if (IsBrowserSideNavigationEnabled()) {
Charlie Reis 2016/04/27 23:00:56 I'm nervous about making this PlzNavigate-only. I
clamy 2016/04/29 16:07:16 We no longer send the POST data to the browser.
4611 post_data = GetRequestBodyForWebURLRequest(request);
4612 }
4613
4576 // This message needs to be sent before any of allowScripts(), 4614 // This message needs to be sent before any of allowScripts(),
4577 // allowImages(), allowPlugins() is called for the new page, so that when 4615 // allowImages(), allowPlugins() is called for the new page, so that when
4578 // these functions send a ViewHostMsg_ContentBlocked message, it arrives 4616 // these functions send a ViewHostMsg_ContentBlocked message, it arrives
4579 // after the FrameHostMsg_DidCommitProvisionalLoad message. 4617 // after the FrameHostMsg_DidCommitProvisionalLoad message.
4580 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); 4618 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params,
4619 post_data));
4581 4620
4582 // If we end up reusing this WebRequest (for example, due to a #ref click), 4621 // If we end up reusing this WebRequest (for example, due to a #ref click),
4583 // we don't want the transition type to persist. Just clear it. 4622 // we don't want the transition type to persist. Just clear it.
4584 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); 4623 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK);
4585 } 4624 }
4586 4625
4587 void RenderFrameImpl::didStartLoading(bool to_different_document) { 4626 void RenderFrameImpl::didStartLoading(bool to_different_document) {
4588 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading", 4627 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading",
4589 "id", routing_id_); 4628 "id", routing_id_);
4590 render_view_->FrameDidStartLoading(frame_); 4629 render_view_->FrameDidStartLoading(frame_);
(...skipping 28 matching lines...) Expand all
4619 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 4658 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
4620 if (renderer_accessibility()) 4659 if (renderer_accessibility())
4621 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); 4660 renderer_accessibility()->AccessibilityFocusedNodeChanged(node);
4622 } 4661 }
4623 4662
4624 // PlzNavigate 4663 // PlzNavigate
4625 void RenderFrameImpl::OnCommitNavigation( 4664 void RenderFrameImpl::OnCommitNavigation(
4626 const ResourceResponseHead& response, 4665 const ResourceResponseHead& response,
4627 const GURL& stream_url, 4666 const GURL& stream_url,
4628 const CommonNavigationParams& common_params, 4667 const CommonNavigationParams& common_params,
4629 const RequestNavigationParams& request_params) { 4668 const RequestNavigationParams& request_params,
4669 scoped_refptr<ResourceRequestBody> post_data) {
4630 CHECK(IsBrowserSideNavigationEnabled()); 4670 CHECK(IsBrowserSideNavigationEnabled());
4631 // This will override the url requested by the WebURLLoader, as well as 4671 // This will override the url requested by the WebURLLoader, as well as
4632 // provide it with the response to the request. 4672 // provide it with the response to the request.
4633 std::unique_ptr<StreamOverrideParameters> stream_override( 4673 std::unique_ptr<StreamOverrideParameters> stream_override(
4634 new StreamOverrideParameters()); 4674 new StreamOverrideParameters());
4635 stream_override->stream_url = stream_url; 4675 stream_override->stream_url = stream_url;
4636 stream_override->response = response; 4676 stream_override->response = response;
4637 4677
4638 NavigateInternal(common_params, StartNavigationParams(), request_params, 4678 NavigateInternal(common_params, StartNavigationParams(), request_params,
4639 std::move(stream_override)); 4679 std::move(stream_override), post_data);
4640 } 4680 }
4641 4681
4642 // PlzNavigate 4682 // PlzNavigate
4643 void RenderFrameImpl::OnFailedNavigation( 4683 void RenderFrameImpl::OnFailedNavigation(
4644 const CommonNavigationParams& common_params, 4684 const CommonNavigationParams& common_params,
4645 const RequestNavigationParams& request_params, 4685 const RequestNavigationParams& request_params,
4646 bool has_stale_copy_in_cache, 4686 bool has_stale_copy_in_cache,
4647 int error_code) { 4687 int error_code) {
4648 DCHECK(IsBrowserSideNavigationEnabled()); 4688 DCHECK(IsBrowserSideNavigationEnabled());
4649 bool is_reload = IsReload(common_params.navigation_type); 4689 bool is_reload = IsReload(common_params.navigation_type);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 params.frame_unique_name = frame_->uniqueName().utf8(); 5265 params.frame_unique_name = frame_->uniqueName().utf8();
5226 } 5266 }
5227 5267
5228 Send(new FrameHostMsg_OpenURL(routing_id_, params)); 5268 Send(new FrameHostMsg_OpenURL(routing_id_, params));
5229 } 5269 }
5230 5270
5231 void RenderFrameImpl::NavigateInternal( 5271 void RenderFrameImpl::NavigateInternal(
5232 const CommonNavigationParams& common_params, 5272 const CommonNavigationParams& common_params,
5233 const StartNavigationParams& start_params, 5273 const StartNavigationParams& start_params,
5234 const RequestNavigationParams& request_params, 5274 const RequestNavigationParams& request_params,
5235 std::unique_ptr<StreamOverrideParameters> stream_params) { 5275 std::unique_ptr<StreamOverrideParameters> stream_params,
5276 scoped_refptr<ResourceRequestBody> post_data) {
5236 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); 5277 bool browser_side_navigation = IsBrowserSideNavigationEnabled();
5237 5278
5238 // Lower bound for browser initiated navigation start time. 5279 // Lower bound for browser initiated navigation start time.
5239 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 5280 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
5240 bool is_reload = IsReload(common_params.navigation_type); 5281 bool is_reload = IsReload(common_params.navigation_type);
5241 bool is_history_navigation = request_params.page_state.IsValid(); 5282 bool is_history_navigation = request_params.page_state.IsValid();
5242 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; 5283 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy;
5243 RenderFrameImpl::PrepareRenderViewForNavigation( 5284 RenderFrameImpl::PrepareRenderViewForNavigation(
5244 common_params.url, request_params); 5285 common_params.url, request_params);
5245 5286
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5286 ? blink::WebFrameLoadType::ReplaceCurrentItem 5327 ? blink::WebFrameLoadType::ReplaceCurrentItem
5287 : blink::WebFrameLoadType::Standard; 5328 : blink::WebFrameLoadType::Standard;
5288 blink::WebHistoryLoadType history_load_type = 5329 blink::WebHistoryLoadType history_load_type =
5289 blink::WebHistoryDifferentDocumentLoad; 5330 blink::WebHistoryDifferentDocumentLoad;
5290 bool should_load_request = false; 5331 bool should_load_request = false;
5291 WebHistoryItem item_for_history_navigation; 5332 WebHistoryItem item_for_history_navigation;
5292 WebURLRequest request = 5333 WebURLRequest request =
5293 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5334 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5294 frame_->isViewSourceModeEnabled()); 5335 frame_->isViewSourceModeEnabled());
5295 5336
5337 if (IsBrowserSideNavigationEnabled() && post_data)
5338 AddHTTPBodyToRequest(&request, post_data);
5339
5296 // Used to determine whether this frame is actually loading a request as part 5340 // Used to determine whether this frame is actually loading a request as part
5297 // of a history navigation. 5341 // of a history navigation.
5298 bool has_history_navigation_in_frame = false; 5342 bool has_history_navigation_in_frame = false;
5299 5343
5300 #if defined(OS_ANDROID) 5344 #if defined(OS_ANDROID)
5301 request.setHasUserGesture(start_params.has_user_gesture); 5345 request.setHasUserGesture(start_params.has_user_gesture);
5302 #endif 5346 #endif
5303 5347
5304 // PlzNavigate: Make sure that Blink's loader will not try to use browser side 5348 // PlzNavigate: Make sure that Blink's loader will not try to use browser side
5305 // navigation for this request (since it already went to the browser). 5349 // navigation for this request (since it already went to the browser).
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
6039 int match_count, 6083 int match_count,
6040 int ordinal, 6084 int ordinal,
6041 const WebRect& selection_rect, 6085 const WebRect& selection_rect,
6042 bool final_status_update) { 6086 bool final_status_update) {
6043 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6087 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6044 selection_rect, ordinal, 6088 selection_rect, ordinal,
6045 final_status_update)); 6089 final_status_update));
6046 } 6090 }
6047 6091
6048 } // namespace content 6092 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698