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 REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ | 5 #ifndef REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ |
6 #define REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ | 6 #define REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ |
7 | 7 |
8 #include <array> | 8 #include <array> |
9 #include <list> | 9 #include <list> |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "remoting/protocol/ice_config.h" | 16 #include "remoting/protocol/ice_config.h" |
17 #include "remoting/protocol/network_settings.h" | 17 #include "remoting/protocol/network_settings.h" |
18 #include "remoting/protocol/transport.h" | 18 #include "remoting/protocol/transport.h" |
19 | 19 |
20 namespace remoting { | 20 namespace remoting { |
21 | 21 |
22 class SignalStrategy; | 22 class SignalStrategy; |
23 class UrlRequestFactory; | 23 class UrlRequestFactory; |
24 | 24 |
25 namespace protocol { | 25 namespace protocol { |
(...skipping 13 matching lines...) Expand all Loading... |
39 LAST_RELAYMODE = TURN | 39 LAST_RELAYMODE = TURN |
40 }; | 40 }; |
41 static const int kNumRelayModes = RelayMode::LAST_RELAYMODE + 1; | 41 static const int kNumRelayModes = RelayMode::LAST_RELAYMODE + 1; |
42 | 42 |
43 typedef base::Callback<void(const IceConfig& ice_config)> | 43 typedef base::Callback<void(const IceConfig& ice_config)> |
44 GetIceConfigCallback; | 44 GetIceConfigCallback; |
45 | 45 |
46 static scoped_refptr<TransportContext> ForTests(TransportRole role); | 46 static scoped_refptr<TransportContext> ForTests(TransportRole role); |
47 | 47 |
48 TransportContext(SignalStrategy* signal_strategy, | 48 TransportContext(SignalStrategy* signal_strategy, |
49 scoped_ptr<PortAllocatorFactory> port_allocator_factory, | 49 std::unique_ptr<PortAllocatorFactory> port_allocator_factory, |
50 scoped_ptr<UrlRequestFactory> url_request_factory, | 50 std::unique_ptr<UrlRequestFactory> url_request_factory, |
51 const NetworkSettings& network_settings, | 51 const NetworkSettings& network_settings, |
52 TransportRole role); | 52 TransportRole role); |
53 | 53 |
54 void set_ice_config_url(const std::string& ice_config_url) { | 54 void set_ice_config_url(const std::string& ice_config_url) { |
55 ice_config_url_ = ice_config_url; | 55 ice_config_url_ = ice_config_url; |
56 } | 56 } |
57 | 57 |
58 // Sets relay mode for all future calls of GetIceConfig(). Doesn't affect | 58 // Sets relay mode for all future calls of GetIceConfig(). Doesn't affect |
59 // previous GetIceConfig() requests. | 59 // previous GetIceConfig() requests. |
60 void set_relay_mode(RelayMode relay_mode) { relay_mode_ = relay_mode; } | 60 void set_relay_mode(RelayMode relay_mode) { relay_mode_ = relay_mode; } |
(...skipping 17 matching lines...) Expand all Loading... |
78 | 78 |
79 private: | 79 private: |
80 friend class base::RefCountedThreadSafe<TransportContext>; | 80 friend class base::RefCountedThreadSafe<TransportContext>; |
81 | 81 |
82 ~TransportContext(); | 82 ~TransportContext(); |
83 | 83 |
84 void EnsureFreshIceConfig(); | 84 void EnsureFreshIceConfig(); |
85 void OnIceConfig(RelayMode relay_mode, const IceConfig& ice_config); | 85 void OnIceConfig(RelayMode relay_mode, const IceConfig& ice_config); |
86 | 86 |
87 SignalStrategy* signal_strategy_; | 87 SignalStrategy* signal_strategy_; |
88 scoped_ptr<PortAllocatorFactory> port_allocator_factory_; | 88 std::unique_ptr<PortAllocatorFactory> port_allocator_factory_; |
89 scoped_ptr<UrlRequestFactory> url_request_factory_; | 89 std::unique_ptr<UrlRequestFactory> url_request_factory_; |
90 NetworkSettings network_settings_; | 90 NetworkSettings network_settings_; |
91 TransportRole role_; | 91 TransportRole role_; |
92 | 92 |
93 std::string ice_config_url_; | 93 std::string ice_config_url_; |
94 RelayMode relay_mode_ = RelayMode::GTURN; | 94 RelayMode relay_mode_ = RelayMode::GTURN; |
95 | 95 |
96 std::array<scoped_ptr<IceConfigRequest>, kNumRelayModes> ice_config_request_; | 96 std::array<std::unique_ptr<IceConfigRequest>, kNumRelayModes> |
| 97 ice_config_request_; |
97 std::array<IceConfig, kNumRelayModes> ice_config_; | 98 std::array<IceConfig, kNumRelayModes> ice_config_; |
98 | 99 |
99 // When there is an active |ice_config_request_| stores list of callbacks to | 100 // When there is an active |ice_config_request_| stores list of callbacks to |
100 // be called once the request is finished. | 101 // be called once the request is finished. |
101 std::array<std::list<GetIceConfigCallback>, kNumRelayModes> | 102 std::array<std::list<GetIceConfigCallback>, kNumRelayModes> |
102 pending_ice_config_callbacks_; | 103 pending_ice_config_callbacks_; |
103 | 104 |
104 DISALLOW_COPY_AND_ASSIGN(TransportContext); | 105 DISALLOW_COPY_AND_ASSIGN(TransportContext); |
105 }; | 106 }; |
106 | 107 |
107 } // namespace protocol | 108 } // namespace protocol |
108 } // namespace remoting | 109 } // namespace remoting |
109 | 110 |
110 #endif // REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ | 111 #endif // REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ |
OLD | NEW |