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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 message_received_callback_ = message_received_callback; | 191 message_received_callback_ = message_received_callback; |
192 message_sent_callback_ = message_sent_callback; | 192 message_sent_callback_ = message_sent_callback; |
193 | 193 |
194 connection_factory_->Initialize( | 194 connection_factory_->Initialize( |
195 base::Bind(&MCSClient::ResetStateAndBuildLoginRequest, | 195 base::Bind(&MCSClient::ResetStateAndBuildLoginRequest, |
196 weak_ptr_factory_.GetWeakPtr()), | 196 weak_ptr_factory_.GetWeakPtr()), |
197 base::Bind(&MCSClient::HandlePacketFromWire, | 197 base::Bind(&MCSClient::HandlePacketFromWire, |
198 weak_ptr_factory_.GetWeakPtr()), | 198 weak_ptr_factory_.GetWeakPtr()), |
199 base::Bind(&MCSClient::MaybeSendMessage, | 199 base::Bind(&MCSClient::MaybeSendMessage, |
200 weak_ptr_factory_.GetWeakPtr())); | 200 weak_ptr_factory_.GetWeakPtr())); |
201 connection_handler_ = connection_factory_->GetConnectionHandler(); | |
202 | 201 |
203 stream_id_out_ = 1; // Login request is hardcoded to id 1. | 202 stream_id_out_ = 1; // Login request is hardcoded to id 1. |
204 | 203 |
205 android_id_ = load_result->device_android_id; | 204 android_id_ = load_result->device_android_id; |
206 security_token_ = load_result->device_security_token; | 205 security_token_ = load_result->device_security_token; |
207 | 206 |
208 if (android_id_ == 0) { | 207 if (android_id_ == 0) { |
209 DVLOG(1) << "No device credentials found, assuming new client."; | 208 DVLOG(1) << "No device credentials found, assuming new client."; |
210 // No need to try and load RMQ data in that case. | 209 // No need to try and load RMQ data in that case. |
211 return; | 210 return; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 DCHECK(android_id); | 283 DCHECK(android_id); |
285 DCHECK(security_token); | 284 DCHECK(security_token); |
286 android_id_ = android_id; | 285 android_id_ = android_id; |
287 security_token_ = security_token; | 286 security_token_ = security_token; |
288 } | 287 } |
289 | 288 |
290 DCHECK(android_id_ != 0 || restored_unackeds_server_ids_.empty()); | 289 DCHECK(android_id_ != 0 || restored_unackeds_server_ids_.empty()); |
291 | 290 |
292 state_ = CONNECTING; | 291 state_ = CONNECTING; |
293 connection_factory_->Connect(); | 292 connection_factory_->Connect(); |
| 293 connection_handler_ = connection_factory_->GetConnectionHandler(); |
294 } | 294 } |
295 | 295 |
296 void MCSClient::SendMessage(const MCSMessage& message) { | 296 void MCSClient::SendMessage(const MCSMessage& message) { |
297 int ttl = GetTTL(message.GetProtobuf()); | 297 int ttl = GetTTL(message.GetProtobuf()); |
298 DCHECK_GE(ttl, 0); | 298 DCHECK_GE(ttl, 0); |
299 if (to_send_.size() > kMaxSendQueueSize) { | 299 if (to_send_.size() > kMaxSendQueueSize) { |
300 NotifyMessageSendStatus(message.GetProtobuf(), QUEUE_SIZE_LIMIT_REACHED); | 300 NotifyMessageSendStatus(message.GetProtobuf(), QUEUE_SIZE_LIMIT_REACHED); |
301 return; | 301 return; |
302 } | 302 } |
303 if (message.size() > kMaxMessageBytes) { | 303 if (message.size() > kMaxMessageBytes) { |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get()); | 903 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get()); |
904 CollapseKey collapse_key(*data_message); | 904 CollapseKey collapse_key(*data_message); |
905 if (collapse_key.IsValid()) | 905 if (collapse_key.IsValid()) |
906 collapse_key_map_.erase(collapse_key); | 906 collapse_key_map_.erase(collapse_key); |
907 } | 907 } |
908 | 908 |
909 return packet; | 909 return packet; |
910 } | 910 } |
911 | 911 |
912 } // namespace gcm | 912 } // namespace gcm |
OLD | NEW |