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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/resource_request_body.h" 5 #include "content/common/resource_request_body.h"
6 6
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/common/page_state_serialization.h"
9
10 using blink::WebHTTPBody;
11 using blink::WebString;
12
7 namespace content { 13 namespace content {
8 14
9 ResourceRequestBody::ResourceRequestBody() 15 ResourceRequestBody::ResourceRequestBody()
10 : identifier_(0) { 16 : identifier_(0) {
11 } 17 }
12 18
19 void ResourceRequestBody::AppendExplodedHTTPBodyElement(
20 const ExplodedHttpBodyElement& element) {
21 // Note: this code is based on GetRequestBodyForWebURLRequest (in
22 // web_url_request_util.cc). The other function transforms a
23 // blink::WebHTTPBody into a ResourceRequestBody. This function is used to
24 // transform an ExplodedHttpBody into a ResourceRequestBody.
25 switch (element.type) {
26 case WebHTTPBody::Element::TypeData:
27 if (!element.data.empty()) {
28 // Blink sometimes gives empty data to append. These aren't
29 // necessary so they are just optimized out here.
30 AppendBytes(element.data.data(), static_cast<int>(element.data.size()));
31 }
32 break;
33 case WebHTTPBody::Element::TypeFile:
34 if (element.file_length == -1) {
35 AppendFileRange(
36 base::FilePath::FromUTF16Unsafe(element.file_path.string()), 0,
37 std::numeric_limits<uint64_t>::max(), base::Time());
38 } else {
39 AppendFileRange(
40 base::FilePath::FromUTF16Unsafe(element.file_path.string()),
41 static_cast<uint64_t>(element.file_start),
42 static_cast<uint64_t>(element.file_length),
43 base::Time::FromDoubleT(element.file_modification_time));
44 }
45 break;
46 case WebHTTPBody::Element::TypeFileSystemURL: {
47 GURL file_system_url = element.filesystem_url;
48 DCHECK(file_system_url.SchemeIsFileSystem());
49 AppendFileSystemFileRange(
50 file_system_url, static_cast<uint64_t>(element.file_start),
51 static_cast<uint64_t>(element.file_length),
52 base::Time::FromDoubleT(element.file_modification_time));
53 break;
54 }
55 case WebHTTPBody::Element::TypeBlob:
56 AppendBlob(element.blob_uuid);
57 break;
58 default:
59 NOTREACHED();
60 }
61 }
62
13 void ResourceRequestBody::AppendBytes(const char* bytes, int bytes_len) { 63 void ResourceRequestBody::AppendBytes(const char* bytes, int bytes_len) {
14 if (bytes_len > 0) { 64 if (bytes_len > 0) {
15 elements_.push_back(Element()); 65 elements_.push_back(Element());
16 elements_.back().SetToBytes(bytes, bytes_len); 66 elements_.back().SetToBytes(bytes, bytes_len);
17 } 67 }
18 } 68 }
19 69
20 void ResourceRequestBody::AppendFileRange( 70 void ResourceRequestBody::AppendFileRange(
21 const base::FilePath& file_path, 71 const base::FilePath& file_path,
22 uint64_t offset, 72 uint64_t offset,
(...skipping 16 matching lines...) Expand all
39 const base::Time& expected_modification_time) { 89 const base::Time& expected_modification_time) {
40 elements_.push_back(Element()); 90 elements_.push_back(Element());
41 elements_.back().SetToFileSystemUrlRange(url, offset, length, 91 elements_.back().SetToFileSystemUrlRange(url, offset, length,
42 expected_modification_time); 92 expected_modification_time);
43 } 93 }
44 94
45 ResourceRequestBody::~ResourceRequestBody() { 95 ResourceRequestBody::~ResourceRequestBody() {
46 } 96 }
47 97
48 } // namespace content 98 } // namespace content
OLDNEW
« 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