OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The purpose of SessionManager is to facilitate creation of chromotocol | 5 // The purpose of SessionManager is to facilitate creation of chromotocol |
6 // sessions. Both host and client use it to establish chromotocol | 6 // sessions. Both host and client use it to establish chromotocol |
7 // sessions. JingleChromotocolServer implements this inteface using | 7 // sessions. JingleChromotocolServer implements this inteface using |
8 // libjingle. | 8 // libjingle. |
9 // | 9 // |
10 // OUTGOING SESSIONS | 10 // OUTGOING SESSIONS |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 namespace remoting { | 64 namespace remoting { |
65 | 65 |
66 class SignalStrategy; | 66 class SignalStrategy; |
67 | 67 |
68 namespace protocol { | 68 namespace protocol { |
69 | 69 |
70 class Authenticator; | 70 class Authenticator; |
71 class AuthenticatorFactory; | 71 class AuthenticatorFactory; |
72 | 72 |
73 // TODO(sergeyu): Remove this struct and use TransportConfig instead. | |
74 struct NetworkSettings { | |
75 NetworkSettings() | |
76 : nat_traversal_mode(TransportConfig::NAT_TRAVERSAL_DISABLED), | |
77 min_port(0), | |
78 max_port(0) { | |
79 } | |
80 | |
81 explicit NetworkSettings(bool allow_nat_traversal) | |
82 : nat_traversal_mode(allow_nat_traversal ? | |
83 TransportConfig::NAT_TRAVERSAL_ENABLED : | |
84 TransportConfig::NAT_TRAVERSAL_DISABLED), | |
85 min_port(0), | |
86 max_port(0) { | |
87 } | |
88 | |
89 explicit NetworkSettings(TransportConfig::NatTraversalMode nat_traversal_mode) | |
90 : nat_traversal_mode(nat_traversal_mode), | |
91 min_port(0), | |
92 max_port(0) { | |
93 } | |
94 | |
95 TransportConfig::NatTraversalMode nat_traversal_mode; | |
96 | |
97 // |min_port| and |max_port| specify range (inclusive) of ports used by | |
98 // P2P sessions. Any port can be used when both values are set to 0. | |
99 int min_port; | |
100 int max_port; | |
101 }; | |
102 | |
103 // Generic interface for Chromoting session manager. | 73 // Generic interface for Chromoting session manager. |
104 // | 74 // |
105 // TODO(sergeyu): Split this into two separate interfaces: one for the | 75 // TODO(sergeyu): Split this into two separate interfaces: one for the |
106 // client side and one for the host side. | 76 // client side and one for the host side. |
107 class SessionManager : public base::NonThreadSafe { | 77 class SessionManager : public base::NonThreadSafe { |
108 public: | 78 public: |
109 SessionManager() { } | 79 SessionManager() { } |
110 virtual ~SessionManager() { } | 80 virtual ~SessionManager() { } |
111 | 81 |
112 enum IncomingSessionResponse { | 82 enum IncomingSessionResponse { |
(...skipping 30 matching lines...) Expand all Loading... |
143 // callback accepts the |session| then it must also set | 113 // callback accepts the |session| then it must also set |
144 // configuration for the |session| using Session::set_config(). | 114 // configuration for the |session| using Session::set_config(). |
145 // The callback must take ownership of the |session| if it ACCEPTs it. | 115 // The callback must take ownership of the |session| if it ACCEPTs it. |
146 virtual void OnIncomingSession(Session* session, | 116 virtual void OnIncomingSession(Session* session, |
147 IncomingSessionResponse* response) = 0; | 117 IncomingSessionResponse* response) = 0; |
148 }; | 118 }; |
149 | 119 |
150 // Initializes the session client. Caller retains ownership of the | 120 // Initializes the session client. Caller retains ownership of the |
151 // |signal_strategy| and |listener|. | 121 // |signal_strategy| and |listener|. |
152 virtual void Init(SignalStrategy* signal_strategy, | 122 virtual void Init(SignalStrategy* signal_strategy, |
153 Listener* listener, | 123 Listener* listener) = 0; |
154 const NetworkSettings& network_settings) = 0; | |
155 | 124 |
156 // Tries to create a session to the host |jid|. Must be called only | 125 // Tries to create a session to the host |jid|. Must be called only |
157 // after initialization has finished successfully, i.e. after | 126 // after initialization has finished successfully, i.e. after |
158 // Listener::OnInitialized() has been called. | 127 // Listener::OnInitialized() has been called. |
159 // | 128 // |
160 // |host_jid| is the full jid of the host to connect to. | 129 // |host_jid| is the full jid of the host to connect to. |
161 // |authenticator| is a client authenticator for the session. | 130 // |authenticator| is a client authenticator for the session. |
162 // |config| contains the session configurations that the client supports. | 131 // |config| contains the session configurations that the client supports. |
163 // |state_change_callback| is called when the connection state changes. | 132 // |state_change_callback| is called when the connection state changes. |
164 virtual scoped_ptr<Session> Connect( | 133 virtual scoped_ptr<Session> Connect( |
(...skipping 16 matching lines...) Expand all Loading... |
181 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; | 150 scoped_ptr<AuthenticatorFactory> authenticator_factory) = 0; |
182 | 151 |
183 private: | 152 private: |
184 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 153 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
185 }; | 154 }; |
186 | 155 |
187 } // namespace protocol | 156 } // namespace protocol |
188 } // namespace remoting | 157 } // namespace remoting |
189 | 158 |
190 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ | 159 #endif // REMOTING_PROTOCOL_SESSION_MANAGER_H_ |
OLD | NEW |