| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void set_delay_removed_for_testing(bool delay_removed) { | 52 void set_delay_removed_for_testing(bool delay_removed) { |
| 53 delay_removed_for_testing_ = delay_removed; | 53 delay_removed_for_testing_ = delay_removed; |
| 54 } | 54 } |
| 55 base::TimeDelta current_request_delay_interval() const { | 55 base::TimeDelta current_request_delay_interval() const { |
| 56 return current_request_delay_interval_; | 56 return current_request_delay_interval_; |
| 57 } | 57 } |
| 58 static int first_time_delay_seconds(); | 58 static int first_time_delay_seconds(); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 // Called when a request is completed. | 61 // Called when a request is completed. |
| 62 void OnRequestCompleted(bool enabled, int poll_interval_seconds); | 62 void OnRequestCompleted(bool update_received, |
| 63 bool enabled, |
| 64 int poll_interval_seconds); |
| 63 | 65 |
| 64 // Schedules next request to start after appropriate delay. | 66 // Schedules next request to start after appropriate delay. |
| 65 void ScheduleRequest(); | 67 void ScheduleRequest(); |
| 66 | 68 |
| 67 // Creates and starts a request immediately. | 69 // Creates and starts a request immediately. |
| 68 void StartRequest(); | 70 void StartRequest(); |
| 69 | 71 |
| 70 // Computes and returns a delay with the fuzzing variation added if needed, | 72 // Computes and returns a delay with the fuzzing variation added if needed, |
| 71 // after which the request could start. | 73 // after which the request could start. |
| 72 base::TimeDelta GetRequestDelayInterval() const; | 74 base::TimeDelta GetRequestDelayInterval() const; |
| 73 | 75 |
| 74 // GCMDriver owns GCMChannelStatusSyncer instance. | 76 // GCMDriver owns GCMChannelStatusSyncer instance. |
| 75 GCMDriver* driver_; | 77 GCMDriver* driver_; |
| 76 PrefService* prefs_; | 78 PrefService* prefs_; |
| 77 const std::string channel_status_request_url_; | 79 const std::string channel_status_request_url_; |
| 78 const std::string user_agent_; | 80 const std::string user_agent_; |
| 79 | 81 |
| 80 scoped_refptr<net::URLRequestContextGetter> request_context_; | 82 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 81 scoped_ptr<GCMChannelStatusRequest> request_; | 83 scoped_ptr<GCMChannelStatusRequest> request_; |
| 82 | 84 |
| 83 bool gcm_enabled_; | 85 bool gcm_enabled_; |
| 84 int poll_interval_seconds_; | 86 int poll_interval_seconds_; |
| 85 base::Time last_check_time_; | 87 base::Time last_check_time_; |
| 86 | 88 |
| 89 // If non-zero, |poll_interval_seconds_| is overriden by the command line |
| 90 // options for testing purpose. Each time when the custom poll interval is |
| 91 // used, this count is subtracted by one. When it reaches zero, the default |
| 92 // poll interval will be used instead. |
| 93 int custom_poll_interval_use_count_; |
| 94 |
| 87 // The flag that indicates if the delay, including fuzzing variation and poll | 95 // The flag that indicates if the delay, including fuzzing variation and poll |
| 88 // interval, is removed for testing purpose. | 96 // interval, is removed for testing purpose. |
| 89 bool delay_removed_for_testing_; | 97 bool delay_removed_for_testing_; |
| 90 | 98 |
| 91 // Tracked for testing purpose. | 99 // Tracked for testing purpose. |
| 92 base::TimeDelta current_request_delay_interval_; | 100 base::TimeDelta current_request_delay_interval_; |
| 93 | 101 |
| 94 // Used to pass a weak pointer to a task. | 102 // Used to pass a weak pointer to a task. |
| 95 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_; | 103 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_; |
| 96 | 104 |
| 97 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer); | 105 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer); |
| 98 }; | 106 }; |
| 99 | 107 |
| 100 } // namespace gcm | 108 } // namespace gcm |
| 101 | 109 |
| 102 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ | 110 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ |
| OLD | NEW |