Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "net/socket/tcp_listen_socket.h" | 18 #include "net/socket/tcp_listen_socket.h" |
| 19 | 19 |
| 20 namespace base { | |
| 21 class FilePath; | |
| 22 } | |
| 23 | |
| 20 namespace net { | 24 namespace net { |
| 21 namespace test_server { | 25 namespace test_server { |
| 22 | 26 |
| 23 class HttpConnection; | 27 class HttpConnection; |
| 24 class HttpResponse; | 28 class HttpResponse; |
| 25 struct HttpRequest; | 29 struct HttpRequest; |
| 26 | 30 |
| 27 // This class is required to be able to have composition instead of inheritance, | 31 // This class is required to be able to have composition instead of inheritance, |
| 28 class HttpListenSocket : public TCPListenSocket { | 32 class HttpListenSocket : public TCPListenSocket { |
| 29 public: | 33 public: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 const GURL& base_url() const { return base_url_; } | 104 const GURL& base_url() const { return base_url_; } |
| 101 | 105 |
| 102 // Returns a URL to the server based on the given relative URL, which | 106 // Returns a URL to the server based on the given relative URL, which |
| 103 // should start with '/'. For example: GetURL("/path?query=foo") => | 107 // should start with '/'. For example: GetURL("/path?query=foo") => |
| 104 // http://127.0.0.1:<port>/path?query=foo. | 108 // http://127.0.0.1:<port>/path?query=foo. |
| 105 GURL GetURL(const std::string& relative_url) const; | 109 GURL GetURL(const std::string& relative_url) const; |
| 106 | 110 |
| 107 // Returns the port number used by the server. | 111 // Returns the port number used by the server. |
| 108 int port() const { return port_; } | 112 int port() const { return port_; } |
| 109 | 113 |
| 114 // Registers request handler which serves files from |directory|. | |
|
satorux1
2013/05/17 06:02:26
Would be nice to make it clearer:
For instance, a
Paweł Hajdan Jr.
2013/05/17 17:34:07
Done.
| |
| 115 void ServeFilesFromDirectory(const base::FilePath& directory); | |
| 116 | |
| 110 // The most general purpose method. Any request processing can be added using | 117 // The most general purpose method. Any request processing can be added using |
| 111 // this method. Takes ownership of the object. The |callback| is called | 118 // this method. Takes ownership of the object. The |callback| is called |
| 112 // on UI thread. | 119 // on UI thread. |
| 113 void RegisterRequestHandler(const HandleRequestCallback& callback); | 120 void RegisterRequestHandler(const HandleRequestCallback& callback); |
| 114 | 121 |
| 115 private: | 122 private: |
| 116 // Initializes and starts the server. If initialization succeeds, Starts() | 123 // Initializes and starts the server. If initialization succeeds, Starts() |
| 117 // will return true. | 124 // will return true. |
| 118 void InitializeOnIOThread(); | 125 void InitializeOnIOThread(); |
| 119 | 126 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 | 160 |
| 154 base::ThreadChecker thread_checker_; | 161 base::ThreadChecker thread_checker_; |
| 155 | 162 |
| 156 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); | 163 DISALLOW_COPY_AND_ASSIGN(EmbeddedTestServer); |
| 157 }; | 164 }; |
| 158 | 165 |
| 159 } // namespace test_servers | 166 } // namespace test_servers |
| 160 } // namespace net | 167 } // namespace net |
| 161 | 168 |
| 162 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ | 169 #endif // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_H_ |
| OLD | NEW |