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

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

Issue 668663006: Standardize usage of virtual/override/final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « mojo/spy/spy_server_impl.h ('k') | no next file » | 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 "base/macros.h" 10 #include "base/macros.h"
11 #include "mojo/spy/common.h" 11 #include "mojo/spy/common.h"
12 #include "mojo/spy/public/spy.mojom.h" 12 #include "mojo/spy/public/spy.mojom.h"
13 #include "net/server/http_server.h" 13 #include "net/server/http_server.h"
14 14
15 namespace base { 15 namespace base {
16 class Time; 16 class Time;
17 }; 17 };
18 18
19 class GURL; 19 class GURL;
20 20
21 namespace mojo { 21 namespace mojo {
22 22
23 class WebSocketServer : public net::HttpServer::Delegate, 23 class WebSocketServer : public net::HttpServer::Delegate,
24 public spy_api::SpyClient { 24 public spy_api::SpyClient {
25 public: 25 public:
26 // Pass 0 in |port| to listen in one available port. 26 // Pass 0 in |port| to listen in one available port.
27 explicit WebSocketServer(int port, ScopedMessagePipeHandle server_pipe); 27 explicit WebSocketServer(int port, ScopedMessagePipeHandle server_pipe);
28 virtual ~WebSocketServer(); 28 ~WebSocketServer() override;
29 // Begin accepting HTTP requests. Must be called from an IO MessageLoop. 29 // Begin accepting HTTP requests. Must be called from an IO MessageLoop.
30 bool Start(); 30 bool Start();
31 // Returns the listening port, useful if 0 was passed to the contructor. 31 // Returns the listening port, useful if 0 was passed to the contructor.
32 int port() const { return port_; } 32 int port() const { return port_; }
33 33
34 // Maintains a log of the message passed in. 34 // Maintains a log of the message passed in.
35 void LogMessageInfo( 35 void LogMessageInfo(
36 const mojo::MojoRequestHeader& message_header, 36 const mojo::MojoRequestHeader& message_header,
37 const GURL& url, 37 const GURL& url,
38 const base::Time& message_time); 38 const base::Time& message_time);
39 39
40 protected: 40 protected:
41 // Overridden from net::HttpServer::Delegate. 41 // Overridden from net::HttpServer::Delegate.
42 virtual void OnConnect(int connection_id) override {} 42 void OnConnect(int connection_id) override {}
43 virtual void OnHttpRequest( 43 void OnHttpRequest(int connection_id,
44 int connection_id, 44 const net::HttpServerRequestInfo& info) override;
45 const net::HttpServerRequestInfo& info) override; 45 void OnWebSocketRequest(int connection_id,
46 virtual void OnWebSocketRequest( 46 const net::HttpServerRequestInfo& info) override;
47 int connection_id, 47 void OnWebSocketMessage(int connection_id, const std::string& data) override;
48 const net::HttpServerRequestInfo& info) override; 48 void OnClose(int connection_id) override;
49 virtual void OnWebSocketMessage(
50 int connection_id,
51 const std::string& data) override;
52 virtual void OnClose(int connection_id) override;
53 49
54 // Overriden form spy_api::SpyClient. 50 // Overriden form spy_api::SpyClient.
55 virtual void OnFatalError(spy_api::Result result) override; 51 void OnFatalError(spy_api::Result result) override;
56 virtual void OnSessionEnd(spy_api::Result result) override; 52 void OnSessionEnd(spy_api::Result result) override;
57 virtual void OnClientConnection( 53 void OnClientConnection(const mojo::String& name,
58 const mojo::String& name, 54 uint32_t id,
59 uint32_t id, 55 spy_api::ConnectionOptions options) override;
60 spy_api::ConnectionOptions options) override; 56 void OnMessage(spy_api::MessagePtr message) override;
61 virtual void OnMessage(spy_api::MessagePtr message) override;
62 57
63 // Callbacks from calling spy_api::SpyServer. 58 // Callbacks from calling spy_api::SpyServer.
64 void OnStartSession(spy_api::Result, mojo::String); 59 void OnStartSession(spy_api::Result, mojo::String);
65 60
66 bool Connected() const; 61 bool Connected() const;
67 62
68 private: 63 private:
69 int port_; 64 int port_;
70 int connection_id_; 65 int connection_id_;
71 scoped_ptr<net::HttpServer> web_server_; 66 scoped_ptr<net::HttpServer> web_server_;
72 spy_api::SpyServerPtr spy_server_; 67 spy_api::SpyServerPtr spy_server_;
73 68
74 DISALLOW_COPY_AND_ASSIGN(WebSocketServer); 69 DISALLOW_COPY_AND_ASSIGN(WebSocketServer);
75 }; 70 };
76 71
77 } // namespace mojo 72 } // namespace mojo
78 73
79 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_ 74 #endif // MOJO_SPY_WEBSOCKET_SERVER_H_
OLDNEW
« no previous file with comments | « mojo/spy/spy_server_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698