OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BLIMP_NET_ENGINE_CONNECTION_MANAGER_H_ | |
6 #define BLIMP_NET_ENGINE_CONNECTION_MANAGER_H_ | |
7 | |
8 #include <memory> | |
9 #include <vector> | |
10 | |
11 #include "base/gtest_prod_util.h" | |
12 #include "base/macros.h" | |
13 #include "blimp/net/blimp_net_export.h" | |
14 #include "blimp/net/connection_handler.h" | |
15 #include "net/base/ip_endpoint.h" | |
16 #include "net/log/net_log.h" | |
17 | |
18 namespace blimp { | |
19 | |
20 class BlimpEngineTransport; | |
21 | |
22 // Coordinates the channel creation and authentication workflows for | |
23 // incoming (Engine) network connections. | |
24 // | |
25 // TODO(kmarshall): Add rate limiting and abuse handling logic. | |
26 class BLIMP_NET_EXPORT EngineConnectionManager { | |
27 public: | |
28 enum class EngineTransportType { TCP, GRPC }; | |
29 | |
30 // Caller is responsible for ensuring that |connection_handler| outlives | |
31 // |this|. | |
32 explicit EngineConnectionManager(ConnectionHandler* connection_handler, | |
33 net::NetLog* net_log); | |
34 | |
35 ~EngineConnectionManager(); | |
36 | |
37 // Adds a transport and accepts new BlimpConnections from it as fast as they | |
38 // arrive. The |ip_endpoint| will receive the actual port-number if the | |
39 // provided one is not available for listening. | |
40 void ConnectTransport(net::IPEndPoint* ip_endpoint, | |
41 EngineTransportType transport_type); | |
42 | |
43 private: | |
44 // Invokes transport_->Connect to listen for a connection. | |
45 void Connect(); | |
46 | |
47 // Callback invoked by |transport_| to indicate that it has a connection | |
48 // ready to be authenticated. | |
49 void OnConnectResult(int result); | |
50 | |
51 ConnectionHandler* connection_handler_; | |
52 net::NetLog* net_log_; | |
53 std::unique_ptr<BlimpEngineTransport> transport_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(EngineConnectionManager); | |
56 }; | |
57 | |
58 } // namespace blimp | |
59 | |
60 #endif // BLIMP_NET_ENGINE_CONNECTION_MANAGER_H_ | |
OLD | NEW |