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

Side by Side Diff: components/gcm_driver/gcm_channel_status_syncer.h

Issue 653843003: [GCM] Start GCMChannelStatusSyncer when GCM is disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for GCM not reenabled after being disabled on the fly Created 6 years, 2 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
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
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
85 bool started_;
83 bool gcm_enabled_; 86 bool gcm_enabled_;
84 int poll_interval_seconds_; 87 int poll_interval_seconds_;
85 base::Time last_check_time_; 88 base::Time last_check_time_;
86 89
90 // If non-zero, |poll_interval_seconds_| is overriden by the command line
91 // options for testing purpose. Each time when the custom poll interval is
92 // used, this count is subtracted by one. When it reaches zero, the default
93 // poll interval will be used instead.
94 int custom_poll_interval_use_count_;
95
87 // The flag that indicates if the delay, including fuzzing variation and poll 96 // The flag that indicates if the delay, including fuzzing variation and poll
88 // interval, is removed for testing purpose. 97 // interval, is removed for testing purpose.
89 bool delay_removed_for_testing_; 98 bool delay_removed_for_testing_;
90 99
91 // Tracked for testing purpose. 100 // Tracked for testing purpose.
92 base::TimeDelta current_request_delay_interval_; 101 base::TimeDelta current_request_delay_interval_;
93 102
94 // Used to pass a weak pointer to a task. 103 // Used to pass a weak pointer to a task.
95 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_; 104 base::WeakPtrFactory<GCMChannelStatusSyncer> weak_ptr_factory_;
96 105
97 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer); 106 DISALLOW_COPY_AND_ASSIGN(GCMChannelStatusSyncer);
98 }; 107 };
99 108
100 } // namespace gcm 109 } // namespace gcm
101 110
102 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_ 111 #endif // COMPONENTS_GCM_DRIVER_GCM_CHANNEL_STATUS_SYNCER_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_request_unittest.cc ('k') | components/gcm_driver/gcm_channel_status_syncer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698