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 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ | 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_H_ |
6 #define REMOTING_HOST_CHROMOTING_HOST_H_ | 6 #define REMOTING_HOST_CHROMOTING_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 class SessionConfig; | 32 class SessionConfig; |
33 class CandidateSessionConfig; | 33 class CandidateSessionConfig; |
34 } // namespace protocol | 34 } // namespace protocol |
35 | 35 |
36 class Capturer; | 36 class Capturer; |
37 class ChromotingHostContext; | 37 class ChromotingHostContext; |
38 class DesktopEnvironment; | 38 class DesktopEnvironment; |
39 class Encoder; | 39 class Encoder; |
40 class ScreenRecorder; | 40 class ScreenRecorder; |
41 | 41 |
| 42 struct NetworkSettings { |
| 43 enum NatTraversalMode { |
| 44 // Don't use STUN or relay servers. Accept incoming P2P connection |
| 45 // attempts, but don't initiate any. This ensures that the peer is |
| 46 // on the same network. Note that connection will always fail if |
| 47 // both ends use this mode. |
| 48 NAT_TRAVERSAL_DISABLED, |
| 49 |
| 50 // Don't use STUN or relay servers but make outgoing connections. |
| 51 NAT_TRAVERSAL_OUTGOING, |
| 52 |
| 53 // Active NAT traversal using STUN and relay servers. |
| 54 NAT_TRAVERSAL_ENABLED, |
| 55 }; |
| 56 |
| 57 NetworkSettings() |
| 58 : nat_traversal_mode(NAT_TRAVERSAL_DISABLED), |
| 59 min_port(0), |
| 60 max_port(0) { |
| 61 } |
| 62 |
| 63 explicit NetworkSettings(bool allow_nat_traversal) |
| 64 : nat_traversal_mode(allow_nat_traversal ? |
| 65 NAT_TRAVERSAL_ENABLED : |
| 66 NAT_TRAVERSAL_DISABLED), |
| 67 min_port(0), |
| 68 max_port(0) { |
| 69 } |
| 70 |
| 71 explicit NetworkSettings(NatTraversalMode nat_traversal_mode) |
| 72 : nat_traversal_mode(nat_traversal_mode), |
| 73 min_port(0), |
| 74 max_port(0) { |
| 75 } |
| 76 |
| 77 NatTraversalMode nat_traversal_mode; |
| 78 |
| 79 // |min_port| and |max_port| specify range (inclusive) of ports used by |
| 80 // P2P sessions. Any port can be used when both values are set to 0. |
| 81 int min_port; |
| 82 int max_port; |
| 83 }; |
| 84 |
42 // A class to implement the functionality of a host process. | 85 // A class to implement the functionality of a host process. |
43 // | 86 // |
44 // Here's the work flow of this class: | 87 // Here's the work flow of this class: |
45 // 1. We should load the saved GAIA ID token or if this is the first | 88 // 1. We should load the saved GAIA ID token or if this is the first |
46 // time the host process runs we should prompt user for the | 89 // time the host process runs we should prompt user for the |
47 // credential. We will use this token or credentials to authenicate | 90 // credential. We will use this token or credentials to authenicate |
48 // and register the host. | 91 // and register the host. |
49 // | 92 // |
50 // 2. We listen for incoming connection using libjingle. We will create | 93 // 2. We listen for incoming connection using libjingle. We will create |
51 // a ConnectionToClient object that wraps around linjingle for transport. | 94 // a ConnectionToClient object that wraps around linjingle for transport. |
(...skipping 12 matching lines...) Expand all Loading... |
64 // incoming connection. | 107 // incoming connection. |
65 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 108 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
66 public ClientSession::EventHandler, | 109 public ClientSession::EventHandler, |
67 public protocol::SessionManager::Listener { | 110 public protocol::SessionManager::Listener { |
68 public: | 111 public: |
69 // The caller must ensure that |context|, |signal_strategy| and | 112 // The caller must ensure that |context|, |signal_strategy| and |
70 // |environment| out-live the host. | 113 // |environment| out-live the host. |
71 ChromotingHost(ChromotingHostContext* context, | 114 ChromotingHost(ChromotingHostContext* context, |
72 SignalStrategy* signal_strategy, | 115 SignalStrategy* signal_strategy, |
73 DesktopEnvironment* environment, | 116 DesktopEnvironment* environment, |
74 const protocol::NetworkSettings& network_settings); | 117 const NetworkSettings& network_settings); |
75 | 118 |
76 // Asynchronously start the host process. | 119 // Asynchronously start the host process. |
77 // | 120 // |
78 // After this is invoked, the host process will connect to the talk | 121 // After this is invoked, the host process will connect to the talk |
79 // network and start listening for incoming connections. | 122 // network and start listening for incoming connections. |
80 // | 123 // |
81 // This method can only be called once during the lifetime of this object. | 124 // This method can only be called once during the lifetime of this object. |
82 void Start(); | 125 void Start(); |
83 | 126 |
84 // Asynchronously shutdown the host process. |shutdown_task| is | 127 // Asynchronously shutdown the host process. |shutdown_task| is |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 212 |
170 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. | 213 // Called from Shutdown() or OnScreenRecorderStopped() to finish shutdown. |
171 void ShutdownFinish(); | 214 void ShutdownFinish(); |
172 | 215 |
173 // Unless specified otherwise all members of this class must be | 216 // Unless specified otherwise all members of this class must be |
174 // used on the network thread only. | 217 // used on the network thread only. |
175 | 218 |
176 // Parameters specified when the host was created. | 219 // Parameters specified when the host was created. |
177 ChromotingHostContext* context_; | 220 ChromotingHostContext* context_; |
178 DesktopEnvironment* desktop_environment_; | 221 DesktopEnvironment* desktop_environment_; |
179 protocol::NetworkSettings network_settings_; | 222 NetworkSettings network_settings_; |
180 | 223 |
181 // Connection objects. | 224 // Connection objects. |
182 SignalStrategy* signal_strategy_; | 225 SignalStrategy* signal_strategy_; |
183 scoped_ptr<protocol::SessionManager> session_manager_; | 226 scoped_ptr<protocol::SessionManager> session_manager_; |
184 | 227 |
185 // Must be used on the network thread only. | 228 // Must be used on the network thread only. |
186 ObserverList<HostStatusObserver> status_observers_; | 229 ObserverList<HostStatusObserver> status_observers_; |
187 | 230 |
188 // The connections to remote clients. | 231 // The connections to remote clients. |
189 ClientList clients_; | 232 ClientList clients_; |
(...skipping 28 matching lines...) Expand all Loading... |
218 // TODO(sergeyu): The following members do not belong to | 261 // TODO(sergeyu): The following members do not belong to |
219 // ChromotingHost and should be moved elsewhere. | 262 // ChromotingHost and should be moved elsewhere. |
220 UiStrings ui_strings_; | 263 UiStrings ui_strings_; |
221 | 264 |
222 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 265 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
223 }; | 266 }; |
224 | 267 |
225 } // namespace remoting | 268 } // namespace remoting |
226 | 269 |
227 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 270 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |