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

Unified Diff: content/common/resource_request_body.cc

Issue 2002413002: Revert of Deduplicating code performing WebHTTPBody::Element conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/content_renderer.gypi » ('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 b2b0c5fd96dc41254a5ba15aca33fd8db3163174..74276c8aaa06544f4144428390347327bf180c53 100644
--- a/content/common/resource_request_body.cc
+++ b/content/common/resource_request_body.cc
@@ -14,6 +14,50 @@
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) {
« no previous file with comments | « content/common/resource_request_body.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698