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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index fecee3060bd411b412092beacdd47a318f315e84..c55b5422b21a0c1232d3defb20967a97f6ae0afe 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -148,6 +148,7 @@
#include "net/base/net_errors.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/http/http_util.h"
+#include "storage/common/data_element.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebCachePolicy.h"
#include "third_party/WebKit/public/platform/WebData.h"
@@ -542,6 +543,38 @@ WebURLRequest CreateURLRequestForNavigation(
return request;
}
+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
+ scoped_refptr<ResourceRequestBody> body) {
+ WebHTTPBody http_body;
+ http_body.initialize();
+ http_body.setIdentifier(body->identifier());
+ for (auto element : *(body->elements())) {
+ switch (element.type()) {
+ case storage::DataElement::TYPE_BYTES:
+ http_body.appendData(WebData(
+ reinterpret_cast<const char*>(element.bytes()), element.length()));
+ break;
+ case storage::DataElement::TYPE_FILE:
+ http_body.appendFileRange(
+ element.path().AsUTF16Unsafe(), element.offset(), element.length(),
+ element.expected_modification_time().ToDoubleT());
+ break;
+ case storage::DataElement::TYPE_FILE_FILESYSTEM:
+ http_body.appendFileSystemURLRange(
+ element.filesystem_url(), element.offset(), element.length(),
+ element.expected_modification_time().ToDoubleT());
+ break;
+ case storage::DataElement::TYPE_BLOB:
+ http_body.appendBlob(WebString::fromUTF8(element.blob_uuid()));
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+ request->setHTTPBody(http_body);
+}
+
// Sanitizes the navigation_start timestamp for browser-initiated navigations,
// where the browser possibly has a better notion of start time than the
// renderer. In the case of cross-process navigations, this carries over the
@@ -1488,7 +1521,7 @@ void RenderFrameImpl::OnNavigate(
TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_,
"url", common_params.url.possibly_invalid_spec());
NavigateInternal(common_params, start_params, request_params,
- std::unique_ptr<StreamOverrideParameters>());
+ std::unique_ptr<StreamOverrideParameters>(), nullptr);
}
void RenderFrameImpl::BindServiceRegistry(
@@ -4573,11 +4606,17 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad(
params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT;
}
+ scoped_refptr<ResourceRequestBody> post_data;
+ 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.
+ post_data = GetRequestBodyForWebURLRequest(request);
+ }
+
// This message needs to be sent before any of allowScripts(),
// allowImages(), allowPlugins() is called for the new page, so that when
// these functions send a ViewHostMsg_ContentBlocked message, it arrives
// after the FrameHostMsg_DidCommitProvisionalLoad message.
- Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params));
+ Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params,
+ post_data));
// If we end up reusing this WebRequest (for example, due to a #ref click),
// we don't want the transition type to persist. Just clear it.
@@ -4626,7 +4665,8 @@ void RenderFrameImpl::OnCommitNavigation(
const ResourceResponseHead& response,
const GURL& stream_url,
const CommonNavigationParams& common_params,
- const RequestNavigationParams& request_params) {
+ const RequestNavigationParams& request_params,
+ scoped_refptr<ResourceRequestBody> post_data) {
CHECK(IsBrowserSideNavigationEnabled());
// This will override the url requested by the WebURLLoader, as well as
// provide it with the response to the request.
@@ -4636,7 +4676,7 @@ void RenderFrameImpl::OnCommitNavigation(
stream_override->response = response;
NavigateInternal(common_params, StartNavigationParams(), request_params,
- std::move(stream_override));
+ std::move(stream_override), post_data);
}
// PlzNavigate
@@ -5232,7 +5272,8 @@ void RenderFrameImpl::NavigateInternal(
const CommonNavigationParams& common_params,
const StartNavigationParams& start_params,
const RequestNavigationParams& request_params,
- std::unique_ptr<StreamOverrideParameters> stream_params) {
+ std::unique_ptr<StreamOverrideParameters> stream_params,
+ scoped_refptr<ResourceRequestBody> post_data) {
bool browser_side_navigation = IsBrowserSideNavigationEnabled();
// Lower bound for browser initiated navigation start time.
@@ -5293,6 +5334,9 @@ void RenderFrameImpl::NavigateInternal(
CreateURLRequestForNavigation(common_params, std::move(stream_params),
frame_->isViewSourceModeEnabled());
+ if (IsBrowserSideNavigationEnabled() && post_data)
+ AddHTTPBodyToRequest(&request, post_data);
+
// Used to determine whether this frame is actually loading a request as part
// of a history navigation.
bool has_history_navigation_in_frame = false;

Powered by Google App Engine
This is Rietveld 408576698