| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 // Returns the port number used by the server. | 138 // Returns the port number used by the server. |
| 139 uint16 port() const { return port_; } | 139 uint16 port() const { return port_; } |
| 140 | 140 |
| 141 // Registers request handler which serves files from |directory|. | 141 // Registers request handler which serves files from |directory|. |
| 142 // For instance, a request to "/foo.html" is served by "foo.html" under | 142 // For instance, a request to "/foo.html" is served by "foo.html" under |
| 143 // |directory|. Files under sub directories are also handled in the same way | 143 // |directory|. Files under sub directories are also handled in the same way |
| 144 // (i.e. "/foo/bar.html" is served by "foo/bar.html" under |directory|). | 144 // (i.e. "/foo/bar.html" is served by "foo/bar.html" under |directory|). |
| 145 void ServeFilesFromDirectory(const base::FilePath& directory); | 145 void ServeFilesFromDirectory(const base::FilePath& directory); |
| 146 | 146 |
| 147 // Similar to the above method, but takes multiple directories. The first |
| 148 // matched file would be served. |
| 149 void ServeFilesFromDirectories( |
| 150 const std::vector<base::FilePath>& directories); |
| 151 |
| 147 // The most general purpose method. Any request processing can be added using | 152 // The most general purpose method. Any request processing can be added using |
| 148 // this method. Takes ownership of the object. The |callback| is called | 153 // this method. Takes ownership of the object. The |callback| is called |
| 149 // on UI thread. | 154 // on UI thread. |
| 150 void RegisterRequestHandler(const HandleRequestCallback& callback); | 155 void RegisterRequestHandler(const HandleRequestCallback& callback); |
| 151 | 156 |
| 152 // Stops IO thread that handles http requests. | 157 // Stops IO thread that handles http requests. |
| 153 void StopThread(); | 158 void StopThread(); |
| 154 | 159 |
| 155 // Restarts IO thread and listen on the socket. | 160 // Restarts IO thread and listen on the socket. |
| 156 void RestartThreadAndListen(); | 161 void RestartThreadAndListen(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // invalidate its weak pointers before any other members are destroyed. | 208 // invalidate its weak pointers before any other members are destroyed. |
| 204 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; | 209 base::WeakPtrFactory<EmbeddedTestServer> weak_factory_; |
| 205 | 210 |
| 206 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); | 211 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); |
| 207 }; | 212 }; |
| 208 | 213 |
| 209 } // namespace test_servers | 214 } // namespace test_servers |
| 210 } // namespace net | 215 } // namespace net |
| 211 | 216 |
| 212 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 217 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
| OLD | NEW |