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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_
6 #define CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
12 class NetworkTimeTracker
;
15 namespace user_prefs
{
16 class PrefRegistrySyncable
;
19 // NetworkTimeService can convert local time to network time.
20 class NetworkTimeService
: public BrowserContextKeyedService
{
22 explicit NetworkTimeService(Profile
* profile
);
23 virtual ~NetworkTimeService();
25 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
27 // Return network time corresponding to |local_time| if possible. Return
28 // |local_time| otherwise.
29 base::Time
GetNetworkTime(const base::Time
& local_time
);
31 // Shortcut to get current time.
32 base::Time
GetNetworkNow();
34 virtual void Shutdown() OVERRIDE
;
38 scoped_ptr
<NetworkTimeTracker
> network_time_tracker_
;
41 #endif // CHROME_BROWSER_NETWORK_TIME_NETWORK_TIME_SERVICE_H_