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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/test/cert_test_util.cc ('k') | net/test/spawned_test_server/remote_test_server.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/embedded_test_server/embedded_test_server.h" 5 #include "net/test/embedded_test_server/embedded_test_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Trim the first byte ('/'). 52 // Trim the first byte ('/').
53 std::string request_path(request.relative_url.substr(1)); 53 std::string request_path(request.relative_url.substr(1));
54 54
55 // Remove the query string if present. 55 // Remove the query string if present.
56 size_t query_pos = request_path.find('?'); 56 size_t query_pos = request_path.find('?');
57 if (query_pos != std::string::npos) 57 if (query_pos != std::string::npos)
58 request_path = request_path.substr(0, query_pos); 58 request_path = request_path.substr(0, query_pos);
59 59
60 base::FilePath file_path(server_root.AppendASCII(request_path)); 60 base::FilePath file_path(server_root.AppendASCII(request_path));
61 std::string file_contents; 61 std::string file_contents;
62 if (!file_util::ReadFileToString(file_path, &file_contents)) 62 if (!base::ReadFileToString(file_path, &file_contents))
63 return scoped_ptr<HttpResponse>(); 63 return scoped_ptr<HttpResponse>();
64 64
65 base::FilePath headers_path( 65 base::FilePath headers_path(
66 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers"))); 66 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers")));
67 67
68 if (base::PathExists(headers_path)) { 68 if (base::PathExists(headers_path)) {
69 std::string headers_contents; 69 std::string headers_contents;
70 if (!file_util::ReadFileToString(headers_path, &headers_contents)) 70 if (!base::ReadFileToString(headers_path, &headers_contents))
71 return scoped_ptr<HttpResponse>(); 71 return scoped_ptr<HttpResponse>();
72 72
73 scoped_ptr<CustomHttpResponse> http_response( 73 scoped_ptr<CustomHttpResponse> http_response(
74 new CustomHttpResponse(headers_contents, file_contents)); 74 new CustomHttpResponse(headers_contents, file_contents));
75 return http_response.PassAs<HttpResponse>(); 75 return http_response.PassAs<HttpResponse>();
76 } 76 }
77 77
78 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); 78 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse);
79 http_response->set_code(HTTP_OK); 79 http_response->set_code(HTTP_OK);
80 http_response->set_content(file_contents); 80 http_response->set_content(file_contents);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 std::map<StreamListenSocket*, HttpConnection*>::iterator it = 267 std::map<StreamListenSocket*, HttpConnection*>::iterator it =
268 connections_.find(socket); 268 connections_.find(socket);
269 if (it == connections_.end()) { 269 if (it == connections_.end()) {
270 return NULL; 270 return NULL;
271 } 271 }
272 return it->second; 272 return it->second;
273 } 273 }
274 274
275 } // namespace test_server 275 } // namespace test_server
276 } // namespace net 276 } // namespace net
OLDNEW
« no previous file with comments | « net/test/cert_test_util.cc ('k') | net/test/spawned_test_server/remote_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698