| 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 #ifndef SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ | 5 #ifndef SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ |
| 6 #define SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ | 6 #define SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "mojo/common/weak_binding_set.h" | 13 #include "mojo/common/binding_set.h" |
| 14 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 #include "mojo/services/http_server/public/interfaces/http_server_factory.mojom.
h" | 15 #include "mojo/services/http_server/public/interfaces/http_server_factory.mojom.
h" |
| 16 #include "mojo/services/network/public/interfaces/net_address.mojom.h" | 16 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
| 17 | 17 |
| 18 namespace mojo { | 18 namespace mojo { |
| 19 class ApplicationImpl; | 19 class ApplicationImpl; |
| 20 } // namespace mojo | 20 } // namespace mojo |
| 21 | 21 |
| 22 namespace http_server { | 22 namespace http_server { |
| 23 | 23 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 // allow multiple clients to connect to them. We use a pair of the IP address | 39 // allow multiple clients to connect to them. We use a pair of the IP address |
| 40 // and the port as a lookup key. | 40 // and the port as a lookup key. |
| 41 typedef std::pair<std::vector<uint8_t>, uint16_t> ServerKey; | 41 typedef std::pair<std::vector<uint8_t>, uint16_t> ServerKey; |
| 42 | 42 |
| 43 ServerKey GetServerKey(mojo::NetAddress* local_address); | 43 ServerKey GetServerKey(mojo::NetAddress* local_address); |
| 44 | 44 |
| 45 // HttpServerFactory: | 45 // HttpServerFactory: |
| 46 void CreateHttpServer(mojo::InterfaceRequest<HttpServer> server_request, | 46 void CreateHttpServer(mojo::InterfaceRequest<HttpServer> server_request, |
| 47 mojo::NetAddressPtr local_address) override; | 47 mojo::NetAddressPtr local_address) override; |
| 48 | 48 |
| 49 mojo::WeakBindingSet<HttpServerFactory> bindings_; | 49 mojo::BindingSet<HttpServerFactory> bindings_; |
| 50 | 50 |
| 51 std::map<ServerKey, HttpServerImpl*> port_indicated_servers_; | 51 std::map<ServerKey, HttpServerImpl*> port_indicated_servers_; |
| 52 | 52 |
| 53 // Servers that were requested with port = 0 (pick any) are not available to | 53 // Servers that were requested with port = 0 (pick any) are not available to |
| 54 // other clients. | 54 // other clients. |
| 55 std::set<HttpServerImpl*> port_any_servers_; | 55 std::set<HttpServerImpl*> port_any_servers_; |
| 56 | 56 |
| 57 mojo::ApplicationImpl* app_; | 57 mojo::ApplicationImpl* app_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace http_server | 60 } // namespace http_server |
| 61 | 61 |
| 62 #endif // SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ | 62 #endif // SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ |
| OLD | NEW |