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/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "net/socket/client_socket_factory.h" | 10 #include "net/socket/client_socket_factory.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); | 60 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); |
61 return; | 61 return; |
62 } | 62 } |
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_->StartWatching(base::Bind(&It2MeHost::OnPolicyUpdate, this)); | 70 policy_watcher_->StartWatching( |
| 71 base::Bind(&It2MeHost::OnPolicyUpdate, this), |
| 72 base::Bind(&It2MeHost::OnPolicyError, this)); |
71 | 73 |
72 // Switch to the network thread to start the actual connection. | 74 // Switch to the network thread to start the actual connection. |
73 host_context_->network_task_runner()->PostTask( | 75 host_context_->network_task_runner()->PostTask( |
74 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); | 76 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); |
75 } | 77 } |
76 | 78 |
77 void It2MeHost::Disconnect() { | 79 void It2MeHost::Disconnect() { |
78 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { | 80 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { |
79 DCHECK(task_runner_->BelongsToCurrentThread()); | 81 DCHECK(task_runner_->BelongsToCurrentThread()); |
80 host_context_->network_task_runner()->PostTask( | 82 host_context_->network_task_runner()->PostTask( |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 334 } |
333 | 335 |
334 policy_received_ = true; | 336 policy_received_ = true; |
335 | 337 |
336 if (!pending_connect_.is_null()) { | 338 if (!pending_connect_.is_null()) { |
337 pending_connect_.Run(); | 339 pending_connect_.Run(); |
338 pending_connect_.Reset(); | 340 pending_connect_.Reset(); |
339 } | 341 } |
340 } | 342 } |
341 | 343 |
| 344 void It2MeHost::OnPolicyError() { |
| 345 // TODO(lukasza): Report the policy error to the user. crbug.com/433009 |
| 346 NOTIMPLEMENTED(); |
| 347 } |
| 348 |
342 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { | 349 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { |
343 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 350 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
344 | 351 |
345 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; | 352 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; |
346 | 353 |
347 // When transitioning from enabled to disabled, force disconnect any | 354 // When transitioning from enabled to disabled, force disconnect any |
348 // existing session. | 355 // existing session. |
349 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { | 356 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsConnected()) { |
350 Disconnect(); | 357 Disconnect(); |
351 } | 358 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 491 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
485 const std::string& directory_bot_jid) { | 492 const std::string& directory_bot_jid) { |
486 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher = | 493 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher = |
487 policy_hack::PolicyWatcher::Create(policy_service_, | 494 policy_hack::PolicyWatcher::Create(policy_service_, |
488 context->network_task_runner()); | 495 context->network_task_runner()); |
489 return new It2MeHost(context.Pass(), policy_watcher.Pass(), observer, | 496 return new It2MeHost(context.Pass(), policy_watcher.Pass(), observer, |
490 xmpp_server_config, directory_bot_jid); | 497 xmpp_server_config, directory_bot_jid); |
491 } | 498 } |
492 | 499 |
493 } // namespace remoting | 500 } // namespace remoting |
OLD | NEW |