Chromium Code Reviews| 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> { |
|
Aaron Boodman
2014/11/11 16:12:50
I find that it makes implementation easier to put
| |
| 18 public net::HttpServer::Delegate { | |
| 19 public: | 18 public: |
| 20 InspectorFrontendImpl(); | 19 class Delegate { |
| 20 public: | |
| 21 virtual void Register(InspectorFrontendImpl*) = 0; | |
|
Aaron Boodman
2014/11/11 16:12:50
You can avoid the Register() function by just havi
| |
| 22 virtual void Unregister(InspectorFrontendImpl*) = 0; | |
| 23 virtual void SendMessage(const mojo::String&) = 0; | |
| 24 }; | |
| 25 | |
| 26 InspectorFrontendImpl(Delegate* delegate); | |
|
abarth-chromium
2014/11/11 02:53:57
explicit
| |
| 21 virtual ~InspectorFrontendImpl(); | 27 virtual ~InspectorFrontendImpl(); |
| 22 | 28 |
| 29 void OnShutdown(); | |
| 30 | |
| 23 private: | 31 private: |
| 24 // From net::HttpServer::Delegate | 32 // InspectorFrontend: |
| 25 virtual void OnConnect(int connection_id) override; | 33 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 | 34 |
| 34 // From InspectorFrontend | 35 // InterfaceImpl: |
| 35 virtual void Listen(int32_t port) override; | 36 void OnConnectionError() override; |
| 36 virtual void SendMessage(const mojo::String&) override; | |
| 37 | 37 |
| 38 void StopListening(); | 38 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 | 39 |
| 47 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFrontendImpl); | 40 MOJO_DISALLOW_COPY_AND_ASSIGN(InspectorFrontendImpl); |
| 48 }; | 41 }; |
| 49 | 42 |
| 50 typedef mojo::InterfaceFactoryImpl< | |
| 51 InspectorFrontendImpl> InspectorFrontendFactory; | |
| 52 | |
| 53 } // namespace tester | 43 } // namespace tester |
| 54 } // namespace sky | 44 } // namespace sky |
| 55 | 45 |
| 56 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ | 46 #endif // SKY_SERVICES_INSPECTOR_INSPECTOR_FRONTEND_IMPL_H_ |
| OLD | NEW |