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 // Simple system resources class that uses the current message loop | 5 // Simple system resources class that uses the current message loop |
6 // for scheduling. Assumes the current message loop is already | 6 // for scheduling. Assumes the current message loop is already |
7 // running. | 7 // running. |
8 | 8 |
9 #ifndef COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ | 9 #ifndef COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ |
10 #define COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ | 10 #define COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 static scoped_ptr<SyncNetworkChannel> CreatePushClientChannel( | 136 static scoped_ptr<SyncNetworkChannel> CreatePushClientChannel( |
137 const notifier::NotifierOptions& notifier_options); | 137 const notifier::NotifierOptions& notifier_options); |
138 static scoped_ptr<SyncNetworkChannel> CreateGCMNetworkChannel( | 138 static scoped_ptr<SyncNetworkChannel> CreateGCMNetworkChannel( |
139 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 139 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
140 scoped_ptr<GCMNetworkChannelDelegate> delegate); | 140 scoped_ptr<GCMNetworkChannelDelegate> delegate); |
141 | 141 |
142 // Get the count of how many valid received messages were received. | 142 // Get the count of how many valid received messages were received. |
143 int GetReceivedMessagesCount() const; | 143 int GetReceivedMessagesCount() const; |
144 | 144 |
145 protected: | 145 protected: |
146 // Subclass should notify about connection state through NotifyStateChange. | 146 // Subclass should call NotifyNetworkStatusChange to notify about network |
147 void NotifyStateChange(InvalidatorState invalidator_state); | 147 // changes. This triggers cacheinvalidation to try resending failed message |
148 // ahead of schedule when client comes online or IP address changes. | |
149 void NotifyNetworkStatusChange(bool online); | |
rlarocque
2014/06/19 16:13:33
nit: Could you add some spacing between these meth
pavely
2014/06/19 17:29:15
Done.
| |
150 // Subclass should notify about connection state through | |
151 // NotifyChannelStateChange. If communication doesn't work and it is possible | |
152 // that invalidations from server will not reach this client then channel | |
153 // should call this function with TRANSIENT_INVALIDATION_ERROR. | |
154 void NotifyChannelStateChange(InvalidatorState invalidator_state); | |
148 // Subclass should call DeliverIncomingMessage for message to reach | 155 // Subclass should call DeliverIncomingMessage for message to reach |
149 // invalidations library. | 156 // invalidations library. |
150 bool DeliverIncomingMessage(const std::string& message); | 157 bool DeliverIncomingMessage(const std::string& message); |
151 | 158 |
152 private: | 159 private: |
153 typedef std::vector<invalidation::NetworkStatusCallback*> | 160 typedef std::vector<invalidation::NetworkStatusCallback*> |
154 NetworkStatusReceiverList; | 161 NetworkStatusReceiverList; |
155 | 162 |
156 // Callbacks into invalidation library | 163 // Callbacks into invalidation library |
157 scoped_ptr<invalidation::MessageCallback> incoming_receiver_; | 164 scoped_ptr<invalidation::MessageCallback> incoming_receiver_; |
158 NetworkStatusReceiverList network_status_receivers_; | 165 NetworkStatusReceiverList network_status_receivers_; |
159 | 166 |
160 // Last channel state for new network status receivers. | 167 // Last network status for new network status receivers. |
161 InvalidatorState invalidator_state_; | 168 bool last_network_status_; |
162 | 169 |
163 int received_messages_count_; | 170 int received_messages_count_; |
164 | 171 |
165 ObserverList<Observer> observers_; | 172 ObserverList<Observer> observers_; |
166 }; | 173 }; |
167 | 174 |
168 class SyncStorage : public invalidation::Storage { | 175 class SyncStorage : public invalidation::Storage { |
169 public: | 176 public: |
170 SyncStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); | 177 SyncStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); |
171 | 178 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; | 239 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; |
233 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; | 240 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; |
234 scoped_ptr<SyncStorage> storage_; | 241 scoped_ptr<SyncStorage> storage_; |
235 // sync_network_channel_ is owned by SyncInvalidationListener. | 242 // sync_network_channel_ is owned by SyncInvalidationListener. |
236 SyncNetworkChannel* sync_network_channel_; | 243 SyncNetworkChannel* sync_network_channel_; |
237 }; | 244 }; |
238 | 245 |
239 } // namespace syncer | 246 } // namespace syncer |
240 | 247 |
241 #endif // COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ | 248 #endif // COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ |
OLD | NEW |