Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Side by Side Diff: services/http_server/http_server_factory_impl.h

Issue 2012873003: More ApplicationDelegate/ApplicationRunner[Chromium] conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_run_app_options
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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/interfaces/http_server_factory.mojom.h" 15 #include "mojo/services/http_server/interfaces/http_server_factory.mojom.h"
16 #include "mojo/services/network/interfaces/net_address.mojom.h" 16 #include "mojo/services/network/interfaces/net_address.mojom.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 class ApplicationImpl; 19 class Shell;
20 } // namespace mojo 20 } // namespace mojo
21 21
22 namespace http_server { 22 namespace http_server {
23 23
24 class HttpServerImpl; 24 class HttpServerImpl;
25 25
26 class HttpServerFactoryImpl : public HttpServerFactory { 26 class HttpServerFactoryImpl : public HttpServerFactory {
27 public: 27 public:
28 HttpServerFactoryImpl(mojo::ApplicationImpl* app); 28 // TODO(vtl): Possibly this should take an
29 // |InterfaceHandle<ApplicationConnector>| instead of a |Shell*|.
30 explicit HttpServerFactoryImpl(mojo::Shell* shell);
29 ~HttpServerFactoryImpl() override; 31 ~HttpServerFactoryImpl() override;
30 32
31 void AddBinding(mojo::InterfaceRequest<HttpServerFactory> request); 33 void AddBinding(mojo::InterfaceRequest<HttpServerFactory> request);
32 34
33 // The server impl calls back here when the last of its clients disconnects. 35 // The server impl calls back here when the last of its clients disconnects.
34 void DeleteServer(HttpServerImpl* server, 36 void DeleteServer(HttpServerImpl* server,
35 mojo::NetAddress* requested_address); 37 mojo::NetAddress* requested_address);
36 38
37 private: 39 private:
38 // Servers that were requested with non-zero port are stored in a map and we 40 // Servers that were requested with non-zero port are stored in a map and we
39 // allow multiple clients to connect to them. We use a pair of the IP address 41 // allow multiple clients to connect to them. We use a pair of the IP address
40 // and the port as a lookup key. 42 // and the port as a lookup key.
41 typedef std::pair<std::vector<uint8_t>, uint16_t> ServerKey; 43 typedef std::pair<std::vector<uint8_t>, uint16_t> ServerKey;
42 44
43 ServerKey GetServerKey(mojo::NetAddress* local_address); 45 ServerKey GetServerKey(mojo::NetAddress* local_address);
44 46
45 // HttpServerFactory: 47 // HttpServerFactory:
46 void CreateHttpServer(mojo::InterfaceRequest<HttpServer> server_request, 48 void CreateHttpServer(mojo::InterfaceRequest<HttpServer> server_request,
47 mojo::NetAddressPtr local_address) override; 49 mojo::NetAddressPtr local_address) override;
48 50
49 mojo::BindingSet<HttpServerFactory> bindings_; 51 mojo::BindingSet<HttpServerFactory> bindings_;
50 52
51 std::map<ServerKey, HttpServerImpl*> port_indicated_servers_; 53 std::map<ServerKey, HttpServerImpl*> port_indicated_servers_;
52 54
53 // Servers that were requested with port = 0 (pick any) are not available to 55 // Servers that were requested with port = 0 (pick any) are not available to
54 // other clients. 56 // other clients.
55 std::set<HttpServerImpl*> port_any_servers_; 57 std::set<HttpServerImpl*> port_any_servers_;
56 58
57 mojo::ApplicationImpl* app_; 59 mojo::Shell* const shell_;
58 }; 60 };
59 61
60 } // namespace http_server 62 } // namespace http_server
61 63
62 #endif // SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_ 64 #endif // SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_
OLDNEW
« no previous file with comments | « services/http_server/http_server_app.cc ('k') | services/http_server/http_server_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698