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 <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 void It2MeHost::SetState(It2MeHostState state, | 386 void It2MeHost::SetState(It2MeHostState state, |
387 const std::string& error_message) { | 387 const std::string& error_message) { |
388 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 388 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
389 | 389 |
390 switch (state_) { | 390 switch (state_) { |
391 case kDisconnected: | 391 case kDisconnected: |
392 DCHECK(state == kStarting || | 392 DCHECK(state == kStarting || |
393 state == kError) << state; | 393 state == kError) << state; |
394 break; | 394 break; |
395 case kStarting: | 395 case kStarting: |
396 DCHECK(state == kRequestedAccessCode || | 396 DCHECK(state == kRequestedAccessCode || |
Sergey Ulanov
2016/10/27 22:44:12
maybe update formatting for all DCHECKS here to ma
joedow
2016/10/31 17:16:07
I'm going to update the changed conditions to matc
| |
397 state == kDisconnected || | 397 state == kDisconnected || |
398 state == kError || | 398 state == kError || |
399 state == kInvalidDomainError) << state; | 399 state == kInvalidDomainError) << state; |
400 break; | 400 break; |
401 case kRequestedAccessCode: | 401 case kRequestedAccessCode: |
402 DCHECK(state == kReceivedAccessCode || | 402 DCHECK(state == kReceivedAccessCode || |
403 state == kDisconnected || | 403 state == kDisconnected || |
404 state == kError) << state; | 404 state == kError) << state; |
405 break; | 405 break; |
406 case kReceivedAccessCode: | 406 case kReceivedAccessCode: |
407 DCHECK(state == kConnected || | 407 DCHECK(state == kConnecting || state == kDisconnected || state == kError) |
408 state == kDisconnected || | 408 << state; |
409 state == kError) << state; | |
410 break; | 409 break; |
411 case kConnected: | 410 case kConnected: |
412 DCHECK(state == kDisconnected || | 411 DCHECK(state == kDisconnected || |
413 state == kError) << state; | 412 state == kError) << state; |
414 break; | 413 break; |
414 case kConnecting: | |
Sergey Ulanov
2016/10/27 22:44:12
Put kConnecting before kConnected
joedow
2016/10/31 17:16:07
Done.
| |
415 DCHECK(state == kConnected || state == kDisconnected || state == kError) | |
416 << state; | |
417 break; | |
415 case kError: | 418 case kError: |
416 DCHECK(state == kDisconnected) << state; | 419 DCHECK(state == kDisconnected) << state; |
417 break; | 420 break; |
418 case kInvalidDomainError: | 421 case kInvalidDomainError: |
419 DCHECK(state == kDisconnected) << state; | 422 DCHECK(state == kDisconnected) << state; |
420 break; | 423 break; |
421 }; | 424 }; |
422 | 425 |
423 state_ = state; | 426 state_ = state; |
424 | 427 |
425 // Post a state-change notification to the web-app. | 428 // Post a state-change notification to the web-app. |
426 host_context_->ui_task_runner()->PostTask( | 429 host_context_->ui_task_runner()->PostTask( |
427 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStateChanged, observer_, | 430 FROM_HERE, base::Bind(&It2MeHost::Observer::OnStateChanged, observer_, |
428 state, error_message)); | 431 state, error_message)); |
429 } | 432 } |
430 | 433 |
431 bool It2MeHost::IsConnected() const { | 434 bool It2MeHost::IsConnected() const { |
Sergey Ulanov
2016/10/27 22:44:12
This doesn't look like the right name for this met
joedow
2016/10/31 17:16:07
Changed. Agreed that IsConnected is ambiguous sin
| |
432 return state_ == kRequestedAccessCode || state_ == kReceivedAccessCode || | 435 return state_ == kRequestedAccessCode || state_ == kReceivedAccessCode || |
433 state_ == kConnected; | 436 state_ == kConnected || state_ == kConnecting; |
434 } | 437 } |
435 | 438 |
436 void It2MeHost::OnReceivedSupportID( | 439 void It2MeHost::OnReceivedSupportID( |
437 const std::string& support_id, | 440 const std::string& support_id, |
438 const base::TimeDelta& lifetime, | 441 const base::TimeDelta& lifetime, |
439 const std::string& error_message) { | 442 const std::string& error_message) { |
440 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); | 443 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); |
441 | 444 |
442 if (!error_message.empty()) { | 445 if (!error_message.empty()) { |
443 SetState(kError, error_message); | 446 SetState(kError, error_message); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 std::string("@") + required_client_domain_, | 507 std::string("@") + required_client_domain_, |
505 base::CompareCase::INSENSITIVE_ASCII)) { | 508 base::CompareCase::INSENSITIVE_ASCII)) { |
506 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid | 509 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid |
507 << ": Domain mismatch."; | 510 << ": Domain mismatch."; |
508 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); | 511 result_callback.Run(ValidationResult::ERROR_INVALID_ACCOUNT); |
509 DisconnectOnNetworkThread(); | 512 DisconnectOnNetworkThread(); |
510 return; | 513 return; |
511 } | 514 } |
512 } | 515 } |
513 | 516 |
517 HOST_LOG << "Client " << client_username << " connecting."; | |
518 SetState(kConnecting, std::string()); | |
519 | |
514 // Show a confirmation dialog to the user to allow them to confirm/reject it. | 520 // Show a confirmation dialog to the user to allow them to confirm/reject it. |
515 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( | 521 confirmation_dialog_proxy_.reset(new It2MeConfirmationDialogProxy( |
516 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); | 522 host_context_->ui_task_runner(), std::move(confirmation_dialog_))); |
517 | 523 |
518 confirmation_dialog_proxy_->Show( | 524 confirmation_dialog_proxy_->Show( |
519 client_username, base::Bind(&It2MeHost::OnConfirmationResult, | 525 client_username, base::Bind(&It2MeHost::OnConfirmationResult, |
520 base::Unretained(this), result_callback)); | 526 base::Unretained(this), result_callback)); |
521 } | 527 } |
522 | 528 |
523 void It2MeHost::OnConfirmationResult( | 529 void It2MeHost::OnConfirmationResult( |
(...skipping 27 matching lines...) Expand all Loading... | |
551 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); | 557 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); |
552 | 558 |
553 std::unique_ptr<PolicyWatcher> policy_watcher = | 559 std::unique_ptr<PolicyWatcher> policy_watcher = |
554 PolicyWatcher::Create(policy_service, context->file_task_runner()); | 560 PolicyWatcher::Create(policy_service, context->file_task_runner()); |
555 return new It2MeHost(std::move(context), std::move(policy_watcher), | 561 return new It2MeHost(std::move(context), std::move(policy_watcher), |
556 It2MeConfirmationDialog::Create(), observer, | 562 It2MeConfirmationDialog::Create(), observer, |
557 std::move(signal_strategy), username, directory_bot_jid); | 563 std::move(signal_strategy), username, directory_bot_jid); |
558 } | 564 } |
559 | 565 |
560 } // namespace remoting | 566 } // namespace remoting |
OLD | NEW |