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

Side by Side Diff: mojo/spy/websocket_server.h

Issue 354043003: Add support for logging information about mojo messages retrieved by the mojo debugger (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Presubmit warnings Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/spy/test/spy_repl_test.html ('k') | mojo/spy/websocket_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 MOJO_SPY_WEBSOCKET_SERVER_H_ 5 #ifndef MOJO_SPY_WEBSOCKET_SERVER_H_
6 #define MOJO_SPY_WEBSOCKET_SERVER_H_ 6 #define MOJO_SPY_WEBSOCKET_SERVER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/spy/common.h"
10 #include "mojo/spy/public/spy.mojom.h" 11 #include "mojo/spy/public/spy.mojom.h"
11 #include "net/server/http_server.h" 12 #include "net/server/http_server.h"
12 13
14 namespace base {
15 class Time;
16 };
17
18 class GURL;
19
13 namespace mojo { 20 namespace mojo {
14 21
15 class WebSocketServer : public net::HttpServer::Delegate, 22 class WebSocketServer : public net::HttpServer::Delegate,
16 public spy_api::SpyClient { 23 public spy_api::SpyClient {
17 public: 24 public:
18 // Pass 0 in |port| to listen in one available port. 25 // Pass 0 in |port| to listen in one available port.
19 explicit WebSocketServer(int port, ScopedMessagePipeHandle server_pipe); 26 explicit WebSocketServer(int port, ScopedMessagePipeHandle server_pipe);
20 virtual ~WebSocketServer(); 27 virtual ~WebSocketServer();
21 // Begin accepting HTTP requests. Must be called from an IO MessageLoop. 28 // Begin accepting HTTP requests. Must be called from an IO MessageLoop.
22 bool Start(); 29 bool Start();
23 // Returns the listening port, useful if 0 was passed to the contructor. 30 // Returns the listening port, useful if 0 was passed to the contructor.
24 int port() const { return port_; } 31 int port() const { return port_; }
25 32
33 // Maintains a log of the message passed in.
34 void LogMessageInfo(
35 const mojo::MojoRequestHeader& message_header,
36 const GURL& url,
37 const base::Time& message_time);
38
26 protected: 39 protected:
27 // Overridden from net::HttpServer::Delegate. 40 // Overridden from net::HttpServer::Delegate.
28 virtual void OnHttpRequest( 41 virtual void OnHttpRequest(
29 int connection_id, 42 int connection_id,
30 const net::HttpServerRequestInfo& info) OVERRIDE; 43 const net::HttpServerRequestInfo& info) OVERRIDE;
31 virtual void OnWebSocketRequest( 44 virtual void OnWebSocketRequest(
32 int connection_id, 45 int connection_id,
33 const net::HttpServerRequestInfo& info) OVERRIDE; 46 const net::HttpServerRequestInfo& info) OVERRIDE;
34 virtual void OnWebSocketMessage( 47 virtual void OnWebSocketMessage(
35 int connection_id, 48 int connection_id,
36 const std::string& data) OVERRIDE; 49 const std::string& data) OVERRIDE;
37 virtual void OnClose(int connection_id) OVERRIDE; 50 virtual void OnClose(int connection_id) OVERRIDE;
38 51
39 // Overriden form spy_api::SpyClient. 52 // Overriden form spy_api::SpyClient.
40 virtual void OnFatalError(spy_api::Result result) OVERRIDE; 53 virtual void OnFatalError(spy_api::Result result) OVERRIDE;
41 virtual void OnSessionEnd(spy_api::Result result) OVERRIDE; 54 virtual void OnSessionEnd(spy_api::Result result) OVERRIDE;
42 virtual void OnClientConnection( 55 virtual void OnClientConnection(
43 const mojo::String& name, 56 const mojo::String& name,
44 uint32_t id, 57 uint32_t id,
45 spy_api::ConnectionOptions options) OVERRIDE; 58 spy_api::ConnectionOptions options) OVERRIDE;
46 virtual void OnMessage(spy_api::MessagePtr message) OVERRIDE; 59 virtual void OnMessage(spy_api::MessagePtr message) OVERRIDE;
47 60
48 // Callbacks from calling spy_api::SpyServer. 61 // Callbacks from calling spy_api::SpyServer.
49 void OnStartSession(spy_api::Result, mojo::String); 62 void OnStartSession(spy_api::Result, mojo::String);
50 63
64 bool Connected() const;
65
51 private: 66 private:
52 int port_; 67 int port_;
53 int connection_id_; 68 int connection_id_;
54 scoped_refptr<net::HttpServer> web_server_; 69 scoped_refptr<net::HttpServer> web_server_;
55 spy_api::SpyServerPtr spy_server_; 70 spy_api::SpyServerPtr spy_server_;
56 71
57 DISALLOW_COPY_AND_ASSIGN(WebSocketServer); 72 DISALLOW_COPY_AND_ASSIGN(WebSocketServer);
58 }; 73 };
59 74
60 } // namespace mojo 75 } // namespace mojo
61 76
62 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_ 77 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_
OLDNEW
« 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