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

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

Issue 891663005: Add blocking IO restriction on the network thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@it2me_host_dcheck
Patch Set: Created 5 years, 10 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
« no previous file with comments | « remoting/host/host_signaling_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/debug/alias.h" 13 #include "base/debug/alias.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "crypto/nss_util.h" 24 #include "crypto/nss_util.h"
25 #include "ipc/ipc_channel.h" 25 #include "ipc/ipc_channel.h"
26 #include "ipc/ipc_channel_proxy.h" 26 #include "ipc/ipc_channel_proxy.h"
27 #include "ipc/ipc_listener.h" 27 #include "ipc/ipc_listener.h"
28 #include "media/base/media.h" 28 #include "media/base/media.h"
29 #include "net/base/network_change_notifier.h"
29 #include "net/socket/client_socket_factory.h" 30 #include "net/socket/client_socket_factory.h"
30 #include "net/socket/ssl_server_socket.h" 31 #include "net/socket/ssl_server_socket.h"
31 #include "net/url_request/url_fetcher.h" 32 #include "net/url_request/url_fetcher.h"
32 #include "policy/policy_constants.h" 33 #include "policy/policy_constants.h"
33 #include "remoting/base/auto_thread_task_runner.h" 34 #include "remoting/base/auto_thread_task_runner.h"
34 #include "remoting/base/breakpad.h" 35 #include "remoting/base/breakpad.h"
35 #include "remoting/base/constants.h" 36 #include "remoting/base/constants.h"
36 #include "remoting/base/logging.h" 37 #include "remoting/base/logging.h"
37 #include "remoting/base/rsa_key_pair.h" 38 #include "remoting/base/rsa_key_pair.h"
38 #include "remoting/base/service_urls.h" 39 #include "remoting/base/service_urls.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 scoped_refptr<RsaKeyPair> key_pair_; 317 scoped_refptr<RsaKeyPair> key_pair_;
317 std::string oauth_refresh_token_; 318 std::string oauth_refresh_token_;
318 std::string serialized_config_; 319 std::string serialized_config_;
319 std::string host_owner_; 320 std::string host_owner_;
320 std::string host_owner_email_; 321 std::string host_owner_email_;
321 bool use_service_account_; 322 bool use_service_account_;
322 bool enable_vp9_; 323 bool enable_vp9_;
323 int64_t frame_recorder_buffer_size_; 324 int64_t frame_recorder_buffer_size_;
324 325
325 scoped_ptr<PolicyWatcher> policy_watcher_; 326 scoped_ptr<PolicyWatcher> policy_watcher_;
327 bool policies_loaded_;
326 std::string host_domain_; 328 std::string host_domain_;
327 bool host_username_match_required_; 329 bool host_username_match_required_;
328 bool allow_nat_traversal_; 330 bool allow_nat_traversal_;
329 bool allow_relay_; 331 bool allow_relay_;
330 uint16 min_udp_port_; 332 uint16 min_udp_port_;
331 uint16 max_udp_port_; 333 uint16 max_udp_port_;
332 std::string talkgadget_prefix_; 334 std::string talkgadget_prefix_;
333 bool allow_pairing_; 335 bool allow_pairing_;
334 336
335 bool curtain_required_; 337 bool curtain_required_;
336 ThirdPartyAuthConfig third_party_auth_config_; 338 ThirdPartyAuthConfig third_party_auth_config_;
337 bool enable_gnubby_auth_; 339 bool enable_gnubby_auth_;
338 340
339 // Boolean to change flow, where ncessary, if we're 341 // Boolean to change flow, where necessary, if we're
340 // capturing a window instead of the entire desktop. 342 // capturing a window instead of the entire desktop.
341 bool enable_window_capture_; 343 bool enable_window_capture_;
342 344
343 // Used to specify which window to stream, if enabled. 345 // Used to specify which window to stream, if enabled.
344 webrtc::WindowId window_id_; 346 webrtc::WindowId window_id_;
345 347
346 // Used to send heartbeats while running, and the reason for going offline 348 // Used to send heartbeats while running, and the reason for going offline
347 // when shutting down. 349 // when shutting down.
348 scoped_ptr<HostSignalingManager> host_signaling_manager_; 350 scoped_ptr<HostSignalingManager> host_signaling_manager_;
349 351
(...skipping 21 matching lines...) Expand all
371 }; 373 };
372 374
373 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, 375 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
374 int* exit_code_out, 376 int* exit_code_out,
375 ShutdownWatchdog* shutdown_watchdog) 377 ShutdownWatchdog* shutdown_watchdog)
376 : context_(context.Pass()), 378 : context_(context.Pass()),
377 state_(HOST_INITIALIZING), 379 state_(HOST_INITIALIZING),
378 use_service_account_(false), 380 use_service_account_(false),
379 enable_vp9_(false), 381 enable_vp9_(false),
380 frame_recorder_buffer_size_(0), 382 frame_recorder_buffer_size_(0),
383 policies_loaded_(false),
381 host_username_match_required_(false), 384 host_username_match_required_(false),
382 allow_nat_traversal_(true), 385 allow_nat_traversal_(true),
383 allow_relay_(true), 386 allow_relay_(true),
384 min_udp_port_(0), 387 min_udp_port_(0),
385 max_udp_port_(0), 388 max_udp_port_(0),
386 allow_pairing_(true), 389 allow_pairing_(true),
387 curtain_required_(false), 390 curtain_required_(false),
388 enable_gnubby_auth_(false), 391 enable_gnubby_auth_(false),
389 enable_window_capture_(false), 392 enable_window_capture_(false),
390 window_id_(0), 393 window_id_(0),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 ShutdownHost(kInvalidHostConfigurationExitCode); 543 ShutdownHost(kInvalidHostConfigurationExitCode);
541 return; 544 return;
542 } 545 }
543 546
544 if (!ApplyConfig(*config)) { 547 if (!ApplyConfig(*config)) {
545 LOG(ERROR) << "Failed to apply the configuration."; 548 LOG(ERROR) << "Failed to apply the configuration.";
546 ShutdownHost(kInvalidHostConfigurationExitCode); 549 ShutdownHost(kInvalidHostConfigurationExitCode);
547 return; 550 return;
548 } 551 }
549 552
553 if (!policies_loaded_)
Łukasz Anforowicz 2015/01/31 00:02:34 The early return is not needed - this can be made
Sergey Ulanov 2015/01/31 00:34:26 Done.
554 return;
555
550 if (state_ == HOST_INITIALIZING) { 556 if (state_ == HOST_INITIALIZING) {
551 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is 557 StartHost();
Łukasz Anforowicz 2015/01/31 00:02:34 It seems that StartHost can only proceed if 1) pol
Sergey Ulanov 2015/01/31 00:34:26 Added StartHostIfReady() that checks these two con
552 // already loaded so PolicyWatcher has to be started here. Separate policy 558 } else if (state_ == HOST_STARTED) {
553 // loading from policy verifications and move |policy_watcher_|
554 // initialization to StartOnNetworkThread().
555 policy_watcher_ =
556 PolicyWatcher::Create(nullptr, context_->file_task_runner());
557 policy_watcher_->StartWatching(
558 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)),
559 base::Bind(&HostProcess::OnPolicyError, base::Unretained(this)));
560 } else {
561 // Reapply policies that could be affected by a new config. 559 // Reapply policies that could be affected by a new config.
562 ApplyHostDomainPolicy(); 560 ApplyHostDomainPolicy();
Łukasz Anforowicz 2015/01/31 00:02:34 Would it make sense to add DCHECK(policy_loaded_)
Sergey Ulanov 2015/01/31 00:34:26 Added DCHECK here. I don't think we need a DCHECK
563 ApplyUsernamePolicy(); 561 ApplyUsernamePolicy();
564 562
565 if (state_ == HOST_STARTED) { 563 // TODO(sergeyu): Here we assume that PIN is the only part of the config
566 // TODO(sergeyu): Here we assume that PIN is the only part of the config 564 // that may change while the service is running. Change ApplyConfig() to
567 // that may change while the service is running. Change ApplyConfig() to 565 // detect other changes in the config and restart host if necessary here.
568 // detect other changes in the config and restart host if necessary here. 566 CreateAuthenticatorFactory();
569 CreateAuthenticatorFactory();
570 }
571 } 567 }
572 } 568 }
573 569
574 void HostProcess::OnConfigWatcherError() { 570 void HostProcess::OnConfigWatcherError() {
575 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 571 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
576 ShutdownHost(kInvalidHostConfigurationExitCode); 572 ShutdownHost(kInvalidHostConfigurationExitCode);
577 } 573 }
578 574
579 void HostProcess::StartOnNetworkThread() { 575 void HostProcess::StartOnNetworkThread() {
580 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 576 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 713 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
718 714
719 if (!InitWithCommandLine(base::CommandLine::ForCurrentProcess())) { 715 if (!InitWithCommandLine(base::CommandLine::ForCurrentProcess())) {
720 // Shutdown the host if the command line is invalid. 716 // Shutdown the host if the command line is invalid.
721 context_->network_task_runner()->PostTask( 717 context_->network_task_runner()->PostTask(
722 FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this, 718 FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this,
723 kUsageExitCode)); 719 kUsageExitCode));
724 return; 720 return;
725 } 721 }
726 722
723 policy_watcher_ =
724 PolicyWatcher::Create(nullptr, context_->file_task_runner());
725 policy_watcher_->StartWatching(
726 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)),
727 base::Bind(&HostProcess::OnPolicyError, base::Unretained(this)));
728
727 #if defined(OS_LINUX) 729 #if defined(OS_LINUX)
728 // If an audio pipe is specific on the command-line then initialize 730 // If an audio pipe is specific on the command-line then initialize
729 // AudioCapturerLinux to capture from it. 731 // AudioCapturerLinux to capture from it.
730 base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()-> 732 base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()->
731 GetSwitchValuePath(kAudioPipeSwitchName); 733 GetSwitchValuePath(kAudioPipeSwitchName);
732 if (!audio_pipe_name.empty()) { 734 if (!audio_pipe_name.empty()) {
733 remoting::AudioCapturerLinux::InitializePipeReader( 735 remoting::AudioCapturerLinux::InitializePipeReader(
734 context_->audio_task_runner(), audio_pipe_name); 736 context_->audio_task_runner(), audio_pipe_name);
735 } 737 }
736 738
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 base::Bind(&HostProcess::StartOnNetworkThread, this)); 779 base::Bind(&HostProcess::StartOnNetworkThread, this));
778 } 780 }
779 781
780 void HostProcess::ShutdownOnUiThread() { 782 void HostProcess::ShutdownOnUiThread() {
781 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 783 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
782 784
783 // Tear down resources that need to be torn down on the UI thread. 785 // Tear down resources that need to be torn down on the UI thread.
784 daemon_channel_.reset(); 786 daemon_channel_.reset();
785 desktop_environment_factory_.reset(); 787 desktop_environment_factory_.reset();
786 788
789 policy_watcher_.reset();
790
787 // It is now safe for the HostProcess to be deleted. 791 // It is now safe for the HostProcess to be deleted.
788 self_ = nullptr; 792 self_ = nullptr;
789 793
790 #if defined(OS_LINUX) 794 #if defined(OS_LINUX)
791 // Cause the global AudioPipeReader to be freed, otherwise the audio 795 // Cause the global AudioPipeReader to be freed, otherwise the audio
792 // thread will remain in-use and prevent the process from exiting. 796 // thread will remain in-use and prevent the process from exiting.
793 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. 797 // TODO(wez): DesktopEnvironmentFactory should own the pipe reader.
794 // See crbug.com/161373 and crbug.com/104544. 798 // See crbug.com/161373 and crbug.com/104544.
795 AudioCapturerLinux::InitializePipeReader(nullptr, base::FilePath()); 799 AudioCapturerLinux::InitializePipeReader(nullptr, base::FilePath());
796 #endif 800 #endif
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 &frame_recorder_buffer_kb); 953 &frame_recorder_buffer_kb);
950 } 954 }
951 if (frame_recorder_buffer_kb > 0) { 955 if (frame_recorder_buffer_kb > 0) {
952 frame_recorder_buffer_size_ = 1024LL * frame_recorder_buffer_kb; 956 frame_recorder_buffer_size_ = 1024LL * frame_recorder_buffer_kb;
953 } 957 }
954 958
955 return true; 959 return true;
956 } 960 }
957 961
958 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 962 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
959 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 963 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
964 context_->network_task_runner()->PostTask(
965 FROM_HERE, base::Bind(&HostProcess::OnPolicyUpdate, this,
966 base::Passed(&policies)));
967 return;
968 }
960 969
961 bool restart_required = false; 970 bool restart_required = false;
962 restart_required |= OnHostDomainPolicyUpdate(policies.get()); 971 restart_required |= OnHostDomainPolicyUpdate(policies.get());
963 restart_required |= OnCurtainPolicyUpdate(policies.get()); 972 restart_required |= OnCurtainPolicyUpdate(policies.get());
964 // Note: UsernamePolicyUpdate must run after OnCurtainPolicyUpdate. 973 // Note: UsernamePolicyUpdate must run after OnCurtainPolicyUpdate.
965 restart_required |= OnUsernamePolicyUpdate(policies.get()); 974 restart_required |= OnUsernamePolicyUpdate(policies.get());
966 restart_required |= OnNatPolicyUpdate(policies.get()); 975 restart_required |= OnNatPolicyUpdate(policies.get());
967 restart_required |= OnRelayPolicyUpdate(policies.get()); 976 restart_required |= OnRelayPolicyUpdate(policies.get());
968 restart_required |= OnUdpPortPolicyUpdate(policies.get()); 977 restart_required |= OnUdpPortPolicyUpdate(policies.get());
969 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(policies.get()); 978 restart_required |= OnHostTalkGadgetPrefixPolicyUpdate(policies.get());
970 restart_required |= OnHostTokenUrlPolicyUpdate(policies.get()); 979 restart_required |= OnHostTokenUrlPolicyUpdate(policies.get());
971 restart_required |= OnPairingPolicyUpdate(policies.get()); 980 restart_required |= OnPairingPolicyUpdate(policies.get());
972 restart_required |= OnGnubbyAuthPolicyUpdate(policies.get()); 981 restart_required |= OnGnubbyAuthPolicyUpdate(policies.get());
973 982
983 policies_loaded_ = true;
Łukasz Anforowicz 2015/01/31 00:02:34 If adding DCHECK (as I suggested elsewhere) to App
Sergey Ulanov 2015/01/31 00:34:26 I'd like to avoid too many changes in how policies
984
974 if (state_ == HOST_INITIALIZING) { 985 if (state_ == HOST_INITIALIZING) {
975 StartHost(); 986 if (!serialized_config_.empty())
976 } else if (state_ == HOST_STARTED && restart_required) { 987 StartHost();
977 RestartHost(); 988 } else if (state_ == HOST_STARTED) {
989 if (restart_required)
990 RestartHost();
978 } 991 }
979 } 992 }
980 993
981 void HostProcess::OnPolicyError() { 994 void HostProcess::OnPolicyError() {
982 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 995 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
996 context_->network_task_runner()->PostTask(
997 FROM_HERE, base::Bind(&HostProcess::OnPolicyError, this));
998 return;
999 }
983 1000
984 ShutdownHost(kInvalidHostConfigurationExitCode); 1001 ShutdownHost(kInvalidHostConfigurationExitCode);
985 } 1002 }
986 1003
987 void HostProcess::ApplyHostDomainPolicy() { 1004 void HostProcess::ApplyHostDomainPolicy() {
1005 if (state_ != HOST_STARTED)
1006 return;
1007
988 HOST_LOG << "Policy sets host domain: " << host_domain_; 1008 HOST_LOG << "Policy sets host domain: " << host_domain_;
989 1009
990 if (!host_domain_.empty()) { 1010 if (!host_domain_.empty()) {
991 // If the user does not have a Google email, their client JID will not be 1011 // If the user does not have a Google email, their client JID will not be
992 // based on their email. In that case, the username/host domain policies 1012 // based on their email. In that case, the username/host domain policies
993 // would be meaningless, since there is no way to check that the JID 1013 // would be meaningless, since there is no way to check that the JID
994 // trying to connect actually corresponds to the owner email in question. 1014 // trying to connect actually corresponds to the owner email in question.
995 if (host_owner_ != host_owner_email_) { 1015 if (host_owner_ != host_owner_email_) {
996 LOG(ERROR) << "The username and host domain policies cannot be enabled " 1016 LOG(ERROR) << "The username and host domain policies cannot be enabled "
997 << "for accounts with a non-Google email."; 1017 << "for accounts with a non-Google email.";
(...skipping 14 matching lines...) Expand all
1012 if (!policies->GetString(policy::key::kRemoteAccessHostDomain, 1032 if (!policies->GetString(policy::key::kRemoteAccessHostDomain,
1013 &host_domain_)) { 1033 &host_domain_)) {
1014 return false; 1034 return false;
1015 } 1035 }
1016 1036
1017 ApplyHostDomainPolicy(); 1037 ApplyHostDomainPolicy();
1018 return false; 1038 return false;
1019 } 1039 }
1020 1040
1021 void HostProcess::ApplyUsernamePolicy() { 1041 void HostProcess::ApplyUsernamePolicy() {
1042 if (state_ != HOST_STARTED)
1043 return;
1044
1022 if (host_username_match_required_) { 1045 if (host_username_match_required_) {
1023 HOST_LOG << "Policy requires host username match."; 1046 HOST_LOG << "Policy requires host username match.";
1024 1047
1025 // See comment in ApplyHostDomainPolicy. 1048 // See comment in ApplyHostDomainPolicy.
1026 if (host_owner_ != host_owner_email_) { 1049 if (host_owner_ != host_owner_email_) {
1027 LOG(ERROR) << "The username and host domain policies cannot be enabled " 1050 LOG(ERROR) << "The username and host domain policies cannot be enabled "
1028 << "for accounts with a non-Google email."; 1051 << "for accounts with a non-Google email.";
1029 ShutdownHost(kUsernameMismatchExitCode); 1052 ShutdownHost(kUsernameMismatchExitCode);
1030 } 1053 }
1031 1054
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); 1384 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get()));
1362 #else // !defined(REMOTING_MULTI_PROCESS) 1385 #else // !defined(REMOTING_MULTI_PROCESS)
1363 host_event_logger_ = 1386 host_event_logger_ =
1364 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); 1387 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName);
1365 #endif // !defined(REMOTING_MULTI_PROCESS) 1388 #endif // !defined(REMOTING_MULTI_PROCESS)
1366 1389
1367 host_->SetEnableCurtaining(curtain_required_); 1390 host_->SetEnableCurtaining(curtain_required_);
1368 host_->Start(host_owner_email_); 1391 host_->Start(host_owner_email_);
1369 1392
1370 CreateAuthenticatorFactory(); 1393 CreateAuthenticatorFactory();
1394
1395 ApplyHostDomainPolicy();
1396 ApplyUsernamePolicy();
1371 } 1397 }
1372 1398
1373 void HostProcess::OnAuthFailed() { 1399 void HostProcess::OnAuthFailed() {
1374 ShutdownHost(kInvalidOauthCredentialsExitCode); 1400 ShutdownHost(kInvalidOauthCredentialsExitCode);
1375 } 1401 }
1376 1402
1377 void HostProcess::RestartHost() { 1403 void HostProcess::RestartHost() {
1378 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 1404 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
1379 DCHECK_EQ(state_, HOST_STARTED); 1405 DCHECK_EQ(state_, HOST_STARTED);
1380 1406
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 1458
1433 if (state_ == HOST_STOPPING_TO_RESTART) { 1459 if (state_ == HOST_STOPPING_TO_RESTART) {
1434 StartHost(); 1460 StartHost();
1435 } else if (state_ == HOST_STOPPING) { 1461 } else if (state_ == HOST_STOPPING) {
1436 state_ = HOST_STOPPED; 1462 state_ = HOST_STOPPED;
1437 1463
1438 shutdown_watchdog_->SetExitCode(*exit_code_out_); 1464 shutdown_watchdog_->SetExitCode(*exit_code_out_);
1439 shutdown_watchdog_->Arm(); 1465 shutdown_watchdog_->Arm();
1440 1466
1441 config_watcher_.reset(); 1467 config_watcher_.reset();
1442 policy_watcher_.reset();
1443 1468
1444 // Complete the rest of shutdown on the main thread. 1469 // Complete the rest of shutdown on the main thread.
1445 context_->ui_task_runner()->PostTask( 1470 context_->ui_task_runner()->PostTask(
1446 FROM_HERE, base::Bind(&HostProcess::ShutdownOnUiThread, this)); 1471 FROM_HERE, base::Bind(&HostProcess::ShutdownOnUiThread, this));
1447 } else { 1472 } else {
1448 // This method is only called in STOPPING_TO_RESTART and STOPPING states. 1473 // This method is only called in STOPPING_TO_RESTART and STOPPING states.
1449 NOTREACHED(); 1474 NOTREACHED();
1450 } 1475 }
1451 } 1476 }
1452 1477
(...skipping 21 matching lines...) Expand all
1474 gtk_init(nullptr, nullptr); 1499 gtk_init(nullptr, nullptr);
1475 #endif 1500 #endif
1476 1501
1477 // Enable support for SSL server sockets, which must be done while still 1502 // Enable support for SSL server sockets, which must be done while still
1478 // single-threaded. 1503 // single-threaded.
1479 net::EnableSSLServerSockets(); 1504 net::EnableSSLServerSockets();
1480 1505
1481 // Ensures runtime specific CPU features are initialized. 1506 // Ensures runtime specific CPU features are initialized.
1482 media::InitializeCPUSpecificMediaFeatures(); 1507 media::InitializeCPUSpecificMediaFeatures();
1483 1508
1509 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier;
Łukasz Anforowicz 2015/01/31 00:02:34 I don't understand what this does - this will alwa
Sergey Ulanov 2015/01/31 00:34:26 Yes. Thank you.
1510
1484 // Create the main message loop and start helper threads. 1511 // Create the main message loop and start helper threads.
1485 base::MessageLoopForUI message_loop; 1512 base::MessageLoopForUI message_loop;
1486 scoped_ptr<ChromotingHostContext> context = 1513 scoped_ptr<ChromotingHostContext> context =
1487 ChromotingHostContext::Create(new AutoThreadTaskRunner( 1514 ChromotingHostContext::Create(new AutoThreadTaskRunner(
1488 message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure())); 1515 message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure()));
1489 if (!context) 1516 if (!context)
1490 return kInitializationFailed; 1517 return kInitializationFailed;
1491 1518
1519 // BasicURLRequestContext holds references to threads, so it needs to be
1520 // dereferences on UI threads. Store the reference to the URLRequestGetter to
Łukasz Anforowicz 2015/01/31 00:02:34 I don't understand :-( I would understand if you
Sergey Ulanov 2015/01/31 00:34:26 Thread::Stop() is a blocking operation (because it
Łukasz Anforowicz 2015/01/31 00:41:35 Acknowledged.
1521 // make sure it's not destroyed on other threads.
1522 // TODO(sergeyu): Consider fixing it in BasicURLRequestContext.
1523 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter =
1524 context->url_request_context_getter();
1525
1492 // Create & start the HostProcess using these threads. 1526 // Create & start the HostProcess using these threads.
1493 // TODO(wez): The HostProcess holds a reference to itself until Shutdown(). 1527 // TODO(wez): The HostProcess holds a reference to itself until Shutdown().
1494 // Remove this hack as part of the multi-process refactoring. 1528 // Remove this hack as part of the multi-process refactoring.
1495 int exit_code = kSuccessExitCode; 1529 int exit_code = kSuccessExitCode;
1496 ShutdownWatchdog shutdown_watchdog( 1530 ShutdownWatchdog shutdown_watchdog(
1497 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1531 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1498 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); 1532 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog);
1499 1533
1500 // Run the main (also UI) message loop until the host no longer needs it. 1534 // Run the main (also UI) message loop until the host no longer needs it.
1501 message_loop.Run(); 1535 message_loop.Run();
1502 1536
1503 return exit_code; 1537 return exit_code;
1504 } 1538 }
1505 1539
1506 } // namespace remoting 1540 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_signaling_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698