OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 // After we have done all the initialization we'll start the ScreenRecorder. | 55 // After we have done all the initialization we'll start the ScreenRecorder. |
56 // We'll then enter the running state of the host process. | 56 // We'll then enter the running state of the host process. |
57 // | 57 // |
58 // 3. When the user is disconnected, we will pause the ScreenRecorder | 58 // 3. When the user is disconnected, we will pause the ScreenRecorder |
59 // and try to terminate the threads we have created. This will allow | 59 // and try to terminate the threads we have created. This will allow |
60 // all pending tasks to complete. After all of that completed we | 60 // all pending tasks to complete. After all of that completed we |
61 // return to the idle state. We then go to step (2) if there a new | 61 // return to the idle state. We then go to step (2) if there a new |
62 // incoming connection. | 62 // incoming connection. |
63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, | 63 class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, |
64 public ClientSession::EventHandler, | 64 public ClientSession::EventHandler, |
65 public SignalStrategy::Listener, | |
66 public protocol::SessionManager::Listener { | 65 public protocol::SessionManager::Listener { |
67 public: | 66 public: |
68 // Factory methods that must be used to create ChromotingHost | 67 // Caller keeps ownership of |context|, |signal_strategy| and |
69 // instances. It does NOT take ownership of |context|, and | |
70 // |environment|, but they should not be deleted until returned host | 68 // |environment|, but they should not be deleted until returned host |
71 // is destroyed. | 69 // is destroyed. |
Wez
2012/01/03 16:25:04
nit: Reword, e.g. "Creates a ChromotingHost instan
Sergey Ulanov
2012/01/03 21:51:02
Done. This is a constructor, so I don't think that
| |
72 static ChromotingHost* Create(ChromotingHostContext* context, | 70 ChromotingHost(ChromotingHostContext* context, |
73 MutableHostConfig* config, | 71 MutableHostConfig* config, |
74 DesktopEnvironment* environment, | 72 SignalStrategy* signal_strategy, |
75 bool allow_nat_traversal); | 73 DesktopEnvironment* environment, |
74 bool allow_nat_traversal); | |
76 | 75 |
77 // Asynchronously start the host process. | 76 // Asynchronously start the host process. |
78 // | 77 // |
79 // After this is invoked, the host process will connect to the talk | 78 // After this is invoked, the host process will connect to the talk |
80 // network and start listening for incoming connections. | 79 // network and start listening for incoming connections. |
81 // | 80 // |
82 // This method can only be called once during the lifetime of this object. | 81 // This method can only be called once during the lifetime of this object. |
83 void Start(); | 82 void Start(); |
84 | 83 |
85 // Asynchronously shutdown the host process. |shutdown_task| is | 84 // Asynchronously shutdown the host process. |shutdown_task| is |
86 // called after shutdown is completed. | 85 // called after shutdown is completed. |
87 void Shutdown(const base::Closure& shutdown_task); | 86 void Shutdown(const base::Closure& shutdown_task); |
88 | 87 |
89 // Adds |observer| to the list of status observers. Doesn't take | 88 // Adds |observer| to the list of status observers. Doesn't take |
90 // ownership of |observer|, so |observer| must outlive this | 89 // ownership of |observer|, so |observer| must outlive this |
91 // object. All status observers must be added before the host is | 90 // object. All status observers must be added before the host is |
92 // started. | 91 // started. |
93 void AddStatusObserver(HostStatusObserver* observer); | 92 void AddStatusObserver(HostStatusObserver* observer); |
94 | 93 |
95 // Sets shared secret for the host. All incoming connections are | 94 // Sets shared secret for the host. All incoming connections are |
96 // rejected if shared secret isn't set. Must be called on the | 95 // rejected if shared secret isn't set. Must be called on the |
97 // network thread after the host is started. | 96 // network thread after the host is started. |
98 void SetSharedSecret(const std::string& shared_secret); | 97 void SetSharedSecret(const std::string& shared_secret); |
99 | 98 |
100 //////////////////////////////////////////////////////////////////////////// | 99 //////////////////////////////////////////////////////////////////////////// |
101 // SignalStrategy::Listener interface. | |
102 virtual void OnSignalStrategyStateChange( | |
103 SignalStrategy::State state) OVERRIDE; | |
104 | |
105 //////////////////////////////////////////////////////////////////////////// | |
106 // ClientSession::EventHandler implementation. | 100 // ClientSession::EventHandler implementation. |
107 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; | 101 virtual void OnSessionAuthenticated(ClientSession* client) OVERRIDE; |
108 virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE; | 102 virtual void OnSessionAuthenticationFailed(ClientSession* client) OVERRIDE; |
109 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; | 103 virtual void OnSessionClosed(ClientSession* session) OVERRIDE; |
110 virtual void OnSessionSequenceNumber(ClientSession* session, | 104 virtual void OnSessionSequenceNumber(ClientSession* session, |
111 int64 sequence_number) OVERRIDE; | 105 int64 sequence_number) OVERRIDE; |
112 | 106 |
113 // SessionManager::Listener implementation. | 107 // SessionManager::Listener implementation. |
114 virtual void OnSessionManagerReady() OVERRIDE; | 108 virtual void OnSessionManagerReady() OVERRIDE; |
115 virtual void OnIncomingSession( | 109 virtual void OnIncomingSession( |
(...skipping 29 matching lines...) Expand all Loading... | |
145 typedef std::vector<HostStatusObserver*> StatusObserverList; | 139 typedef std::vector<HostStatusObserver*> StatusObserverList; |
146 typedef std::vector<ClientSession*> ClientList; | 140 typedef std::vector<ClientSession*> ClientList; |
147 | 141 |
148 enum State { | 142 enum State { |
149 kInitial, | 143 kInitial, |
150 kStarted, | 144 kStarted, |
151 kStopping, | 145 kStopping, |
152 kStopped, | 146 kStopped, |
153 }; | 147 }; |
154 | 148 |
155 // Caller keeps ownership of |context| and |environment|. | |
156 ChromotingHost(ChromotingHostContext* context, | |
157 MutableHostConfig* config, | |
158 DesktopEnvironment* environment, | |
159 bool allow_nat_traversal); | |
160 virtual ~ChromotingHost(); | 149 virtual ~ChromotingHost(); |
161 | 150 |
162 // Creates encoder for the specified configuration. | 151 // Creates encoder for the specified configuration. |
163 Encoder* CreateEncoder(const protocol::SessionConfig& config); | 152 Encoder* CreateEncoder(const protocol::SessionConfig& config); |
164 | 153 |
165 std::string GenerateHostAuthToken(const std::string& encoded_client_token); | 154 std::string GenerateHostAuthToken(const std::string& encoded_client_token); |
166 | 155 |
167 void AddAuthenticatedClient(ClientSession* client, | 156 void AddAuthenticatedClient(ClientSession* client, |
168 const protocol::SessionConfig& config, | 157 const protocol::SessionConfig& config, |
169 const std::string& jid); | 158 const std::string& jid); |
(...skipping 19 matching lines...) Expand all Loading... | |
189 // TODO(lambroslambrou): The following is a temporary fix for Me2Me | 178 // TODO(lambroslambrou): The following is a temporary fix for Me2Me |
190 // (crbug.com/105995), pending the AuthenticatorFactory work. | 179 // (crbug.com/105995), pending the AuthenticatorFactory work. |
191 // Cache the shared secret, in case SetSharedSecret() is called before the | 180 // Cache the shared secret, in case SetSharedSecret() is called before the |
192 // session manager has been created. | 181 // session manager has been created. |
193 // The |have_shared_secret_| flag is to distinguish SetSharedSecret() not | 182 // The |have_shared_secret_| flag is to distinguish SetSharedSecret() not |
194 // being called at all, from being called with an empty string. | 183 // being called at all, from being called with an empty string. |
195 std::string shared_secret_; | 184 std::string shared_secret_; |
196 bool have_shared_secret_; | 185 bool have_shared_secret_; |
197 | 186 |
198 // Connection objects. | 187 // Connection objects. |
199 scoped_ptr<SignalStrategy> signal_strategy_; | 188 SignalStrategy* signal_strategy_; |
200 std::string local_jid_; | |
201 scoped_ptr<protocol::SessionManager> session_manager_; | 189 scoped_ptr<protocol::SessionManager> session_manager_; |
202 | 190 |
203 // StatusObserverList is thread-safe and can be used on any thread. | 191 // StatusObserverList is thread-safe and can be used on any thread. |
204 StatusObserverList status_observers_; | 192 StatusObserverList status_observers_; |
205 | 193 |
206 // The connections to remote clients. | 194 // The connections to remote clients. |
207 ClientList clients_; | 195 ClientList clients_; |
208 | 196 |
209 // Session manager for the host process. | 197 // Session manager for the host process. |
210 scoped_refptr<ScreenRecorder> recorder_; | 198 scoped_refptr<ScreenRecorder> recorder_; |
(...skipping 19 matching lines...) Expand all Loading... | |
230 bool is_it2me_; | 218 bool is_it2me_; |
231 std::string access_code_; | 219 std::string access_code_; |
232 UiStrings ui_strings_; | 220 UiStrings ui_strings_; |
233 | 221 |
234 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); | 222 DISALLOW_COPY_AND_ASSIGN(ChromotingHost); |
235 }; | 223 }; |
236 | 224 |
237 } // namespace remoting | 225 } // namespace remoting |
238 | 226 |
239 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ | 227 #endif // REMOTING_HOST_CHROMOTING_HOST_H_ |
OLD | NEW |