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

Side by Side Diff: net/test/url_request/url_request_mock_http_job.cc

Issue 1200393002: Add more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string
Patch Set: Android Created 5 years, 5 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 | « net/ftp/ftp_util.cc ('k') | net/test/url_request/url_request_slow_download_job.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/test/url_request/url_request_mock_http_job.h" 5 #include "net/test/url_request/url_request_mock_http_job.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 task_runner_.get(), 182 task_runner_.get(),
183 FROM_HERE, 183 FROM_HERE,
184 base::Bind(&DoFileIO, file_path_), 184 base::Bind(&DoFileIO, file_path_),
185 base::Bind(&URLRequestMockHTTPJob::SetHeadersAndStart, 185 base::Bind(&URLRequestMockHTTPJob::SetHeadersAndStart,
186 weak_ptr_factory_.GetWeakPtr())); 186 weak_ptr_factory_.GetWeakPtr()));
187 } 187 }
188 188
189 void URLRequestMockHTTPJob::SetHeadersAndStart(const std::string& raw_headers) { 189 void URLRequestMockHTTPJob::SetHeadersAndStart(const std::string& raw_headers) {
190 raw_headers_ = raw_headers; 190 raw_headers_ = raw_headers;
191 // Handle CRLF line-endings. 191 // Handle CRLF line-endings.
192 ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n"); 192 base::ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\r\n", "\n");
193 // ParseRawHeaders expects \0 to end each header line. 193 // ParseRawHeaders expects \0 to end each header line.
194 ReplaceSubstringsAfterOffset(&raw_headers_, 0, "\n", std::string("\0", 1)); 194 base::ReplaceSubstringsAfterOffset(
195 &raw_headers_, 0, "\n", base::StringPiece("\0", 1));
195 URLRequestFileJob::Start(); 196 URLRequestFileJob::Start();
196 } 197 }
197 198
198 // Private const version. 199 // Private const version.
199 void URLRequestMockHTTPJob::GetResponseInfoConst(HttpResponseInfo* info) const { 200 void URLRequestMockHTTPJob::GetResponseInfoConst(HttpResponseInfo* info) const {
200 info->headers = new HttpResponseHeaders(raw_headers_); 201 info->headers = new HttpResponseHeaders(raw_headers_);
201 } 202 }
202 203
203 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { 204 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const {
204 HttpResponseInfo info; 205 HttpResponseInfo info;
(...skipping 10 matching lines...) Expand all
215 return URLRequestJob::GetResponseCode(); 216 return URLRequestJob::GetResponseCode();
216 } 217 }
217 218
218 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { 219 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) {
219 HttpResponseInfo info; 220 HttpResponseInfo info;
220 GetResponseInfo(&info); 221 GetResponseInfo(&info);
221 return info.headers.get() && info.headers->GetCharset(charset); 222 return info.headers.get() && info.headers->GetCharset(charset);
222 } 223 }
223 224
224 } // namespace net 225 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | net/test/url_request/url_request_slow_download_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698