OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "google_apis/gcm/engine/mcs_client.h" | 5 #include "google_apis/gcm/engine/mcs_client.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // The protobuf of the message itself. | 79 // The protobuf of the message itself. |
80 MCSProto protobuf; | 80 MCSProto protobuf; |
81 }; | 81 }; |
82 | 82 |
83 ReliablePacketInfo::ReliablePacketInfo() | 83 ReliablePacketInfo::ReliablePacketInfo() |
84 : stream_id(0), tag(0) { | 84 : stream_id(0), tag(0) { |
85 } | 85 } |
86 ReliablePacketInfo::~ReliablePacketInfo() {} | 86 ReliablePacketInfo::~ReliablePacketInfo() {} |
87 | 87 |
88 MCSClient::MCSClient(base::Clock* clock, | 88 MCSClient::MCSClient(const std::string& version_string, |
| 89 base::Clock* clock, |
89 ConnectionFactory* connection_factory, | 90 ConnectionFactory* connection_factory, |
90 GCMStore* gcm_store) | 91 GCMStore* gcm_store) |
91 : clock_(clock), | 92 : version_string_(version_string), |
| 93 clock_(clock), |
92 state_(UNINITIALIZED), | 94 state_(UNINITIALIZED), |
93 android_id_(0), | 95 android_id_(0), |
94 security_token_(0), | 96 security_token_(0), |
95 connection_factory_(connection_factory), | 97 connection_factory_(connection_factory), |
96 connection_handler_(NULL), | 98 connection_handler_(NULL), |
97 last_device_to_server_stream_id_received_(0), | 99 last_device_to_server_stream_id_received_(0), |
98 last_server_to_device_stream_id_received_(0), | 100 last_server_to_device_stream_id_received_(0), |
99 stream_id_out_(0), | 101 stream_id_out_(0), |
100 stream_id_in_(0), | 102 stream_id_in_(0), |
101 gcm_store_(gcm_store), | 103 gcm_store_(gcm_store), |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 acked_server_ids_.begin(); | 292 acked_server_ids_.begin(); |
291 iter != acked_server_ids_.end(); ++iter) { | 293 iter != acked_server_ids_.end(); ++iter) { |
292 restored_unackeds_server_ids_.insert(restored_unackeds_server_ids_.end(), | 294 restored_unackeds_server_ids_.insert(restored_unackeds_server_ids_.end(), |
293 iter->second.begin(), | 295 iter->second.begin(), |
294 iter->second.end()); | 296 iter->second.end()); |
295 } | 297 } |
296 acked_server_ids_.clear(); | 298 acked_server_ids_.clear(); |
297 | 299 |
298 // Then build the request, consuming all pending acknowledgments. | 300 // Then build the request, consuming all pending acknowledgments. |
299 request->Swap(BuildLoginRequest( | 301 request->Swap(BuildLoginRequest( |
300 android_id_, security_token_, user_serial_numbers_).get()); | 302 android_id_, |
| 303 security_token_, |
| 304 version_string_, |
| 305 user_serial_numbers_).get()); |
301 for (PersistentIdList::const_iterator iter = | 306 for (PersistentIdList::const_iterator iter = |
302 restored_unackeds_server_ids_.begin(); | 307 restored_unackeds_server_ids_.begin(); |
303 iter != restored_unackeds_server_ids_.end(); ++iter) { | 308 iter != restored_unackeds_server_ids_.end(); ++iter) { |
304 request->add_received_persistent_id(*iter); | 309 request->add_received_persistent_id(*iter); |
305 } | 310 } |
306 acked_server_ids_[stream_id_out_] = restored_unackeds_server_ids_; | 311 acked_server_ids_[stream_id_out_] = restored_unackeds_server_ids_; |
307 restored_unackeds_server_ids_.clear(); | 312 restored_unackeds_server_ids_.clear(); |
308 | 313 |
309 // Push all unacknowledged messages to front of send queue. No need to save | 314 // Push all unacknowledged messages to front of send queue. No need to save |
310 // to RMQ, as all messages that reach this point should already have been | 315 // to RMQ, as all messages that reach this point should already have been |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 data_message_stanza->category(), | 758 data_message_stanza->category(), |
754 data_message_stanza->id(), | 759 data_message_stanza->id(), |
755 status); | 760 status); |
756 } | 761 } |
757 | 762 |
758 void MCSClient::SetGCMStoreForTesting(GCMStore* gcm_store) { | 763 void MCSClient::SetGCMStoreForTesting(GCMStore* gcm_store) { |
759 gcm_store_ = gcm_store; | 764 gcm_store_ = gcm_store; |
760 } | 765 } |
761 | 766 |
762 } // namespace gcm | 767 } // namespace gcm |
OLD | NEW |