Chromium Code Reviews| Index: chrome/browser/google_apis/test_server/http_server.h |
| diff --git a/chrome/browser/google_apis/test_server/http_server.h b/chrome/browser/google_apis/test_server/http_server.h |
| index 9f288eeb8c82bc16998bb6d6503a612a6fb99c56..9aea0ea109375b26fe735a7a2df97bac853a4d52 100644 |
| --- a/chrome/browser/google_apis/test_server/http_server.h |
| +++ b/chrome/browser/google_apis/test_server/http_server.h |
| @@ -13,9 +13,14 @@ |
| #include "base/compiler_specific.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| #include "googleurl/src/gurl.h" |
| #include "net/socket/tcp_listen_socket.h" |
| +namespace base { |
| +class WaitableEvent; |
|
tfarina
2013/04/23 22:14:06
looks like you can remove this now.
satorux1
2013/04/23 23:39:53
good catch! please remove before submit.
Paweł Hajdan Jr.
2013/04/24 18:10:37
Done.
|
| +}; |
| + |
| namespace google_apis { |
| namespace test_server { |
| @@ -24,7 +29,7 @@ class HttpResponse; |
| struct HttpRequest; |
| // This class is required to be able to have composition instead of inheritance, |
| -class HttpListenSocket: public net::TCPListenSocket { |
| +class HttpListenSocket : public net::TCPListenSocket { |
| public: |
| HttpListenSocket(const SocketDescriptor socket_descriptor, |
| net::StreamListenSocket::Delegate* delegate); |
| @@ -32,6 +37,8 @@ class HttpListenSocket: public net::TCPListenSocket { |
| private: |
| virtual ~HttpListenSocket(); |
| + |
| + base::ThreadChecker thread_checker_; |
| }; |
| // Class providing an HTTP server for testing purpose. This is a basic server |
| @@ -67,16 +74,18 @@ class HttpServer : public net::StreamListenSocket::Delegate { |
| typedef base::Callback<scoped_ptr<HttpResponse>(const HttpRequest& request)> |
| HandleRequestCallback; |
| - // Creates a http test server. InitializeAndWaitUntilReady() must be called |
| - // to start the server. |
| - HttpServer(); |
| + // Creates a http test server. |io_thread| is a task runner |
| + // with IO message loop, used as a backend thread. |
| + // InitializeAndWaitUntilReady() must be called to start the server. |
| + explicit HttpServer( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_thread); |
| virtual ~HttpServer(); |
| // Initializes and waits until the server is ready to accept requests. |
| - bool InitializeAndWaitUntilReady(); |
| + bool InitializeAndWaitUntilReady() WARN_UNUSED_RESULT; |
| // Shuts down the http server and waits until the shutdown is complete. |
| - void ShutdownAndWaitUntilComplete(); |
| + bool ShutdownAndWaitUntilComplete() WARN_UNUSED_RESULT; |
| // Checks if the server is started. |
| bool Started() const { |
| @@ -124,6 +133,8 @@ class HttpServer : public net::StreamListenSocket::Delegate { |
| HttpConnection* FindConnection(net::StreamListenSocket* socket); |
| + scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| + |
| scoped_refptr<HttpListenSocket> listen_socket_; |
| int port_; |
| GURL base_url_; |
| @@ -138,6 +149,8 @@ class HttpServer : public net::StreamListenSocket::Delegate { |
| // invalidate its weak pointers before any other members are destroyed. |
| base::WeakPtrFactory<HttpServer> weak_factory_; |
| + base::ThreadChecker thread_checker_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(HttpServer); |
| }; |