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

Unified Diff: content/common/resource_request_body.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/resource_request_body.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/resource_request_body.cc
diff --git a/content/common/resource_request_body.cc b/content/common/resource_request_body.cc
index 2aa3f7ec2facab5cc424c47d8d9c66e8dae42303..74276c8aaa06544f4144428390347327bf180c53 100644
--- a/content/common/resource_request_body.cc
+++ b/content/common/resource_request_body.cc
@@ -4,12 +4,62 @@
#include "content/common/resource_request_body.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/common/page_state_serialization.h"
+
+using blink::WebHTTPBody;
+using blink::WebString;
+
namespace content {
ResourceRequestBody::ResourceRequestBody()
: identifier_(0) {
}
+void ResourceRequestBody::AppendExplodedHTTPBodyElement(
+ const ExplodedHttpBodyElement& element) {
+ // Note: this code is based on GetRequestBodyForWebURLRequest (in
+ // web_url_request_util.cc). The other function transforms a
+ // blink::WebHTTPBody into a ResourceRequestBody. This function is used to
+ // transform an ExplodedHttpBody into a ResourceRequestBody.
+ switch (element.type) {
+ case WebHTTPBody::Element::TypeData:
+ if (!element.data.empty()) {
+ // Blink sometimes gives empty data to append. These aren't
+ // necessary so they are just optimized out here.
+ AppendBytes(element.data.data(), static_cast<int>(element.data.size()));
+ }
+ break;
+ case WebHTTPBody::Element::TypeFile:
+ if (element.file_length == -1) {
+ AppendFileRange(
+ base::FilePath::FromUTF16Unsafe(element.file_path.string()), 0,
+ std::numeric_limits<uint64_t>::max(), base::Time());
+ } else {
+ AppendFileRange(
+ base::FilePath::FromUTF16Unsafe(element.file_path.string()),
+ static_cast<uint64_t>(element.file_start),
+ static_cast<uint64_t>(element.file_length),
+ base::Time::FromDoubleT(element.file_modification_time));
+ }
+ break;
+ case WebHTTPBody::Element::TypeFileSystemURL: {
+ GURL file_system_url = element.filesystem_url;
+ DCHECK(file_system_url.SchemeIsFileSystem());
+ AppendFileSystemFileRange(
+ file_system_url, static_cast<uint64_t>(element.file_start),
+ static_cast<uint64_t>(element.file_length),
+ base::Time::FromDoubleT(element.file_modification_time));
+ break;
+ }
+ case WebHTTPBody::Element::TypeBlob:
+ AppendBlob(element.blob_uuid);
+ break;
+ default:
+ NOTREACHED();
+ }
+}
+
void ResourceRequestBody::AppendBytes(const char* bytes, int bytes_len) {
if (bytes_len > 0) {
elements_.push_back(Element());
« no previous file with comments | « content/common/resource_request_body.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698