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

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

Issue 1406313002: Adding Default Handlers from SpawnedTestServer to EmbeddedTestServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Adding comments. Created 5 years, 1 month 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/test/embedded_test_server/default_handlers.cc ('k') | no next file » | 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/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 11 matching lines...) Expand all
22 #include "net/base/ip_endpoint.h" 22 #include "net/base/ip_endpoint.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/base/test_data_directory.h" 24 #include "net/base/test_data_directory.h"
25 #include "net/cert/pem_tokenizer.h" 25 #include "net/cert/pem_tokenizer.h"
26 #include "net/cert/test_root_certs.h" 26 #include "net/cert/test_root_certs.h"
27 #include "net/socket/ssl_server_socket.h" 27 #include "net/socket/ssl_server_socket.h"
28 #include "net/socket/stream_socket.h" 28 #include "net/socket/stream_socket.h"
29 #include "net/socket/tcp_server_socket.h" 29 #include "net/socket/tcp_server_socket.h"
30 #include "net/ssl/ssl_server_config.h" 30 #include "net/ssl/ssl_server_config.h"
31 #include "net/test/cert_test_util.h" 31 #include "net/test/cert_test_util.h"
32 #include "net/test/embedded_test_server/default_handlers.h"
32 #include "net/test/embedded_test_server/embedded_test_server_connection_listener .h" 33 #include "net/test/embedded_test_server/embedded_test_server_connection_listener .h"
33 #include "net/test/embedded_test_server/http_connection.h" 34 #include "net/test/embedded_test_server/http_connection.h"
34 #include "net/test/embedded_test_server/http_request.h" 35 #include "net/test/embedded_test_server/http_request.h"
35 #include "net/test/embedded_test_server/http_response.h" 36 #include "net/test/embedded_test_server/http_response.h"
36 #include "net/test/embedded_test_server/request_handler_util.h" 37 #include "net/test/embedded_test_server/request_handler_util.h"
37 38
38 namespace net { 39 namespace net {
39 namespace test_server { 40 namespace test_server {
40 41
41 EmbeddedTestServer::EmbeddedTestServer() : EmbeddedTestServer(TYPE_HTTP) {} 42 EmbeddedTestServer::EmbeddedTestServer() : EmbeddedTestServer(TYPE_HTTP) {}
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 249 }
249 250
250 void EmbeddedTestServer::ServeFilesFromSourceDirectory( 251 void EmbeddedTestServer::ServeFilesFromSourceDirectory(
251 const base::FilePath& relative) { 252 const base::FilePath& relative) {
252 base::FilePath test_data_dir; 253 base::FilePath test_data_dir;
253 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); 254 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
254 ServeFilesFromDirectory(test_data_dir.Append(relative)); 255 ServeFilesFromDirectory(test_data_dir.Append(relative));
255 } 256 }
256 257
257 void EmbeddedTestServer::AddDefaultHandlers(const base::FilePath& directory) { 258 void EmbeddedTestServer::AddDefaultHandlers(const base::FilePath& directory) {
258 // TODO(svaldez): Add additional default handlers. 259 RegisterDefaultHandlers(this);
259 ServeFilesFromSourceDirectory(directory); 260 ServeFilesFromSourceDirectory(directory);
260 } 261 }
261 262
262 void EmbeddedTestServer::RegisterRequestHandler( 263 void EmbeddedTestServer::RegisterRequestHandler(
263 const HandleRequestCallback& callback) { 264 const HandleRequestCallback& callback) {
264 // TODO(svaldez): Add check to prevent RegisterHandler from being called 265 // TODO(svaldez): Add check to prevent RegisterHandler from being called
265 // after the server has started. https://crbug.com/546060 266 // after the server has started. https://crbug.com/546060
266 request_handlers_.push_back(callback); 267 request_handlers_.push_back(callback);
267 } 268 }
268 269
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 run_loop.QuitClosure())) { 424 run_loop.QuitClosure())) {
424 return false; 425 return false;
425 } 426 }
426 run_loop.Run(); 427 run_loop.Run();
427 428
428 return true; 429 return true;
429 } 430 }
430 431
431 } // namespace test_server 432 } // namespace test_server
432 } // namespace net 433 } // namespace net
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/default_handlers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698