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

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: Rebasing... 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) {
Łukasz Anforowicz 2016/05/26 16:26:52 This branch is taken by some tests. I assume that
Charlie Reis 2016/05/27 21:45:53 Oh, interesting. I see that this old code never a
Łukasz Anforowicz 2016/05/31 16:38:04 Done - I should have written it this way from the
96 ExplodedHttpBodyElement element;
97 element.SetToFilePath(*optional_body_file_path);
98 state.referenced_files.push_back(base::NullableString16( 95 state.referenced_files.push_back(base::NullableString16(
99 optional_body_file_path->AsUTF16Unsafe(), false)); 96 optional_body_file_path->AsUTF16Unsafe(), false));
100 } 97 }
101 state.top.http_body.contains_passwords = 98 state.top.http_body.contains_passwords =
102 body_contains_password_data; 99 body_contains_password_data;
103 } 100 }
104 101
105 return ToPageState(state); 102 return ToPageState(state);
106 } 103 }
107 104
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 161 }
165 162
166 PageState::PageState(const std::string& data) 163 PageState::PageState(const std::string& data)
167 : data_(data) { 164 : data_(data) {
168 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass 165 // TODO(darin): Enable this DCHECK once tests have been fixed up to not pass
169 // bogus encoded data to CreateFromEncodedData. 166 // bogus encoded data to CreateFromEncodedData.
170 //DCHECK(IsValid()); 167 //DCHECK(IsValid());
171 } 168 }
172 169
173 } // namespace content 170 } // 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