| 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 InspectorFrontendImpl : public mojo::InterfaceImpl<InspectorFrontend>, | 17 class InspectorFrontendImpl : public mojo::InterfaceImpl<InspectorFrontend> { |
| 18 public net::HttpServer::Delegate { | |
| 19 public: | 18 public: |
| 20 InspectorFrontendImpl(); | 19 class Delegate { |
| 20 public: |
| 21 virtual void Register(InspectorFrontendImpl*) = 0; |
| 22 virtual void Unregister(InspectorFrontendImpl*) = 0; |
| 23 |
| 24 virtual void SendMessage(const mojo::String&) = 0; |
| 25 }; |
| 26 |
| 27 InspectorFrontendImpl(Delegate* delegate); |
| 21 virtual ~InspectorFrontendImpl(); | 28 virtual ~InspectorFrontendImpl(); |
| 22 | 29 |
| 30 void OnShutdown(); |
| 31 |
| 23 private: | 32 private: |
| 24 // From net::HttpServer::Delegate | 33 // InspectorFrontend: |
| 25 virtual void OnConnect(int connection_id) override; | 34 void SendMessage(const mojo::String& message) override; |
| 26 virtual void OnHttpRequest( | |
| 27 int connection_id, const net::HttpServerRequestInfo& info) override; | |
| 28 virtual void OnWebSocketRequest( | |
| 29 int connection_id, const net::HttpServerRequestInfo& info) override; | |
| 30 virtual void OnWebSocketMessage( | |
| 31 int connection_id, const std::string& data) override; | |
| 32 virtual void OnClose(int connection_id) override; | |
| 33 | 35 |
| 34 // From InspectorFrontend | 36 // InterfaceImpl: |
| 35 virtual void Listen(int32_t port) override; | 37 void OnConnectionError() override; |
| 36 virtual void SendMessage(const mojo::String&) override; | |
| 37 | 38 |
| 38 void StopListening(); | 39 Delegate* delegate_; |
| 39 | |
| 40 void Register(int port); | |
| 41 void Unregister(); | |
| 42 | |
| 43 int port_; | |
| 44 int connection_id_; | |
| 45 scoped_ptr<net::HttpServer> web_server_; | |
| 46 | 40 |
| 47 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFrontendImpl); | 41 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFrontendImpl); |
| 48 }; | 42 }; |
| 49 | 43 |
| 50 typedef mojo::InterfaceFactoryImpl< | |
| 51 InspectorFrontendImpl> InspectorFrontendFactory; | |
| 52 | |
| 53 } // namespace tester | 44 } // namespace tester |
| 54 } // namespace sky | 45 } // namespace sky |
| 55 | 46 |
| 56 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ | 47 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ |
| OLD | NEW |