OLD | NEW |
---|---|
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_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 // Syncing with the server for GCM channel status that controls if GCM | 31 // Syncing with the server for GCM channel status that controls if GCM |
32 // functionality should be enabled or disabled. | 32 // functionality should be enabled or disabled. |
33 class GCMChannelStatusSyncer { | 33 class GCMChannelStatusSyncer { |
34 public: | 34 public: |
35 static void RegisterPrefs(PrefRegistrySimple* registry); | 35 static void RegisterPrefs(PrefRegistrySimple* registry); |
36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 36 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
37 | 37 |
38 GCMChannelStatusSyncer( | 38 GCMChannelStatusSyncer( |
39 GCMDriver* driver, | 39 GCMDriver* driver, |
40 PrefService* prefs, | 40 PrefService* prefs, |
41 const std::string& channel_status_request_url, | |
42 const std::string& user_agent, | |
41 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 43 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
42 ~GCMChannelStatusSyncer(); | 44 ~GCMChannelStatusSyncer(); |
43 | 45 |
44 void EnsureStarted(); | 46 void EnsureStarted(); |
45 void Stop(); | 47 void Stop(); |
46 | 48 |
47 bool gcm_enabled() const { return gcm_enabled_; } | 49 bool gcm_enabled() const { return gcm_enabled_; } |
48 | 50 |
49 // For testing purpose. | 51 // For testing purpose. |
50 void set_delay_removed_for_testing(bool delay_removed) { | 52 void set_delay_removed_for_testing(bool delay_removed) { |
(...skipping 14 matching lines...) Expand all Loading... | |
65 // Creates and starts a request immediately. | 67 // Creates and starts a request immediately. |
66 void StartRequest(); | 68 void StartRequest(); |
67 | 69 |
68 // Computes and returns a delay with the fuzzing variation added if needed, | 70 // Computes and returns a delay with the fuzzing variation added if needed, |
69 // after which the request could start. | 71 // after which the request could start. |
70 base::TimeDelta GetRequestDelayInterval() const; | 72 base::TimeDelta GetRequestDelayInterval() const; |
71 | 73 |
72 // GCMDriver owns GCMChannelStatusSyncer instance. | 74 // GCMDriver owns GCMChannelStatusSyncer instance. |
73 GCMDriver* driver_; | 75 GCMDriver* driver_; |
74 PrefService* prefs_; | 76 PrefService* prefs_; |
77 std::string channel_status_request_url_; | |
Nicolas Zea
2014/10/08 00:40:41
nit: make both const
fgorski
2014/10/08 16:55:17
Done.
| |
78 std::string user_agent_; | |
75 | 79 |
76 scoped_refptr<net::URLRequestContextGetter> request_context_; | 80 scoped_refptr<net::URLRequestContextGetter> request_context_; |
77 scoped_ptr<GCMChannelStatusRequest> request_; | 81 scoped_ptr<GCMChannelStatusRequest> request_; |
78 | 82 |
79 bool gcm_enabled_; | 83 bool gcm_enabled_; |
80 int poll_interval_seconds_; | 84 int poll_interval_seconds_; |
81 base::Time last_check_time_; | 85 base::Time last_check_time_; |
82 | 86 |
83 // The flag that indicates if the delay, including fuzzing variation and poll | 87 // The flag that indicates if the delay, including fuzzing variation and poll |
84 // interval, is removed for testing purpose. | 88 // interval, is removed for testing purpose. |
85 bool delay_removed_for_testing_; | 89 bool delay_removed_for_testing_; |
86 | 90 |
87 // Tracked for testing purpose. | 91 // Tracked for testing purpose. |
88 base::TimeDelta current_request_delay_interval_; | 92 base::TimeDelta current_request_delay_interval_; |
89 | 93 |
90 // Used to pass a weak pointer to a task. | 94 // Used to pass a weak pointer to a task. |
91 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_; | 95 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_; |
92 | 96 |
93 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer); | 97 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer); |
94 }; | 98 }; |
95 | 99 |
96 } // namespace gcm | 100 } // namespace gcm |
97 | 101 |
98 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ | 102 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ |
OLD | NEW |