| 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 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) | 92 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) |
| 93 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, | 93 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, |
| 94 std::string(), | 94 std::string(), |
| 95 store.get(), | 95 store.get(), |
| 96 task_runner, | 96 task_runner, |
| 97 file_task_runner, | 97 file_task_runner, |
| 98 io_task_runner), | 98 io_task_runner), |
| 99 store_(std::move(store)), | 99 store_(std::move(store)), |
| 100 external_data_manager_(std::move(external_data_manager)), | 100 external_data_manager_(std::move(external_data_manager)), |
| 101 component_policy_cache_path_(component_policy_cache_path), | 101 component_policy_cache_path_(component_policy_cache_path), |
| 102 wait_for_policy_fetch_(wait_for_policy_fetch), | 102 wait_for_policy_fetch_(wait_for_policy_fetch) { |
| 103 policy_fetch_timeout_(false, false) { | |
| 104 time_init_started_ = base::Time::Now(); | 103 time_init_started_ = base::Time::Now(); |
| 105 | 104 |
| 106 // Caller must pass a non-zero policy_fetch_timeout iff | 105 // Caller must pass a non-zero policy_fetch_timeout iff |
| 107 // |wait_for_policy_fetch| is true. | 106 // |wait_for_policy_fetch| is true. |
| 108 DCHECK_NE(wait_for_policy_fetch_, initial_policy_fetch_timeout.is_zero()); | 107 DCHECK_NE(wait_for_policy_fetch_, initial_policy_fetch_timeout.is_zero()); |
| 109 allow_failed_policy_fetches_ = | 108 allow_failed_policy_fetches_ = |
| 110 base::CommandLine::ForCurrentProcess()->HasSwitch( | 109 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 chromeos::switches::kAllowFailedPolicyFetchForTest) || | 110 chromeos::switches::kAllowFailedPolicyFetchForTest) || |
| 112 !initial_policy_fetch_timeout.is_max(); | 111 !initial_policy_fetch_timeout.is_max(); |
| 113 // No need to set the timer when the timeout is infinite. | 112 // No need to set the timer when the timeout is infinite. |
| 114 if (wait_for_policy_fetch_ && allow_failed_policy_fetches_ && | 113 if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) { |
| 115 !initial_policy_fetch_timeout.is_max()) { | |
| 116 policy_fetch_timeout_.Start( | 114 policy_fetch_timeout_.Start( |
| 117 FROM_HERE, | 115 FROM_HERE, |
| 118 initial_policy_fetch_timeout, | 116 initial_policy_fetch_timeout, |
| 119 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, | 117 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, |
| 120 base::Unretained(this))); | 118 base::Unretained(this))); |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 | 121 |
| 124 void UserCloudPolicyManagerChromeOS::ForceTimeoutForTest() { | 122 void UserCloudPolicyManagerChromeOS::ForceTimeoutForTest() { |
| 125 DCHECK(policy_fetch_timeout_.IsRunning()); | 123 DCHECK(policy_fetch_timeout_.IsRunning()); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // OnComponentCloudPolicyUpdated() once it's ready. | 472 // OnComponentCloudPolicyUpdated() once it's ready. |
| 475 return; | 473 return; |
| 476 } | 474 } |
| 477 | 475 |
| 478 core()->StartRefreshScheduler(); | 476 core()->StartRefreshScheduler(); |
| 479 core()->TrackRefreshDelayPref(local_state_, | 477 core()->TrackRefreshDelayPref(local_state_, |
| 480 policy_prefs::kUserPolicyRefreshRate); | 478 policy_prefs::kUserPolicyRefreshRate); |
| 481 } | 479 } |
| 482 | 480 |
| 483 } // namespace policy | 481 } // namespace policy |
| OLD | NEW |