Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 10873050: [Chromoting] Hook up host talkgadget policy checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, 372 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
373 &bool_value)) { 373 &bool_value)) {
374 OnNatPolicyUpdate(bool_value); 374 OnNatPolicyUpdate(bool_value);
375 } 375 }
376 if (policies->GetBoolean( 376 if (policies->GetBoolean(
377 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName, 377 policy_hack::PolicyWatcher::kHostRequireCurtainPolicyName,
378 &bool_value)) { 378 &bool_value)) {
379 OnCurtainPolicyUpdate(bool_value); 379 OnCurtainPolicyUpdate(bool_value);
380 } 380 }
381 if (policies->GetString(
382 policy_hack::PolicyWatcher::kHostTalkGadgetPrefixPolicyName,
383 &string_value)) {
384 OnHostTalkGadgetPrefixPolicyUpdate(string_value);
385 }
381 } 386 }
382 387
383 void OnHostDomainPolicyUpdate(const std::string& host_domain) { 388 void OnHostDomainPolicyUpdate(const std::string& host_domain) {
384 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 389 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
385 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 390 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
386 &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this), 391 &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this),
387 host_domain)); 392 host_domain));
388 return; 393 return;
389 } 394 }
390 395
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 443
439 host_->AddStatusObserver(&curtain_); 444 host_->AddStatusObserver(&curtain_);
440 curtain_.SetEnabled(true); 445 curtain_.SetEnabled(true);
441 } else { 446 } else {
442 curtain_.SetEnabled(false); 447 curtain_.SetEnabled(false);
443 host_->RemoveStatusObserver(&curtain_); 448 host_->RemoveStatusObserver(&curtain_);
444 } 449 }
445 #endif 450 #endif
446 } 451 }
447 452
453 void OnHostTalkGadgetPrefixPolicyUpdate(
454 const std::string& talkgadget_prefix) {
455 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
456 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
457 &HostProcess::OnHostTalkGadgetPrefixPolicyUpdate,
458 base::Unretained(this), talkgadget_prefix));
459 return;
460 }
461
462 LOG(INFO) << "Host talkgadget policy update: " << talkgadget_prefix;
463 if (talkgadget_prefix != talkgadget_prefix_) {
464 LOG(INFO) << "Restarting host due to changed talkgadget policy:";
465 LOG(INFO) << " old talkgadget: " << talkgadget_prefix_;
466 LOG(INFO) << " new talkgadget: " << talkgadget_prefix;
467 talkgadget_prefix_ = talkgadget_prefix;
468 RestartHost();
469 }
470 }
471
448 void StartHost() { 472 void StartHost() {
449 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 473 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
450 DCHECK(!host_); 474 DCHECK(!host_);
451 475
452 if (shutting_down_) 476 if (shutting_down_)
453 return; 477 return;
454 478
455 if (!signal_strategy_.get()) { 479 if (!signal_strategy_.get()) {
456 signal_strategy_.reset( 480 signal_strategy_.reset(
457 new XmppSignalStrategy(context_->url_request_context_getter(), 481 new XmppSignalStrategy(context_->url_request_context_getter(),
458 xmpp_login_, xmpp_auth_token_, 482 xmpp_login_, xmpp_auth_token_,
459 xmpp_auth_service_)); 483 xmpp_auth_service_));
460 484
461 signaling_connector_.reset(new SignalingConnector( 485 signaling_connector_.reset(new SignalingConnector(
462 signal_strategy_.get(), 486 signal_strategy_.get(), context_.get(), talkgadget_prefix_,
463 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); 487 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this))));
464 488
465 if (!oauth_refresh_token_.empty()) { 489 if (!oauth_refresh_token_.empty()) {
466 OAuthClientInfo client_info = { 490 OAuthClientInfo client_info = {
467 kUnofficialOAuth2ClientId, 491 kUnofficialOAuth2ClientId,
468 kUnofficialOAuth2ClientSecret 492 kUnofficialOAuth2ClientSecret
469 }; 493 };
470 494
471 #ifdef OFFICIAL_BUILD 495 #ifdef OFFICIAL_BUILD
472 if (oauth_use_official_client_id_) { 496 if (oauth_use_official_client_id_) {
473 OAuthClientInfo official_client_info = { 497 OAuthClientInfo official_client_info = {
474 kOfficialOAuth2ClientId, 498 kOfficialOAuth2ClientId,
475 kOfficialOAuth2ClientSecret 499 kOfficialOAuth2ClientSecret
476 }; 500 };
477 501
478 client_info = official_client_info; 502 client_info = official_client_info;
479 } 503 }
480 #endif // OFFICIAL_BUILD 504 #endif // OFFICIAL_BUILD
481 505
482 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials( 506 scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials(
483 new SignalingConnector::OAuthCredentials( 507 new SignalingConnector::OAuthCredentials(
484 xmpp_login_, oauth_refresh_token_, client_info)); 508 xmpp_login_, oauth_refresh_token_, client_info));
485 signaling_connector_->EnableOAuth( 509 signaling_connector_->EnableOAuth(oauth_credentials.Pass());
486 oauth_credentials.Pass(),
487 context_->url_request_context_getter());
488 } 510 }
489 } 511 }
490 512
491 if (!desktop_environment_.get()) { 513 if (!desktop_environment_.get()) {
492 desktop_environment_ = 514 desktop_environment_ =
493 DesktopEnvironment::CreateForService(context_.get()); 515 DesktopEnvironment::CreateForService(context_.get());
494 } 516 }
495 517
496 NetworkSettings network_settings( 518 NetworkSettings network_settings(
497 allow_nat_traversal_ ? 519 allow_nat_traversal_ ?
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 576 }
555 577
556 void RestartOnHostShutdown() { 578 void RestartOnHostShutdown() {
557 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 579 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
558 580
559 if (shutting_down_) 581 if (shutting_down_)
560 return; 582 return;
561 583
562 restarting_ = false; 584 restarting_ = false;
563 host_ = NULL; 585 host_ = NULL;
564 log_to_server_.reset(); 586 ResetHost();
garykac 2012/08/23 22:08:50 Note that calling ResetHost here resets the Signal
565 host_event_logger_.reset();
566 heartbeat_sender_.reset();
567 587
568 StartHost(); 588 StartHost();
569 } 589 }
570 590
571 void Shutdown(int exit_code) { 591 void Shutdown(int exit_code) {
572 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 592 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
573 593
574 if (shutting_down_) 594 if (shutting_down_)
575 return; 595 return;
576 596
577 shutting_down_ = true; 597 shutting_down_ = true;
578 exit_code_ = exit_code; 598 exit_code_ = exit_code;
579 if (host_) { 599 if (host_) {
580 host_->Shutdown(base::Bind( 600 host_->Shutdown(base::Bind(
581 &HostProcess::OnShutdownFinished, base::Unretained(this))); 601 &HostProcess::OnShutdownFinished, base::Unretained(this)));
582 } else { 602 } else {
583 OnShutdownFinished(); 603 OnShutdownFinished();
584 } 604 }
585 } 605 }
586 606
587 void OnShutdownFinished() { 607 void OnShutdownFinished() {
588 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 608 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
589 609
590 // Destroy networking objects while we are on the network thread. 610 // Destroy networking objects while we are on the network thread.
591 host_ = NULL; 611 host_ = NULL;
612 ResetHost();
613
614 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
615 }
616
617 void ResetHost() {
618 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
619
592 host_event_logger_.reset(); 620 host_event_logger_.reset();
593 log_to_server_.reset(); 621 log_to_server_.reset();
594 heartbeat_sender_.reset(); 622 heartbeat_sender_.reset();
595 signaling_connector_.reset(); 623 signaling_connector_.reset();
596 signal_strategy_.reset(); 624 signal_strategy_.reset();
597
598 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
599 } 625 }
600 626
601 MessageLoop message_loop_; 627 MessageLoop message_loop_;
602 scoped_ptr<ChromotingHostContext> context_; 628 scoped_ptr<ChromotingHostContext> context_;
603 scoped_ptr<IPC::ChannelProxy> daemon_channel_; 629 scoped_ptr<IPC::ChannelProxy> daemon_channel_;
604 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 630 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
605 631
606 FilePath host_config_path_; 632 FilePath host_config_path_;
607 CompositeHostConfig config_; 633 CompositeHostConfig config_;
608 634
609 std::string host_id_; 635 std::string host_id_;
610 HostKeyPair key_pair_; 636 HostKeyPair key_pair_;
611 protocol::SharedSecretHash host_secret_hash_; 637 protocol::SharedSecretHash host_secret_hash_;
612 std::string xmpp_login_; 638 std::string xmpp_login_;
613 std::string xmpp_auth_token_; 639 std::string xmpp_auth_token_;
614 std::string xmpp_auth_service_; 640 std::string xmpp_auth_service_;
615 641
616 std::string oauth_refresh_token_; 642 std::string oauth_refresh_token_;
617 bool oauth_use_official_client_id_; 643 bool oauth_use_official_client_id_;
618 644
619 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 645 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
620 bool allow_nat_traversal_; 646 bool allow_nat_traversal_;
647 std::string talkgadget_prefix_;
621 scoped_ptr<base::files::FilePathWatcher> config_watcher_; 648 scoped_ptr<base::files::FilePathWatcher> config_watcher_;
622 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_; 649 scoped_ptr<base::DelayTimer<HostProcess> > config_updated_timer_;
623 650
624 bool restarting_; 651 bool restarting_;
625 bool shutting_down_; 652 bool shutting_down_;
626 653
627 scoped_ptr<XmppSignalStrategy> signal_strategy_; 654 scoped_ptr<XmppSignalStrategy> signal_strategy_;
628 scoped_ptr<SignalingConnector> signaling_connector_; 655 scoped_ptr<SignalingConnector> signaling_connector_;
629 scoped_ptr<DesktopEnvironment> desktop_environment_; 656 scoped_ptr<DesktopEnvironment> desktop_environment_;
630 scoped_ptr<HeartbeatSender> heartbeat_sender_; 657 scoped_ptr<HeartbeatSender> heartbeat_sender_;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 user32.GetFunctionPointer("SetProcessDPIAware")); 758 user32.GetFunctionPointer("SetProcessDPIAware"));
732 set_process_dpi_aware(); 759 set_process_dpi_aware();
733 } 760 }
734 761
735 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 762 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
736 // the command line from GetCommandLineW(), so we can safely pass NULL here. 763 // the command line from GetCommandLineW(), so we can safely pass NULL here.
737 return main(0, NULL); 764 return main(0, NULL);
738 } 765 }
739 766
740 #endif // defined(OS_WIN) 767 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_unittest.cc ('k') | remoting/host/signaling_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698