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

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

Issue 722743003: Reporting of policy errors via host-offline-reason: part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and reopened to try memory trybots. Created 6 years 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/policy_hack/policy_watcher_unittest.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"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void CreateAuthenticatorFactory(); 226 void CreateAuthenticatorFactory();
227 227
228 // Tear down resources that run on the UI thread. 228 // Tear down resources that run on the UI thread.
229 void ShutdownOnUiThread(); 229 void ShutdownOnUiThread();
230 230
231 // Applies the host config, returning true if successful. 231 // Applies the host config, returning true if successful.
232 bool ApplyConfig(scoped_ptr<JsonHostConfig> config); 232 bool ApplyConfig(scoped_ptr<JsonHostConfig> config);
233 233
234 // Handles policy updates, by calling On*PolicyUpdate methods. 234 // Handles policy updates, by calling On*PolicyUpdate methods.
235 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 235 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
236 void OnPolicyError();
236 void ApplyHostDomainPolicy(); 237 void ApplyHostDomainPolicy();
237 void ApplyUsernamePolicy(); 238 void ApplyUsernamePolicy();
238 bool OnHostDomainPolicyUpdate(base::DictionaryValue* policies); 239 bool OnHostDomainPolicyUpdate(base::DictionaryValue* policies);
239 bool OnUsernamePolicyUpdate(base::DictionaryValue* policies); 240 bool OnUsernamePolicyUpdate(base::DictionaryValue* policies);
240 bool OnNatPolicyUpdate(base::DictionaryValue* policies); 241 bool OnNatPolicyUpdate(base::DictionaryValue* policies);
241 bool OnRelayPolicyUpdate(base::DictionaryValue* policies); 242 bool OnRelayPolicyUpdate(base::DictionaryValue* policies);
242 bool OnUdpPortPolicyUpdate(base::DictionaryValue* policies); 243 bool OnUdpPortPolicyUpdate(base::DictionaryValue* policies);
243 bool OnCurtainPolicyUpdate(base::DictionaryValue* policies); 244 bool OnCurtainPolicyUpdate(base::DictionaryValue* policies);
244 bool OnHostTalkGadgetPrefixPolicyUpdate(base::DictionaryValue* policies); 245 bool OnHostTalkGadgetPrefixPolicyUpdate(base::DictionaryValue* policies);
245 bool OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies); 246 bool OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 522 }
522 523
523 if (state_ == HOST_INITIALIZING) { 524 if (state_ == HOST_INITIALIZING) {
524 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is 525 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is
525 // already loaded so PolicyWatcher has to be started here. Separate policy 526 // already loaded so PolicyWatcher has to be started here. Separate policy
526 // loading from policy verifications and move |policy_watcher_| 527 // loading from policy verifications and move |policy_watcher_|
527 // initialization to StartOnNetworkThread(). 528 // initialization to StartOnNetworkThread().
528 policy_watcher_ = policy_hack::PolicyWatcher::Create( 529 policy_watcher_ = policy_hack::PolicyWatcher::Create(
529 nullptr, context_->network_task_runner()); 530 nullptr, context_->network_task_runner());
530 policy_watcher_->StartWatching( 531 policy_watcher_->StartWatching(
531 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this))); 532 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)),
533 base::Bind(&HostProcess::OnPolicyError, base::Unretained(this)));
532 } else { 534 } else {
533 // Reapply policies that could be affected by a new config. 535 // Reapply policies that could be affected by a new config.
534 ApplyHostDomainPolicy(); 536 ApplyHostDomainPolicy();
535 ApplyUsernamePolicy(); 537 ApplyUsernamePolicy();
536 538
537 if (state_ == HOST_STARTED) { 539 if (state_ == HOST_STARTED) {
538 // TODO(sergeyu): Here we assume that PIN is the only part of the config 540 // TODO(sergeyu): Here we assume that PIN is the only part of the config
539 // that may change while the service is running. Change ApplyConfig() to 541 // that may change while the service is running. Change ApplyConfig() to
540 // detect other changes in the config and restart host if necessary here. 542 // detect other changes in the config and restart host if necessary here.
541 CreateAuthenticatorFactory(); 543 CreateAuthenticatorFactory();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 restart_required |= OnPairingPolicyUpdate(policies.get()); 928 restart_required |= OnPairingPolicyUpdate(policies.get());
927 restart_required |= OnGnubbyAuthPolicyUpdate(policies.get()); 929 restart_required |= OnGnubbyAuthPolicyUpdate(policies.get());
928 930
929 if (state_ == HOST_INITIALIZING) { 931 if (state_ == HOST_INITIALIZING) {
930 StartHost(); 932 StartHost();
931 } else if (state_ == HOST_STARTED && restart_required) { 933 } else if (state_ == HOST_STARTED && restart_required) {
932 RestartHost(); 934 RestartHost();
933 } 935 }
934 } 936 }
935 937
938 void HostProcess::OnPolicyError() {
939 context_->network_task_runner()->PostTask(
940 FROM_HERE,
941 base::Bind(
942 &HostProcess::ShutdownHost,
943 this,
944 kInvalidHostConfigurationExitCode));
945 }
946
936 void HostProcess::ApplyHostDomainPolicy() { 947 void HostProcess::ApplyHostDomainPolicy() {
937 HOST_LOG << "Policy sets host domain: " << host_domain_; 948 HOST_LOG << "Policy sets host domain: " << host_domain_;
938 949
939 if (!host_domain_.empty()) { 950 if (!host_domain_.empty()) {
940 // If the user does not have a Google email, their client JID will not be 951 // If the user does not have a Google email, their client JID will not be
941 // based on their email. In that case, the username/host domain policies 952 // based on their email. In that case, the username/host domain policies
942 // would be meaningless, since there is no way to check that the JID 953 // would be meaningless, since there is no way to check that the JID
943 // trying to connect actually corresponds to the owner email in question. 954 // trying to connect actually corresponds to the owner email in question.
944 if (host_owner_ != host_owner_email_) { 955 if (host_owner_ != host_owner_email_) {
945 LOG(ERROR) << "The username and host domain policies cannot be enabled " 956 LOG(ERROR) << "The username and host domain policies cannot be enabled "
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 int exit_code = kSuccessExitCode; 1489 int exit_code = kSuccessExitCode;
1479 new HostProcess(context.Pass(), &exit_code); 1490 new HostProcess(context.Pass(), &exit_code);
1480 1491
1481 // Run the main (also UI) message loop until the host no longer needs it. 1492 // Run the main (also UI) message loop until the host no longer needs it.
1482 message_loop.Run(); 1493 message_loop.Run();
1483 1494
1484 return exit_code; 1495 return exit_code;
1485 } 1496 }
1486 1497
1487 } // namespace remoting 1498 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698