OLD | NEW |
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 "base/macros.h" |
10 #include "mojo/spy/common.h" | 11 #include "mojo/spy/common.h" |
11 #include "mojo/spy/public/spy.mojom.h" | 12 #include "mojo/spy/public/spy.mojom.h" |
12 #include "net/server/http_server.h" | 13 #include "net/server/http_server.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class Time; | 16 class Time; |
16 }; | 17 }; |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 | 20 |
(...skipping 11 matching lines...) Expand all Loading... |
31 int port() const { return port_; } | 32 int port() const { return port_; } |
32 | 33 |
33 // Maintains a log of the message passed in. | 34 // Maintains a log of the message passed in. |
34 void LogMessageInfo( | 35 void LogMessageInfo( |
35 const mojo::MojoRequestHeader& message_header, | 36 const mojo::MojoRequestHeader& message_header, |
36 const GURL& url, | 37 const GURL& url, |
37 const base::Time& message_time); | 38 const base::Time& message_time); |
38 | 39 |
39 protected: | 40 protected: |
40 // Overridden from net::HttpServer::Delegate. | 41 // Overridden from net::HttpServer::Delegate. |
41 virtual void OnConnect(int connection_id) OVERRIDE {} | 42 virtual void OnConnect(int connection_id) override {} |
42 virtual void OnHttpRequest( | 43 virtual void OnHttpRequest( |
43 int connection_id, | 44 int connection_id, |
44 const net::HttpServerRequestInfo& info) OVERRIDE; | 45 const net::HttpServerRequestInfo& info) override; |
45 virtual void OnWebSocketRequest( | 46 virtual void OnWebSocketRequest( |
46 int connection_id, | 47 int connection_id, |
47 const net::HttpServerRequestInfo& info) OVERRIDE; | 48 const net::HttpServerRequestInfo& info) override; |
48 virtual void OnWebSocketMessage( | 49 virtual void OnWebSocketMessage( |
49 int connection_id, | 50 int connection_id, |
50 const std::string& data) OVERRIDE; | 51 const std::string& data) override; |
51 virtual void OnClose(int connection_id) OVERRIDE; | 52 virtual void OnClose(int connection_id) override; |
52 | 53 |
53 // Overriden form spy_api::SpyClient. | 54 // Overriden form spy_api::SpyClient. |
54 virtual void OnFatalError(spy_api::Result result) OVERRIDE; | 55 virtual void OnFatalError(spy_api::Result result) override; |
55 virtual void OnSessionEnd(spy_api::Result result) OVERRIDE; | 56 virtual void OnSessionEnd(spy_api::Result result) override; |
56 virtual void OnClientConnection( | 57 virtual void OnClientConnection( |
57 const mojo::String& name, | 58 const mojo::String& name, |
58 uint32_t id, | 59 uint32_t id, |
59 spy_api::ConnectionOptions options) OVERRIDE; | 60 spy_api::ConnectionOptions options) override; |
60 virtual void OnMessage(spy_api::MessagePtr message) OVERRIDE; | 61 virtual void OnMessage(spy_api::MessagePtr message) override; |
61 | 62 |
62 // Callbacks from calling spy_api::SpyServer. | 63 // Callbacks from calling spy_api::SpyServer. |
63 void OnStartSession(spy_api::Result, mojo::String); | 64 void OnStartSession(spy_api::Result, mojo::String); |
64 | 65 |
65 bool Connected() const; | 66 bool Connected() const; |
66 | 67 |
67 private: | 68 private: |
68 int port_; | 69 int port_; |
69 int connection_id_; | 70 int connection_id_; |
70 scoped_ptr<net::HttpServer> web_server_; | 71 scoped_ptr<net::HttpServer> web_server_; |
71 spy_api::SpyServerPtr spy_server_; | 72 spy_api::SpyServerPtr spy_server_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(WebSocketServer); | 74 DISALLOW_COPY_AND_ASSIGN(WebSocketServer); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace mojo | 77 } // namespace mojo |
77 | 78 |
78 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_ | 79 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_ |
OLD | NEW |