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

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: 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..fd4e8068f7ebc143d55069a63c6152c399821455 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/non_thread_safe.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,8 @@ 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 base::NonThreadSafe {
satorux1 2013/04/22 01:12:01 In favor of less inheritance, please use base::Thr
Paweł Hajdan Jr. 2013/04/22 18:53:44 Done.
public:
HttpListenSocket(const SocketDescriptor socket_descriptor,
net::StreamListenSocket::Delegate* delegate);
@@ -62,21 +68,23 @@ class HttpListenSocket: public net::TCPListenSocket {
// return http_response.Pass();
// }
//
-class HttpServer : public net::StreamListenSocket::Delegate {
+class HttpServer : public net::StreamListenSocket::Delegate,
+ public base::NonThreadSafe {
public:
typedef base::Callback<scoped_ptr<HttpResponse>(const HttpRequest& request)>
HandleRequestCallback;
// Creates a http test server. InitializeAndWaitUntilReady() must be called
// 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);
satorux1 2013/04/22 01:12:01 Could you avoid using WaitableEvent? My experience
Paweł Hajdan Jr. 2013/04/22 18:53:44 It'd be great to have a constructive alternative.
satorux1 2013/04/23 01:31:04 Sorry I wasn't clear. I'm not disliking WaitableEv
satorux1 2013/04/23 08:08:50 FWIW, just to make it clearer: issues introduced
// 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_;
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_operations_unittest.cc ('k') | chrome/browser/google_apis/test_server/http_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698