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

Side by Side Diff: content/public/common/page_state.cc

Issue 2012913002: Deduping conversions between ResourceRequestBody/WebHTTPBody/ExplodedHttpBody. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-rid-of-exploded-http-body
Patch Set: Calling ResourceRequestBody::AppendFileRange with optional_body_file_path. Created 4 years, 6 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/content_renderer.gypi ('k') | content/renderer/history_serialization.cc » ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/public/common/page_state.h" 5 #include "content/public/common/page_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/strings/nullable_string16.h" 10 #include "base/strings/nullable_string16.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 PageState PageState::CreateForTesting( 78 PageState PageState::CreateForTesting(
79 const GURL& url, 79 const GURL& url,
80 bool body_contains_password_data, 80 bool body_contains_password_data,
81 const char* optional_body_data, 81 const char* optional_body_data,
82 const base::FilePath* optional_body_file_path) { 82 const base::FilePath* optional_body_file_path) {
83 ExplodedPageState state; 83 ExplodedPageState state;
84 84
85 state.top.url_string = ToNullableString16(url.possibly_invalid_spec()); 85 state.top.url_string = ToNullableString16(url.possibly_invalid_spec());
86 86
87 if (optional_body_data || optional_body_file_path) { 87 if (optional_body_data || optional_body_file_path) {
88 state.top.http_body.is_null = false;
89 if (optional_body_data) { 88 if (optional_body_data) {
90 ExplodedHttpBodyElement element;
91 std::string body_data(optional_body_data); 89 std::string body_data(optional_body_data);
92 element.SetToBytes(body_data.data(), body_data.size()); 90 state.top.http_body.request_body = new ResourceRequestBody();
93 state.top.http_body.elements.push_back(element); 91 state.top.http_body.request_body->AppendBytes(body_data.data(),
92 body_data.size());
94 } 93 }
95 if (optional_body_file_path) { 94 if (optional_body_file_path) {
96 ExplodedHttpBodyElement element; 95 state.top.http_body.request_body = new ResourceRequestBody();
97 element.SetToFilePath(*optional_body_file_path); 96 state.top.http_body.request_body->AppendFileRange(
97 *optional_body_file_path,
98 0, std::numeric_limits<uint64_t>::max(),
99 base::Time());
98 state.referenced_files.push_back(base::NullableString16( 100 state.referenced_files.push_back(base::NullableString16(
99 optional_body_file_path->AsUTF16Unsafe(), false)); 101 optional_body_file_path->AsUTF16Unsafe(), false));
100 } 102 }
101 state.top.http_body.contains_passwords = 103 state.top.http_body.contains_passwords =
102 body_contains_password_data; 104 body_contains_password_data;
103 } 105 }
104 106
105 return ToPageState(state); 107 return ToPageState(state);
106 } 108 }
107 109
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 166 }
165 167
166 PageState::PageState(const std::string& data) 168 PageState::PageState(const std::string& data)
167 : data_(data) { 169 : data_(data) {
168 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass 170 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass
169 // bogus encoded data to CreateFromEncodedData. 171 // bogus encoded data to CreateFromEncodedData.
170 //DCHECK(IsValid()); 172 //DCHECK(IsValid());
171 } 173 }
172 174
173 } // namespace content 175 } // namespace content
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/history_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698