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

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

Issue 657013003: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 base::FilePath headers_path( 66 base::FilePath headers_path(
67 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers"))); 67 file_path.AddExtension(FILE_PATH_LITERAL("mock-http-headers")));
68 68
69 if (base::PathExists(headers_path)) { 69 if (base::PathExists(headers_path)) {
70 std::string headers_contents; 70 std::string headers_contents;
71 if (!base::ReadFileToString(headers_path, &headers_contents)) 71 if (!base::ReadFileToString(headers_path, &headers_contents))
72 return scoped_ptr<HttpResponse>(); 72 return scoped_ptr<HttpResponse>();
73 73
74 scoped_ptr<CustomHttpResponse> http_response( 74 scoped_ptr<CustomHttpResponse> http_response(
75 new CustomHttpResponse(headers_contents, file_contents)); 75 new CustomHttpResponse(headers_contents, file_contents));
76 return http_response.PassAs<HttpResponse>(); 76 return http_response.Pass();
77 } 77 }
78 78
79 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse); 79 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse);
80 http_response->set_code(HTTP_OK); 80 http_response->set_code(HTTP_OK);
81 http_response->set_content(file_contents); 81 http_response->set_content(file_contents);
82 return http_response.PassAs<HttpResponse>(); 82 return http_response.Pass();
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 HttpListenSocket::HttpListenSocket(const SocketDescriptor socket_descriptor, 87 HttpListenSocket::HttpListenSocket(const SocketDescriptor socket_descriptor,
88 StreamListenSocket::Delegate* delegate) 88 StreamListenSocket::Delegate* delegate)
89 : TCPListenSocket(socket_descriptor, delegate) { 89 : TCPListenSocket(socket_descriptor, delegate) {
90 DCHECK(thread_checker_.CalledOnValidThread()); 90 DCHECK(thread_checker_.CalledOnValidThread());
91 } 91 }
92 92
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 request_handled = true; 236 request_handled = true;
237 break; 237 break;
238 } 238 }
239 } 239 }
240 240
241 if (!request_handled) { 241 if (!request_handled) {
242 LOG(WARNING) << "Request not handled. Returning 404: " 242 LOG(WARNING) << "Request not handled. Returning 404: "
243 << request->relative_url; 243 << request->relative_url;
244 scoped_ptr<BasicHttpResponse> not_found_response(new BasicHttpResponse); 244 scoped_ptr<BasicHttpResponse> not_found_response(new BasicHttpResponse);
245 not_found_response->set_code(HTTP_NOT_FOUND); 245 not_found_response->set_code(HTTP_NOT_FOUND);
246 connection->SendResponse( 246 connection->SendResponse(not_found_response.Pass());
247 not_found_response.PassAs<HttpResponse>());
248 } 247 }
249 248
250 // Drop the connection, since we do not support multiple requests per 249 // Drop the connection, since we do not support multiple requests per
251 // connection. 250 // connection.
252 connections_.erase(connection->socket_.get()); 251 connections_.erase(connection->socket_.get());
253 delete connection; 252 delete connection;
254 } 253 }
255 254
256 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const { 255 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const {
257 DCHECK(Started()) << "You must start the server first."; 256 DCHECK(Started()) << "You must start the server first.";
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 FROM_HERE, closure, run_loop.QuitClosure())) { 338 FROM_HERE, closure, run_loop.QuitClosure())) {
340 return false; 339 return false;
341 } 340 }
342 run_loop.Run(); 341 run_loop.Run();
343 342
344 return true; 343 return true;
345 } 344 }
346 345
347 } // namespace test_server 346 } // namespace test_server
348 } // namespace net 347 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/unix_domain_listen_socket_posix.cc ('k') | net/test/embedded_test_server/embedded_test_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698