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

Side by Side Diff: net/test/embedded_test_server/request_handler_util.cc

Issue 2259823002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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/ssl/test_ssl_private_key.cc ('k') | net/test/url_request/url_request_hanging_read_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/embedded_test_server/request_handler_util.h" 5 #include "net/test/embedded_test_server/request_handler_util.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <ctime> 9 #include <ctime>
10 #include <sstream> 10 #include <sstream>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 base::FilePath headers_path( 194 base::FilePath headers_path(
195 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers"))); 195 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers")));
196 196
197 if (base::PathExists(headers_path)) { 197 if (base::PathExists(headers_path)) {
198 std::string headers_contents; 198 std::string headers_contents;
199 199
200 if (!base::ReadFileToString(headers_path, &headers_contents)) 200 if (!base::ReadFileToString(headers_path, &headers_contents))
201 return nullptr; 201 return nullptr;
202 202
203 return base::WrapUnique( 203 return base::MakeUnique<RawHttpResponse>(headers_contents, file_contents);
204 new RawHttpResponse(headers_contents, file_contents));
205 } 204 }
206 205
207 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); 206 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse);
208 http_response->set_code(HTTP_OK); 207 http_response->set_code(HTTP_OK);
209 208
210 if (request.headers.find("Range") != request.headers.end()) { 209 if (request.headers.find("Range") != request.headers.end()) {
211 std::vector<HttpByteRange> ranges; 210 std::vector<HttpByteRange> ranges;
212 211
213 if (HttpUtil::ParseRangeHeader(request.headers.at("Range"), &ranges) && 212 if (HttpUtil::ParseRangeHeader(request.headers.at("Range"), &ranges) &&
214 ranges.size() == 1) { 213 ranges.size() == 1) {
(...skipping 13 matching lines...) Expand all
228 227
229 http_response->set_content_type(GetContentType(file_path)); 228 http_response->set_content_type(GetContentType(file_path));
230 http_response->AddCustomHeader("Accept-Ranges", "bytes"); 229 http_response->AddCustomHeader("Accept-Ranges", "bytes");
231 http_response->AddCustomHeader("ETag", "'" + file_path.MaybeAsASCII() + "'"); 230 http_response->AddCustomHeader("ETag", "'" + file_path.MaybeAsASCII() + "'");
232 http_response->set_content(file_contents); 231 http_response->set_content(file_contents);
233 return std::move(http_response); 232 return std::move(http_response);
234 } 233 }
235 234
236 } // namespace test_server 235 } // namespace test_server
237 } // namespace net 236 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/test_ssl_private_key.cc ('k') | net/test/url_request/url_request_hanging_read_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698