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

Unified Diff: chrome/browser/google_apis/test_server/http_server.h

Issue 14365019: Break dependencies preventing move of test_server down to net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ThreadChecker Created 7 years, 8 months 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 side-by-side diff with in-line comments
Download patch
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..3ba63f35e0d7a2b64fa65067fc3983d82a85a892 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;
+};
+
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
@@ -69,14 +76,15 @@ class HttpServer : public net::StreamListenSocket::Delegate {
// Creates a http test server. InitializeAndWaitUntilReady() must be called
satorux1 2013/04/23 07:57:05 Please add some comment about |io_thread| paramete
Paweł Hajdan Jr. 2013/04/23 22:12:42 Done.
// to start the server.
- HttpServer();
+ 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 {
@@ -104,10 +112,10 @@ class HttpServer : public net::StreamListenSocket::Delegate {
private:
// Initializes and starts the server. If initialization succeeds, Starts()
// will return true.
- void InitializeOnIOThread();
+ void InitializeOnIOThread(base::WaitableEvent* event);
// Shuts down the server.
- void ShutdownOnIOThread();
+ void ShutdownOnIOThread(base::WaitableEvent* event);
// Handles a request when it is parsed. It passes the request to registed
// request handlers and sends a http response.
@@ -124,6 +132,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 +148,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);
};

Powered by Google App Engine
This is Rietveld 408576698