OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "mojo/common/weak_binding_set.h" | 8 #include "mojo/common/weak_binding_set.h" |
9 #include "mojo/public/cpp/bindings/interface_request.h" | 9 #include "mojo/public/cpp/bindings/interface_request.h" |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 11 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
11 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 12 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
12 #include "services/http_server/public/http_request.mojom.h" | 13 #include "services/http_server/public/http_request.mojom.h" |
13 #include "services/http_server/public/http_response.mojom.h" | 14 #include "services/http_server/public/http_response.mojom.h" |
14 #include "services/http_server/public/http_server.mojom.h" | 15 #include "services/http_server/public/http_server.mojom.h" |
15 #include "third_party/re2/re2/re2.h" | 16 #include "third_party/re2/re2/re2.h" |
16 | 17 |
17 namespace mojo { | 18 namespace mojo { |
18 class ApplicationImpl; | 19 class ApplicationImpl; |
19 } // namespace mojo | 20 } // namespace mojo |
20 | 21 |
21 namespace http_server { | 22 namespace http_server { |
22 | 23 |
23 class Connection; | 24 class Connection; |
24 class HttpServerFactoryImpl; | 25 class HttpServerFactoryImpl; |
25 | 26 |
26 class HttpServerImpl : public HttpServer, public mojo::ErrorHandler { | 27 class HttpServerImpl : public HttpServer, public mojo::ErrorHandler { |
27 public: | 28 public: |
28 HttpServerImpl(mojo::ApplicationImpl* app, | 29 HttpServerImpl(mojo::ApplicationImpl* app, |
29 HttpServerFactoryImpl* factory, | 30 HttpServerFactoryImpl* factory, |
30 uint16_t port); | 31 mojo::NetAddressPtr requested_local_address); |
31 ~HttpServerImpl() override; | 32 ~HttpServerImpl() override; |
32 | 33 |
33 void AddBinding(mojo::InterfaceRequest<HttpServer> request); | 34 void AddBinding(mojo::InterfaceRequest<HttpServer> request); |
34 | 35 |
35 // HttpServer: | 36 // HttpServer: |
36 void SetHandler(const mojo::String& path, | 37 void SetHandler(const mojo::String& path, |
37 HttpHandlerPtr http_handler, | 38 HttpHandlerPtr http_handler, |
38 const mojo::Callback<void(bool)>& callback) override; | 39 const mojo::Callback<void(bool)>& callback) override; |
39 | 40 |
40 void GetPort(const GetPortCallback& callback) override; | 41 void GetPort(const GetPortCallback& callback) override; |
(...skipping 23 matching lines...) Expand all Loading... |
64 ~Handler(); | 65 ~Handler(); |
65 scoped_ptr<re2::RE2> pattern; | 66 scoped_ptr<re2::RE2> pattern; |
66 HttpHandlerPtr http_handler; | 67 HttpHandlerPtr http_handler; |
67 | 68 |
68 private: | 69 private: |
69 DISALLOW_COPY_AND_ASSIGN(Handler); | 70 DISALLOW_COPY_AND_ASSIGN(Handler); |
70 }; | 71 }; |
71 | 72 |
72 HttpServerFactoryImpl* factory_; | 73 HttpServerFactoryImpl* factory_; |
73 | 74 |
74 uint16_t requested_port_; | 75 mojo::NetAddressPtr requested_local_address_; |
75 uint16_t assigned_port_; | 76 uint16_t assigned_port_; |
76 std::vector<GetPortCallback> pending_get_port_callbacks_; | 77 std::vector<GetPortCallback> pending_get_port_callbacks_; |
77 | 78 |
78 mojo::WeakBindingSet<HttpServer> bindings_; | 79 mojo::WeakBindingSet<HttpServer> bindings_; |
79 | 80 |
80 mojo::NetworkServicePtr network_service_; | 81 mojo::NetworkServicePtr network_service_; |
81 mojo::TCPBoundSocketPtr bound_socket_; | 82 mojo::TCPBoundSocketPtr bound_socket_; |
82 mojo::TCPServerSocketPtr server_socket_; | 83 mojo::TCPServerSocketPtr server_socket_; |
83 | 84 |
84 mojo::ScopedDataPipeProducerHandle pending_send_handle_; | 85 mojo::ScopedDataPipeProducerHandle pending_send_handle_; |
85 mojo::ScopedDataPipeConsumerHandle pending_receive_handle_; | 86 mojo::ScopedDataPipeConsumerHandle pending_receive_handle_; |
86 mojo::TCPConnectedSocketPtr pending_connected_socket_; | 87 mojo::TCPConnectedSocketPtr pending_connected_socket_; |
87 | 88 |
88 ScopedVector<Handler> handlers_; | 89 ScopedVector<Handler> handlers_; |
89 | 90 |
90 base::WeakPtrFactory<HttpServerImpl> weak_ptr_factory_; | 91 base::WeakPtrFactory<HttpServerImpl> weak_ptr_factory_; |
91 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl); | 92 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl); |
92 }; | 93 }; |
93 | 94 |
94 } // namespace http_server | 95 } // namespace http_server |
OLD | NEW |