OLD | NEW |
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 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
6 #define NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 6 #define NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // | 70 // |
71 // scoped_ptr<HttpResponse> http_response(new HttpResponse()); | 71 // scoped_ptr<HttpResponse> http_response(new HttpResponse()); |
72 // http_response->set_code(test_server::SUCCESS); | 72 // http_response->set_code(test_server::SUCCESS); |
73 // http_response->set_content("hello"); | 73 // http_response->set_content("hello"); |
74 // http_response->set_content_type("text/plain"); | 74 // http_response->set_content_type("text/plain"); |
75 // return http_response.Pass(); | 75 // return http_response.Pass(); |
76 // } | 76 // } |
77 // | 77 // |
78 class EmbeddedTestServer : public StreamListenSocket::Delegate { | 78 class EmbeddedTestServer : public StreamListenSocket::Delegate { |
79 public: | 79 public: |
80 typedef base::Callback<scoped_ptr<HttpResponse>(const HttpRequest& request)> | 80 typedef base::Callback<scoped_ptr<HttpResponse>( |
81 HandleRequestCallback; | 81 const HttpRequest& request)> HandleRequestCallback; |
82 | 82 |
83 // Creates a http test server. |io_thread| is a task runner | 83 // Creates a http test server. |io_thread| is a task runner |
84 // with IO message loop, used as a backend thread. | 84 // with IO message loop, used as a backend thread. |
85 // InitializeAndWaitUntilReady() must be called to start the server. | 85 // InitializeAndWaitUntilReady() must be called to start the server. |
86 explicit EmbeddedTestServer( | 86 explicit EmbeddedTestServer( |
87 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread); | 87 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread); |
88 virtual ~EmbeddedTestServer(); | 88 virtual ~EmbeddedTestServer(); |
89 | 89 |
90 // Initializes and waits until the server is ready to accept requests. | 90 // Initializes and waits until the server is ready to accept requests. |
91 bool InitializeAndWaitUntilReady() WARN_UNUSED_RESULT; | 91 bool InitializeAndWaitUntilReady() WARN_UNUSED_RESULT; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 base::ThreadChecker thread_checker_; | 164 base::ThreadChecker thread_checker_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); | 166 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace test_servers | 169 } // namespace test_servers |
170 } // namespace net | 170 } // namespace net |
171 | 171 |
172 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 172 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
OLD | NEW |