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 // This is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
8 // | 8 // |
9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return 1; | 146 return 1; |
147 } | 147 } |
148 if (!config.GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) { | 148 if (!config.GetString(kXmppAuthServiceConfigPath, &xmpp_auth_service_)) { |
149 // For the simple host, we assume we always use the ClientLogin token for | 149 // For the simple host, we assume we always use the ClientLogin token for |
150 // chromiumsync because we do not have an HTTP stack with which we can | 150 // chromiumsync because we do not have an HTTP stack with which we can |
151 // easily request an OAuth2 access token even if we had a RefreshToken for | 151 // easily request an OAuth2 access token even if we had a RefreshToken for |
152 // the account. | 152 // the account. |
153 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; | 153 xmpp_auth_service_ = kChromotingTokenDefaultServiceName; |
154 } | 154 } |
155 | 155 |
156 context_.network_message_loop()->PostTask(FROM_HERE, base::Bind( | 156 context_.network_task_runner()->PostTask(FROM_HERE, base::Bind( |
157 &SimpleHost::StartHost, base::Unretained(this))); | 157 &SimpleHost::StartHost, base::Unretained(this))); |
158 | 158 |
159 message_loop_.MessageLoop::Run(); | 159 message_loop_.MessageLoop::Run(); |
160 | 160 |
161 return exit_code_; | 161 return exit_code_; |
162 } | 162 } |
163 | 163 |
164 void set_config_path(const FilePath& config_path) { | 164 void set_config_path(const FilePath& config_path) { |
165 config_path_ = config_path; | 165 config_path_ = config_path; |
166 } | 166 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 signal_strategy_.reset( | 219 signal_strategy_.reset( |
220 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, | 220 new XmppSignalStrategy(context_.jingle_thread(), xmpp_login_, |
221 xmpp_auth_token_, xmpp_auth_service_)); | 221 xmpp_auth_token_, xmpp_auth_service_)); |
222 signaling_connector_.reset(new SignalingConnector( | 222 signaling_connector_.reset(new SignalingConnector( |
223 signal_strategy_.get(), | 223 signal_strategy_.get(), |
224 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this)))); | 224 base::Bind(&SimpleHost::OnAuthFailed, base::Unretained(this)))); |
225 | 225 |
226 if (fake_) { | 226 if (fake_) { |
227 scoped_ptr<Capturer> capturer(new CapturerFake()); | 227 scoped_ptr<Capturer> capturer(new CapturerFake()); |
228 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( | 228 scoped_ptr<EventExecutor> event_executor = EventExecutor::Create( |
229 context_.desktop_message_loop()->message_loop_proxy(), | 229 context_.desktop_task_runner(), |
230 context_.ui_message_loop(), capturer.get()); | 230 context_.ui_task_runner(), capturer.get()); |
231 desktop_environment_ = DesktopEnvironment::CreateFake( | 231 desktop_environment_ = DesktopEnvironment::CreateFake( |
232 &context_, capturer.Pass(), event_executor.Pass()); | 232 &context_, capturer.Pass(), event_executor.Pass()); |
233 } else { | 233 } else { |
234 desktop_environment_ = DesktopEnvironment::Create(&context_); | 234 desktop_environment_ = DesktopEnvironment::Create(&context_); |
235 } | 235 } |
236 | 236 |
237 host_ = new ChromotingHost( | 237 host_ = new ChromotingHost( |
238 &context_, signal_strategy_.get(), desktop_environment_.get(), | 238 &context_, signal_strategy_.get(), desktop_environment_.get(), |
239 CreateHostSessionManager(network_settings_, | 239 CreateHostSessionManager(network_settings_, |
240 context_.url_request_context_getter())); | 240 context_.url_request_context_getter())); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 host_secret_hash_)); | 273 host_secret_hash_)); |
274 host_->SetAuthenticatorFactory(factory.Pass()); | 274 host_->SetAuthenticatorFactory(factory.Pass()); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 void OnAuthFailed() { | 278 void OnAuthFailed() { |
279 Shutdown(kInvalidOauthCredentialsExitCode); | 279 Shutdown(kInvalidOauthCredentialsExitCode); |
280 } | 280 } |
281 | 281 |
282 void Shutdown(int exit_code) { | 282 void Shutdown(int exit_code) { |
283 DCHECK(context_.network_message_loop()->BelongsToCurrentThread()); | 283 DCHECK(context_.network_task_runner()->BelongsToCurrentThread()); |
284 | 284 |
285 if (shutting_down_) | 285 if (shutting_down_) |
286 return; | 286 return; |
287 | 287 |
288 shutting_down_ = true; | 288 shutting_down_ = true; |
289 exit_code_ = exit_code; | 289 exit_code_ = exit_code; |
290 host_->Shutdown(base::Bind( | 290 host_->Shutdown(base::Bind( |
291 &SimpleHost::OnShutdownFinished, base::Unretained(this))); | 291 &SimpleHost::OnShutdownFinished, base::Unretained(this))); |
292 } | 292 } |
293 | 293 |
294 void OnShutdownFinished() { | 294 void OnShutdownFinished() { |
295 DCHECK(context_.network_message_loop()->BelongsToCurrentThread()); | 295 DCHECK(context_.network_task_runner()->BelongsToCurrentThread()); |
296 | 296 |
297 // Destroy networking objects while we are on the network thread. | 297 // Destroy networking objects while we are on the network thread. |
298 host_ = NULL; | 298 host_ = NULL; |
299 log_to_server_.reset(); | 299 log_to_server_.reset(); |
300 heartbeat_sender_.reset(); | 300 heartbeat_sender_.reset(); |
301 signaling_connector_.reset(); | 301 signaling_connector_.reset(); |
302 signal_strategy_.reset(); | 302 signal_strategy_.reset(); |
303 | 303 |
304 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 304 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
305 } | 305 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 max_port < 0 || max_port > 65535) { | 427 max_port < 0 || max_port > 65535) { |
428 LOG(ERROR) << "Invalid max-port value: " << max_port | 428 LOG(ERROR) << "Invalid max-port value: " << max_port |
429 << ". Expected integer in range [0, 65535]."; | 429 << ". Expected integer in range [0, 65535]."; |
430 return 1; | 430 return 1; |
431 } | 431 } |
432 simple_host.network_settings()->max_port = max_port; | 432 simple_host.network_settings()->max_port = max_port; |
433 } | 433 } |
434 | 434 |
435 return simple_host.Run(); | 435 return simple_host.Run(); |
436 } | 436 } |
OLD | NEW |