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); |
| 150 |
| 151 // Subclass should notify about connection state through |
| 152 // NotifyChannelStateChange. If communication doesn't work and it is possible |
| 153 // that invalidations from server will not reach this client then channel |
| 154 // should call this function with TRANSIENT_INVALIDATION_ERROR. |
| 155 void NotifyChannelStateChange(InvalidatorState invalidator_state); |
| 156 |
148 // Subclass should call DeliverIncomingMessage for message to reach | 157 // Subclass should call DeliverIncomingMessage for message to reach |
149 // invalidations library. | 158 // invalidations library. |
150 bool DeliverIncomingMessage(const std::string& message); | 159 bool DeliverIncomingMessage(const std::string& message); |
151 | 160 |
152 private: | 161 private: |
153 typedef std::vector<invalidation::NetworkStatusCallback*> | 162 typedef std::vector<invalidation::NetworkStatusCallback*> |
154 NetworkStatusReceiverList; | 163 NetworkStatusReceiverList; |
155 | 164 |
156 // Callbacks into invalidation library | 165 // Callbacks into invalidation library |
157 scoped_ptr<invalidation::MessageCallback> incoming_receiver_; | 166 scoped_ptr<invalidation::MessageCallback> incoming_receiver_; |
158 NetworkStatusReceiverList network_status_receivers_; | 167 NetworkStatusReceiverList network_status_receivers_; |
159 | 168 |
160 // Last channel state for new network status receivers. | 169 // Last network status for new network status receivers. |
161 InvalidatorState invalidator_state_; | 170 bool last_network_status_; |
162 | 171 |
163 int received_messages_count_; | 172 int received_messages_count_; |
164 | 173 |
165 ObserverList<Observer> observers_; | 174 ObserverList<Observer> observers_; |
166 }; | 175 }; |
167 | 176 |
168 class SyncStorage : public invalidation::Storage { | 177 class SyncStorage : public invalidation::Storage { |
169 public: | 178 public: |
170 SyncStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); | 179 SyncStorage(StateWriter* state_writer, invalidation::Scheduler* scheduler); |
171 | 180 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; | 241 scoped_ptr<SyncInvalidationScheduler> internal_scheduler_; |
233 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; | 242 scoped_ptr<SyncInvalidationScheduler> listener_scheduler_; |
234 scoped_ptr<SyncStorage> storage_; | 243 scoped_ptr<SyncStorage> storage_; |
235 // sync_network_channel_ is owned by SyncInvalidationListener. | 244 // sync_network_channel_ is owned by SyncInvalidationListener. |
236 SyncNetworkChannel* sync_network_channel_; | 245 SyncNetworkChannel* sync_network_channel_; |
237 }; | 246 }; |
238 | 247 |
239 } // namespace syncer | 248 } // namespace syncer |
240 | 249 |
241 #endif // COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ | 250 #endif // COMPONENTS_INVALIDATION_SYNC_SYSTEM_RESOURCES_H_ |
OLD | NEW |