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

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: 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
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..c293b347e17f90a62e74481c71068db3d9126888 100644
--- a/content/common/resource_request_body.cc
+++ b/content/common/resource_request_body.cc
@@ -4,12 +4,58 @@
#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) {
+ 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()));
Łukasz Anforowicz 2016/05/12 02:53:59 It is not immediately clear why size_t -> int cast
clamy 2016/05/12 08:53:13 This whole method is a copy of what we do to conve
Łukasz Anforowicz 2016/05/12 19:44:12 It is pretty sad that we have to repeat almost the
Charlie Reis 2016/05/16 21:16:42 Please add a comment above this method indicating
clamy 2016/05/19 13:11:57 Done.
+ }
+ 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());
Łukasz Anforowicz 2016/05/12 02:53:59 I see that UploadFileElementReader::OnGetFileInfoC
clamy 2016/05/12 08:53:13 Possibly? As explained above, I'm just copy pastin
Łukasz Anforowicz 2016/05/12 19:44:12 Acknowledged.
+ } 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));
Łukasz Anforowicz 2016/05/12 02:53:59 Just wanted to double-check - is it okay to use ba
clamy 2016/05/12 08:53:13 Again I imagine it's ok since we've been doing it.
Łukasz Anforowicz 2016/05/12 19:44:12 Acknowledged.
Charlie Reis 2016/05/16 21:16:41 In general, copy/pasting code isn't an excuse for
Łukasz Anforowicz 2016/05/18 00:22:27 I wonder if we could avoid copy&pasted conversion
clamy 2016/05/19 13:11:57 So I did a bit of code archeology, and the time pa
Charlie Reis 2016/05/19 17:43:48 Agreed. Since we aren't certain there's a bug her
+ }
+ break;
+ case WebHTTPBody::Element::TypeFileSystemURL: {
+ GURL file_system_url = element.filesystem_url;
+ DCHECK(file_system_url.SchemeIsFileSystem());
Łukasz Anforowicz 2016/05/12 02:53:59 I guess a DCHECK is sufficient, because UploadFile
clamy 2016/05/12 08:53:13 I imagine. I don't know if we want to crash the re
Łukasz Anforowicz 2016/05/12 19:44:12 Acknowledged.
+ 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());
@@ -42,6 +88,14 @@ void ResourceRequestBody::AppendFileSystemFileRange(
expected_modification_time);
}
+scoped_refptr<ResourceRequestBody> ResourceRequestBody::MakeCopy() {
+ scoped_refptr<ResourceRequestBody> copy = new ResourceRequestBody();
+ copy->set_identifier(identifier_);
+ for (auto element : elements_)
+ copy->elements_mutable()->push_back(element);
+ return copy;
+}
+
ResourceRequestBody::~ResourceRequestBody() {
}

Powered by Google App Engine
This is Rietveld 408576698