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

Side by Side Diff: components/network_time/network_time_tracker.h

Issue 2448943004: Add experimental feature info to certificate reports (Closed)
Patch Set: battre comment Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ 5 #ifndef COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_
6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ 6 #define COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Network time is unavailable because the tracker has not yet 70 // Network time is unavailable because the tracker has not yet
71 // attempted to retrieve a time from the network, but the first 71 // attempted to retrieve a time from the network, but the first
72 // attempt is currently pending. 72 // attempt is currently pending.
73 NETWORK_TIME_FIRST_SYNC_PENDING, 73 NETWORK_TIME_FIRST_SYNC_PENDING,
74 // Network time is unavailable because the tracker has made failed 74 // Network time is unavailable because the tracker has made failed
75 // attempts to retrieve a time from the network, but an attempt is 75 // attempts to retrieve a time from the network, but an attempt is
76 // currently pending. 76 // currently pending.
77 NETWORK_TIME_SUBSEQUENT_SYNC_PENDING, 77 NETWORK_TIME_SUBSEQUENT_SYNC_PENDING,
78 }; 78 };
79 79
80 // Describes the behavior of fetches to the network time service.
81 enum FetchBehavior {
82 // Only used in case of an unrecognize Finch experiment parameter.
83 FETCH_BEHAVIOR_UNKNOWN,
84 // Time queries will be issued in the background as needed.
85 FETCHES_IN_BACKGROUND_ONLY,
86 // Time queries will not be issued except when StartTimeFetch() is called.
87 FETCHES_ON_DEMAND_ONLY,
88 // Time queries will be issued both in the background as needed and also
89 // on-demand.
90 FETCHES_IN_BACKGROUND_AND_ON_DEMAND,
91 };
92
80 static void RegisterPrefs(PrefRegistrySimple* registry); 93 static void RegisterPrefs(PrefRegistrySimple* registry);
81 94
82 // Constructor. Arguments may be stubbed out for tests. |getter|, if not 95 // Constructor. Arguments may be stubbed out for tests. |getter|, if not
83 // null, will cause automatic queries to a time server. Otherwise, time is 96 // null, will cause automatic queries to a time server. Otherwise, time is
84 // available only if |UpdateNetworkTime| is called. 97 // available only if |UpdateNetworkTime| is called.
85 NetworkTimeTracker(std::unique_ptr<base::Clock> clock, 98 NetworkTimeTracker(std::unique_ptr<base::Clock> clock,
86 std::unique_ptr<base::TickClock> tick_clock, 99 std::unique_ptr<base::TickClock> tick_clock,
87 PrefService* pref_service, 100 PrefService* pref_service,
88 scoped_refptr<net::URLRequestContextGetter> getter); 101 scoped_refptr<net::URLRequestContextGetter> getter);
89 ~NetworkTimeTracker() override; 102 ~NetworkTimeTracker() override;
(...skipping 27 matching lines...) Expand all
117 130
118 // Calculates corresponding time ticks according to the given parameters. 131 // Calculates corresponding time ticks according to the given parameters.
119 // The provided |network_time| is precise at the given |resolution| and 132 // The provided |network_time| is precise at the given |resolution| and
120 // represent the time between now and up to |latency| + (now - |post_time|) 133 // represent the time between now and up to |latency| + (now - |post_time|)
121 // ago. 134 // ago.
122 void UpdateNetworkTime(base::Time network_time, 135 void UpdateNetworkTime(base::Time network_time,
123 base::TimeDelta resolution, 136 base::TimeDelta resolution,
124 base::TimeDelta latency, 137 base::TimeDelta latency,
125 base::TimeTicks post_time); 138 base::TimeTicks post_time);
126 139
140 bool AreTimeFetchesEnabled() const;
141 FetchBehavior GetFetchBehavior() const;
142
127 void SetMaxResponseSizeForTesting(size_t limit); 143 void SetMaxResponseSizeForTesting(size_t limit);
128 144
129 void SetPublicKeyForTesting(const base::StringPiece& key); 145 void SetPublicKeyForTesting(const base::StringPiece& key);
130 146
131 void SetTimeServerURLForTesting(const GURL& url); 147 void SetTimeServerURLForTesting(const GURL& url);
132 148
133 GURL GetTimeServerURLForTesting() const; 149 GURL GetTimeServerURLForTesting() const;
134 150
135 bool QueryTimeServiceForTesting(); 151 bool QueryTimeServiceForTesting();
136 152
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 std::vector<base::Closure> fetch_completion_callbacks_; 221 std::vector<base::Closure> fetch_completion_callbacks_;
206 222
207 base::ThreadChecker thread_checker_; 223 base::ThreadChecker thread_checker_;
208 224
209 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker); 225 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker);
210 }; 226 };
211 227
212 } // namespace network_time 228 } // namespace network_time
213 229
214 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_ 230 #endif // COMPONENTS_NETWORK_TIME_NETWORK_TIME_TRACKER_H_
OLDNEW
« no previous file with comments | « components/network_time/network_time_test_utils.cc ('k') | components/network_time/network_time_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698