OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SKY_FRAMEWORK_INSPECTOR_SERVER_INSPECTOR_FRONTEND_IMPL_H_ |
| 6 #define SKY_FRAMEWORK_INSPECTOR_SERVER_INSPECTOR_FRONTEND_IMPL_H_ |
| 7 |
| 8 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 9 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 10 #include "net/server/http_server.h" |
| 11 #include "net/socket/tcp_server_socket.h" |
| 12 #include "sky/framework/inspector/server/inspector.mojom.h" |
| 13 |
| 14 namespace sky { |
| 15 namespace inspector { |
| 16 |
| 17 class InspectorFronendImpl : public mojo::InterfaceImpl<InspectorFrontend>, |
| 18 public net::HttpServer::Delegate { |
| 19 public: |
| 20 InspectorFronendImpl(); |
| 21 virtual ~InspectorFronendImpl(); |
| 22 |
| 23 private: |
| 24 // From net::HttpServer::Delegate |
| 25 virtual void OnConnect(int connection_id) 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 |
| 34 // From InspectorFronend |
| 35 virtual void Listen(int32_t port) override; |
| 36 virtual void SendMessage(const mojo::String&) override; |
| 37 |
| 38 void StopListening(); |
| 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 |
| 47 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFronendImpl); |
| 48 }; |
| 49 |
| 50 typedef mojo::InterfaceFactoryImpl< |
| 51 InspectorFronendImpl> InspectorFronendFactory; |
| 52 |
| 53 } // namespace tester |
| 54 } // namespace sky |
| 55 |
| 56 #endif // SKY_FRAMEWORK_INSPECTOR_SERVER_INSPECTOR_FRONTEND_IMPL_H_ |
OLD | NEW |