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

Side by Side Diff: chrome/browser/metrics/variations/network_time_tracker.h

Issue 12096096: Give access to a network time kept in the variation service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final nits. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/metrics/variations/network_time_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_VARIATIONS_NETWORK_TIME_TRACKER_H_
6 #define CHROME_BROWSER_METRICS_VARIATIONS_NETWORK_TIME_TRACKER_H_
7
8 #include "base/time.h"
9
10 // A class that tracks time based on a provided network time, using system's
11 // tick time to properly offset it, and also provide uncertainty.
12 class NetworkTimeTracker {
13 public:
14 NetworkTimeTracker();
15 virtual ~NetworkTimeTracker();
16
17 // Returns a network time based on values provided to UpdateNetworkTime and
18 // CPU ticks count since then. Returns false if no network time is available
19 // yet. Can also return the error range if |uncertainty| isn't NULL.
20 bool GetNetworkTime(base::Time* network_time,
21 base::TimeDelta* uncertainty) const;
22
23 // The provided |network_time| is precise at the given |resolution| and
24 // represent the time between now and up to |latency| ago.
25 void UpdateNetworkTime(const base::Time& network_time,
26 const base::TimeDelta& resolution,
27 const base::TimeDelta& latency);
28 protected:
29 // Used for a derviced test class to mock the current CPU ticks time.
30 virtual base::TimeTicks GetTicksNow() const;
31
32 private:
33 // Returns true in NDEBUG, and validate time tracking when NDEBUG isn't
34 // defined, returning FALSE if the network time has drifted too far.
35 bool ValidateTimeTracking(const base::Time& new_network_time,
36 const base::TimeDelta& resolution,
37 const base::TimeDelta& latency);
38
39 // Remember the network time based on last call to UpdateNetworkTime().
40 base::Time network_time_;
41
42 // The estimated ticks count when |network_time_| was set based on the
43 // system's tick count.
44 base::TimeTicks network_time_ticks_;
45
46 // Uncertainty of |network_time_| based on added inaccuracies/resolution.
47 base::TimeDelta network_time_uncertainty_;
48
49 DISALLOW_COPY_AND_ASSIGN(NetworkTimeTracker);
50 };
51
52 #endif // CHROME_BROWSER_METRICS_VARIATIONS_NETWORK_TIME_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/variations/network_time_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698