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

Side by Side Diff: chromeos/timezone/timezone_resolver.h

Issue 834073002: ChromeOS: Implement periodic timezone refresh on geolocation data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 5 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_
6 #define CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/threading/thread_checker.h"
11 #include "chromeos/chromeos_export.h"
12 #include "url/gurl.h"
13
14 class PrefRegistrySimple;
15
16 namespace net {
17 class URLRequestContextGetter;
18 }
19
20 namespace chromeos {
21
22 struct TimeZoneResponseData;
23
24 // This class implements periodic timezone synchronization.
Dmitry Polukhin 2015/01/20 15:32:28 Please describe logic how periodic refresh happens
25 class CHROMEOS_EXPORT TimeZoneResolver {
26 public:
27 class TimeZoneResolverImpl;
28
29 // This callback will be called when new timezone arrives.
30 typedef base::Callback<void(const TimeZoneResponseData*)>
31 ApplyTimeZoneCallback;
32
33 // chromeos::DelayNetworkCall cannot be used directly due to link
34 // restrictions.
35 typedef base::Callback<void(const base::Closure&)> DelayNetworkCallClosure;
36
37 TimeZoneResolver(net::URLRequestContextGetter* context,
38 const GURL& url,
39 const ApplyTimeZoneCallback& apply_timezone,
40 const DelayNetworkCallClosure& delay_network_call);
41 ~TimeZoneResolver();
42
43 // Starts periodic timezone refresh.
44 void Start();
45
46 // Cancels current request and stops periodic timezone refresh.
47 void Stop();
48
49 // Expose internal fuctions for testing.
50 static int MaxRequestsCountForIntervalForTesting(
51 const double interval_seconds);
52 static int IntervalForNextRequestForTesting(const int requests);
53
54 private:
55 net::URLRequestContextGetter* const context_;
56 const GURL url_;
57
58 const ApplyTimeZoneCallback apply_timezone_;
59 const DelayNetworkCallClosure delay_network_call_;
60
61 scoped_ptr<TimeZoneResolverImpl> implementation_;
62
63 base::ThreadChecker thread_checker_;
64
65 DISALLOW_COPY_AND_ASSIGN(TimeZoneResolver);
66 };
67
68 } // namespace chromeos
69
70 #endif // CHROMEOS_TIMEZONE_TIMEZONE_RESOLVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698