OLD | NEW |
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 // Most of this code is copied from: | 5 // Most of this code is copied from: |
6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} | 6 // src/chrome/browser/policy/asynchronous_policy_loader.{h,cc} |
7 | 7 |
8 #include "remoting/host/policy_hack/policy_watcher.h" | 8 #include "remoting/host/policy_hack/policy_watcher.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // |default| if they are not set in |from|, or values from |bad_type_values| if | 33 // |default| if they are not set in |from|, or values from |bad_type_values| if |
34 // the value in |from| has the wrong type. | 34 // the value in |from| has the wrong type. |
35 scoped_ptr<base::DictionaryValue> CopyGoodValuesAndAddDefaults( | 35 scoped_ptr<base::DictionaryValue> CopyGoodValuesAndAddDefaults( |
36 const base::DictionaryValue* from, | 36 const base::DictionaryValue* from, |
37 const base::DictionaryValue* default_values, | 37 const base::DictionaryValue* default_values, |
38 const base::DictionaryValue* bad_type_values) { | 38 const base::DictionaryValue* bad_type_values) { |
39 scoped_ptr<base::DictionaryValue> to(default_values->DeepCopy()); | 39 scoped_ptr<base::DictionaryValue> to(default_values->DeepCopy()); |
40 for (base::DictionaryValue::Iterator i(*default_values); | 40 for (base::DictionaryValue::Iterator i(*default_values); |
41 !i.IsAtEnd(); i.Advance()) { | 41 !i.IsAtEnd(); i.Advance()) { |
42 | 42 |
43 const base::Value* value = NULL; | 43 const base::Value* value = nullptr; |
44 | 44 |
45 // If the policy isn't in |from|, use the default. | 45 // If the policy isn't in |from|, use the default. |
46 if (!from->Get(i.key(), &value)) { | 46 if (!from->Get(i.key(), &value)) { |
47 continue; | 47 continue; |
48 } | 48 } |
49 | 49 |
50 // If the policy is the wrong type, use the value from |bad_type_values|. | 50 // If the policy is the wrong type, use the value from |bad_type_values|. |
51 if (!value->IsType(i.value().GetType())) { | 51 if (!value->IsType(i.value().GetType())) { |
52 CHECK(bad_type_values->Get(i.key(), &value)); | 52 CHECK(bad_type_values->Get(i.key(), &value)); |
53 } | 53 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void PolicyWatcher::SignalTransientPolicyError() { | 246 void PolicyWatcher::SignalTransientPolicyError() { |
247 const int kMaxRetryCount = 5; | 247 const int kMaxRetryCount = 5; |
248 transient_policy_error_retry_counter_ += 1; | 248 transient_policy_error_retry_counter_ += 1; |
249 if (transient_policy_error_retry_counter_ >= kMaxRetryCount) { | 249 if (transient_policy_error_retry_counter_ >= kMaxRetryCount) { |
250 SignalPolicyError(); | 250 SignalPolicyError(); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 } // namespace policy_hack | 254 } // namespace policy_hack |
255 } // namespace remoting | 255 } // namespace remoting |
OLD | NEW |