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

Unified Diff: mojo/spy/websocket_server.h

Issue 258693011: First cut at mojo spy's websocket server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 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
« no previous file with comments | « mojo/spy/test/spy_repl_test.html ('k') | mojo/spy/websocket_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/spy/websocket_server.h
diff --git a/mojo/spy/websocket_server.h b/mojo/spy/websocket_server.h
new file mode 100644
index 0000000000000000000000000000000000000000..84830b8b8dad3f21499952e610fa05df5dc235d6
--- /dev/null
+++ b/mojo/spy/websocket_server.h
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SPY_WEBSOCKET_SERVER_H_
+#define MOJO_SPY_WEBSOCKET_SERVER_H_
+
+#include "net/server/http_server.h"
+
+namespace spy {
+
+class WebSocketServer : public net::HttpServer::Delegate {
+ public:
+ // Pass 0 in |port| to listen in one available port.
+ explicit WebSocketServer(int port);
+ virtual ~WebSocketServer();
+ // Begin accepting HTTP requests. Must be called from an IO MessageLoop.
+ bool Start();
+ // Returns the listening port, useful if 0 was passed to the contructor.
+ int port() const { return port_; }
+
+ protected:
+ // Overridden from net::HttpServer::Delegate.
+ virtual void OnHttpRequest(
+ int connection_id,
+ const net::HttpServerRequestInfo& info) OVERRIDE;
+ virtual void OnWebSocketRequest(
+ int connection_id,
+ const net::HttpServerRequestInfo& info) OVERRIDE;
+ virtual void OnWebSocketMessage(
+ int connection_id,
+ const std::string& data) OVERRIDE;
+ virtual void OnClose(int connection_id) OVERRIDE;
+
+ private:
+ int port_;
+ int connection_id_;
+ scoped_refptr<net::HttpServer> server_;
+ DISALLOW_COPY_AND_ASSIGN(WebSocketServer);
+};
+
+} // namespace spy
+
+#endif // MOJO_SPY_WEBSOCKET_SERVER_H_
« no previous file with comments | « mojo/spy/test/spy_repl_test.html ('k') | mojo/spy/websocket_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698