| 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());
|
|
|