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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_invalidator.h

Issue 226093005: Reduce unneeded policy fetches by detecting expired invalidations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // The default, min and max values for max_fetch_delay_. 42 // The default, min and max values for max_fetch_delay_.
43 static const int kMaxFetchDelayDefault; 43 static const int kMaxFetchDelayDefault;
44 static const int kMaxFetchDelayMin; 44 static const int kMaxFetchDelayMin;
45 static const int kMaxFetchDelayMax; 45 static const int kMaxFetchDelayMax;
46 46
47 // The grace period, in seconds, to allow for invalidations to be received 47 // The grace period, in seconds, to allow for invalidations to be received
48 // once the invalidation service starts up. 48 // once the invalidation service starts up.
49 static const int kInvalidationGracePeriod; 49 static const int kInvalidationGracePeriod;
50 50
51 // Time, in seconds, for which unknown version invalidations are ignored after
52 // fetching a policy.
53 static const int kUnknownVersionIgnorePeriod;
54
55 // The max tolerated discrepancy, in seconds, between policy timestamps and
56 // invalidation timestamps when determining if an invalidation is expired.
57 static const int kMaxInvalidationTimeDelta;
58
51 // |core| is the cloud policy core which connects the various policy objects. 59 // |core| is the cloud policy core which connects the various policy objects.
52 // It must remain valid until Shutdown is called. 60 // It must remain valid until Shutdown is called.
53 // |task_runner| is used for scheduling delayed tasks. It must post tasks to 61 // |task_runner| is used for scheduling delayed tasks. It must post tasks to
54 // the main policy thread. 62 // the main policy thread.
55 // |clock| is used to get the current time. 63 // |clock| is used to get the current time.
56 CloudPolicyInvalidator( 64 CloudPolicyInvalidator(
57 CloudPolicyCore* core, 65 CloudPolicyCore* core,
58 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 66 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
59 scoped_ptr<base::Clock> clock); 67 scoped_ptr<base::Clock> clock);
60 virtual ~CloudPolicyInvalidator(); 68 virtual ~CloudPolicyInvalidator();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // response to an invalidation with a missing payload. 125 // response to an invalidation with a missing payload.
118 void RefreshPolicy(bool is_missing_payload); 126 void RefreshPolicy(bool is_missing_payload);
119 127
120 // Acknowledge the latest invalidation. 128 // Acknowledge the latest invalidation.
121 void AcknowledgeInvalidation(); 129 void AcknowledgeInvalidation();
122 130
123 // Determines if the given policy is different from the policy passed in the 131 // Determines if the given policy is different from the policy passed in the
124 // previous call. 132 // previous call.
125 bool IsPolicyChanged(const enterprise_management::PolicyData* policy); 133 bool IsPolicyChanged(const enterprise_management::PolicyData* policy);
126 134
135 // Determine if an invalidation has expired.
136 // |version| is the version of the invalidation, or zero for unknown.
137 bool IsInvalidationExpired(int64 version);
138
127 // Get the kMetricPolicyRefresh histogram metric which should be incremented 139 // Get the kMetricPolicyRefresh histogram metric which should be incremented
128 // when a policy is stored. 140 // when a policy is stored.
129 int GetPolicyRefreshMetric(bool policy_changed); 141 int GetPolicyRefreshMetric(bool policy_changed);
130 142
143 // Get the kMetricPolicyInvalidations histogram metric which should be
144 // incremented when an invalidation is received.
145 int GetInvalidationMetric(bool is_missing_payload, bool is_expired);
146
131 // Determine if invalidations have been enabled longer than the grace period. 147 // Determine if invalidations have been enabled longer than the grace period.
132 bool GetInvalidationsEnabled(); 148 bool GetInvalidationsEnabled();
133 149
134 // The state of the object. 150 // The state of the object.
135 enum State { 151 enum State {
136 UNINITIALIZED, 152 UNINITIALIZED,
137 STOPPED, 153 STOPPED,
138 STARTED, 154 STARTED,
139 SHUT_DOWN 155 SHUT_DOWN
140 }; 156 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // A thread checker to make sure that callbacks are invoked on the correct 217 // A thread checker to make sure that callbacks are invoked on the correct
202 // thread. 218 // thread.
203 base::ThreadChecker thread_checker_; 219 base::ThreadChecker thread_checker_;
204 220
205 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator); 221 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator);
206 }; 222 };
207 223
208 } // namespace policy 224 } // namespace policy
209 225
210 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ 226 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_browsertest.cc ('k') | chrome/browser/policy/cloud/cloud_policy_invalidator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698