| 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 SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ | 5 #ifndef SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ |
| 6 #define SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ | 6 #define SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ |
| 7 | 7 |
| 8 #include "mojo/public/cpp/application/interface_factory_impl.h" | 8 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 9 #include "mojo/public/cpp/bindings/interface_impl.h" | 9 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 10 #include "net/server/http_server.h" | 10 #include "net/server/http_server.h" |
| 11 #include "net/socket/tcp_server_socket.h" | 11 #include "net/socket/tcp_server_socket.h" |
| 12 #include "sky/services/inspector/inspector.mojom.h" | 12 #include "sky/services/inspector/inspector.mojom.h" |
| 13 | 13 |
| 14 namespace sky { | 14 namespace sky { |
| 15 namespace inspector { | 15 namespace inspector { |
| 16 | 16 |
| 17 class InspectorFronendImpl : public mojo::InterfaceImpl<InspectorFrontend>, | 17 class InspectorFrontendImpl : public mojo::InterfaceImpl<InspectorFrontend>, |
| 18 public net::HttpServer::Delegate { | 18 public net::HttpServer::Delegate { |
| 19 public: | 19 public: |
| 20 InspectorFronendImpl(); | 20 InspectorFrontendImpl(); |
| 21 virtual ~InspectorFronendImpl(); | 21 virtual ~InspectorFrontendImpl(); |
| 22 | 22 |
| 23 private: | 23 private: |
| 24 // From net::HttpServer::Delegate | 24 // From net::HttpServer::Delegate |
| 25 virtual void OnConnect(int connection_id) override; | 25 virtual void OnConnect(int connection_id) override; |
| 26 virtual void OnHttpRequest( | 26 virtual void OnHttpRequest( |
| 27 int connection_id, const net::HttpServerRequestInfo& info) override; | 27 int connection_id, const net::HttpServerRequestInfo& info) override; |
| 28 virtual void OnWebSocketRequest( | 28 virtual void OnWebSocketRequest( |
| 29 int connection_id, const net::HttpServerRequestInfo& info) override; | 29 int connection_id, const net::HttpServerRequestInfo& info) override; |
| 30 virtual void OnWebSocketMessage( | 30 virtual void OnWebSocketMessage( |
| 31 int connection_id, const std::string& data) override; | 31 int connection_id, const std::string& data) override; |
| 32 virtual void OnClose(int connection_id) override; | 32 virtual void OnClose(int connection_id) override; |
| 33 | 33 |
| 34 // From InspectorFronend | 34 // From InspectorFrontend |
| 35 virtual void Listen(int32_t port) override; | 35 virtual void Listen(int32_t port) override; |
| 36 virtual void SendMessage(const mojo::String&) override; | 36 virtual void SendMessage(const mojo::String&) override; |
| 37 | 37 |
| 38 void StopListening(); | 38 void StopListening(); |
| 39 | 39 |
| 40 void Register(int port); | 40 void Register(int port); |
| 41 void Unregister(); | 41 void Unregister(); |
| 42 | 42 |
| 43 int port_; | 43 int port_; |
| 44 int connection_id_; | 44 int connection_id_; |
| 45 scoped_ptr<net::HttpServer> web_server_; | 45 scoped_ptr<net::HttpServer> web_server_; |
| 46 | 46 |
| 47 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFronendImpl); | 47 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFrontendImpl); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 typedef mojo::InterfaceFactoryImpl< | 50 typedef mojo::InterfaceFactoryImpl< |
| 51 InspectorFronendImpl> InspectorFronendFactory; | 51 InspectorFrontendImpl> InspectorFrontendFactory; |
| 52 | 52 |
| 53 } // namespace tester | 53 } // namespace tester |
| 54 } // namespace sky | 54 } // namespace sky |
| 55 | 55 |
| 56 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ | 56 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ |
| OLD | NEW |