| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "remoting/host/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory( | 64 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory( |
| 65 host_context_->network_task_runner(), | 65 host_context_->network_task_runner(), |
| 66 host_context_->input_task_runner(), | 66 host_context_->input_task_runner(), |
| 67 host_context_->ui_task_runner())); | 67 host_context_->ui_task_runner())); |
| 68 | 68 |
| 69 // Start monitoring configured policies. | 69 // Start monitoring configured policies. |
| 70 policy_watcher_.reset( | 70 policy_watcher_.reset( |
| 71 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); | 71 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); |
| 72 policy_watcher_->StartWatching( | 72 policy_watcher_->StartWatching( |
| 73 base::Bind(&It2MeHost::OnPolicyUpdate, this)); | 73 base::Bind(&It2MeHost::OnPolicyUpdate, this), |
| 74 base::Bind(&It2MeHost::OnPolicyError, this)); |
| 74 | 75 |
| 75 // Switch to the network thread to start the actual connection. | 76 // Switch to the network thread to start the actual connection. |
| 76 host_context_->network_task_runner()->PostTask( | 77 host_context_->network_task_runner()->PostTask( |
| 77 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); | 78 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void It2MeHost::Disconnect() { | 81 void It2MeHost::Disconnect() { |
| 81 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { | 82 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { |
| 82 DCHECK(task_runner_->BelongsToCurrentThread()); | 83 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 83 host_context_->network_task_runner()->PostTask( | 84 host_context_->network_task_runner()->PostTask( |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 326 } |
| 326 | 327 |
| 327 policy_received_ = true; | 328 policy_received_ = true; |
| 328 | 329 |
| 329 if (!pending_connect_.is_null()) { | 330 if (!pending_connect_.is_null()) { |
| 330 pending_connect_.Run(); | 331 pending_connect_.Run(); |
| 331 pending_connect_.Reset(); | 332 pending_connect_.Reset(); |
| 332 } | 333 } |
| 333 } | 334 } |
| 334 | 335 |
| 336 void It2MeHost::OnPolicyError() { |
| 337 // TODO(lukasza): Report the policy error to the user. crbug.com/433009 |
| 338 NOTIMPLEMENTED(); |
| 339 } |
| 340 |
| 335 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { | 341 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { |
| 336 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 342 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
| 337 | 343 |
| 338 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; | 344 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; |
| 339 | 345 |
| 340 // When transitioning from enabled to disabled, force disconnect any | 346 // When transitioning from enabled to disabled, force disconnect any |
| 341 // existing session. | 347 // existing session. |
| 342 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { | 348 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { |
| 343 Disconnect(); | 349 Disconnect(); |
| 344 } | 350 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 ChromotingHostContext* context, | 473 ChromotingHostContext* context, |
| 468 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 474 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 469 base::WeakPtr<It2MeHost::Observer> observer, | 475 base::WeakPtr<It2MeHost::Observer> observer, |
| 470 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 476 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 471 const std::string& directory_bot_jid) { | 477 const std::string& directory_bot_jid) { |
| 472 return new It2MeHost( | 478 return new It2MeHost( |
| 473 context, task_runner, observer, xmpp_server_config, directory_bot_jid); | 479 context, task_runner, observer, xmpp_server_config, directory_bot_jid); |
| 474 } | 480 } |
| 475 | 481 |
| 476 } // namespace remoting | 482 } // namespace remoting |
| OLD | NEW |