OLD | NEW |
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_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ |
6 #define CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ | 6 #define CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
11 | 11 |
12 class NetworkTimeTracker; | |
13 class Profile; | 12 class Profile; |
14 | 13 |
15 namespace user_prefs { | 14 namespace user_prefs { |
16 class PrefRegistrySyncable; | 15 class PrefRegistrySyncable; |
17 } | 16 } |
18 | 17 |
19 // NetworkTimeService can convert local time to network time. | 18 // NetworkTimeService can convert local time to network time. |
20 class NetworkTimeService : public KeyedService { | 19 class NetworkTimeService : public KeyedService { |
21 public: | 20 public: |
22 explicit NetworkTimeService(Profile* profile); | 21 explicit NetworkTimeService(Profile* profile); |
23 virtual ~NetworkTimeService(); | 22 virtual ~NetworkTimeService(); |
24 | 23 |
25 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 24 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
26 | 25 |
27 // Return network time corresponding to |local_time| if possible. Return | 26 // Return network time corresponding to |local_time| if possible. Return |
28 // |local_time| otherwise. | 27 // |local_time| otherwise. |
29 base::Time GetNetworkTime(const base::Time& local_time); | 28 base::Time GetNetworkTime(const base::Time& local_time); |
30 | 29 |
31 // Shortcut to get current time. | 30 // Shortcut to get current time. |
32 base::Time GetNetworkNow(); | 31 base::Time GetNetworkNow(); |
33 | 32 |
34 virtual void Shutdown() OVERRIDE; | 33 virtual void Shutdown() OVERRIDE; |
35 | 34 |
36 private: | 35 private: |
37 Profile* profile_; | 36 Profile* profile_; |
38 scoped_ptr<NetworkTimeTracker> network_time_tracker_; | |
39 }; | 37 }; |
40 | 38 |
41 #endif // CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ | 39 #endif // CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_ |
OLD | NEW |