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

Side by Side Diff: chrome/browser/chromeos/policy/active_directory_policy_manager.cc

Issue 2937953002: Chromad: Drop delay for policy refresh on startup (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/active_directory_policy_manager.h" 5 #include "chrome/browser/chromeos/policy/active_directory_policy_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "chromeos/dbus/auth_policy_client.h" 13 #include "chromeos/dbus/auth_policy_client.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "components/policy/core/common/policy_bundle.h" 15 #include "components/policy/core/common/policy_bundle.h"
16 #include "components/policy/core/common/policy_types.h" 16 #include "components/policy/core/common/policy_types.h"
17 #include "components/policy/policy_constants.h" 17 #include "components/policy/policy_constants.h"
18 18
19 namespace { 19 namespace {
20 20
21 // Refresh policy every 90 minutes which matches the Windows default: 21 // Refresh policy every 90 minutes which matches the Windows default:
22 // https://technet.microsoft.com/en-us/library/cc940895.aspx 22 // https://technet.microsoft.com/en-us/library/cc940895.aspx
23 constexpr base::TimeDelta kRefreshInterval = base::TimeDelta::FromMinutes(90); 23 constexpr base::TimeDelta kRefreshInterval = base::TimeDelta::FromMinutes(90);
24 24
25 // After startup, delay initial policy fetch to keep authpolicyd free for more
26 // important tasks like user auth.
27 constexpr base::TimeDelta kInitialFetchDelay = base::TimeDelta::FromSeconds(60);
28
29 // Retry delay in case of |refresh_in_progress_|. 25 // Retry delay in case of |refresh_in_progress_|.
30 constexpr base::TimeDelta kBusyRetryInterval = base::TimeDelta::FromSeconds(1); 26 constexpr base::TimeDelta kBusyRetryInterval = base::TimeDelta::FromSeconds(1);
31 27
32 } // namespace 28 } // namespace
33 29
34 namespace policy { 30 namespace policy {
35 31
36 ActiveDirectoryPolicyManager::~ActiveDirectoryPolicyManager() {} 32 ActiveDirectoryPolicyManager::~ActiveDirectoryPolicyManager() {}
37 33
38 // static 34 // static
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 143 }
148 144
149 void ActiveDirectoryPolicyManager::ScheduleAutomaticRefresh() { 145 void ActiveDirectoryPolicyManager::ScheduleAutomaticRefresh() {
150 base::TimeTicks baseline; 146 base::TimeTicks baseline;
151 base::TimeDelta interval; 147 base::TimeDelta interval;
152 if (retry_refresh_) { 148 if (retry_refresh_) {
153 baseline = last_refresh_; 149 baseline = last_refresh_;
154 interval = kBusyRetryInterval; 150 interval = kBusyRetryInterval;
155 } else if (last_refresh_ == base::TimeTicks()) { 151 } else if (last_refresh_ == base::TimeTicks()) {
156 baseline = startup_; 152 baseline = startup_;
157 interval = kInitialFetchDelay; 153 interval = base::TimeDelta();
158 } else { 154 } else {
159 baseline = last_refresh_; 155 baseline = last_refresh_;
160 interval = kRefreshInterval; 156 interval = kRefreshInterval;
161 } 157 }
162 base::TimeDelta delay; 158 base::TimeDelta delay;
163 const base::TimeTicks now(base::TimeTicks::Now()); 159 const base::TimeTicks now(base::TimeTicks::Now());
164 if (now < baseline + interval) { 160 if (now < baseline + interval) {
165 delay = baseline + interval - now; 161 delay = baseline + interval - now;
166 } 162 }
167 ScheduleRefresh(delay); 163 ScheduleRefresh(delay);
(...skipping 21 matching lines...) Expand all
189 weak_ptr_factory_.GetWeakPtr())); 185 weak_ptr_factory_.GetWeakPtr()));
190 } else { 186 } else {
191 auth_policy_client->RefreshUserPolicy( 187 auth_policy_client->RefreshUserPolicy(
192 account_id_, 188 account_id_,
193 base::Bind(&ActiveDirectoryPolicyManager::OnPolicyRefreshed, 189 base::Bind(&ActiveDirectoryPolicyManager::OnPolicyRefreshed,
194 weak_ptr_factory_.GetWeakPtr())); 190 weak_ptr_factory_.GetWeakPtr()));
195 } 191 }
196 } 192 }
197 193
198 } // namespace policy 194 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698