| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 DCHECK(android_id_ == 0 || android_id_ == android_id); | 197 DCHECK(android_id_ == 0 || android_id_ == android_id); |
| 198 DCHECK(security_token_ == 0 || security_token_ == security_token); | 198 DCHECK(security_token_ == 0 || security_token_ == security_token); |
| 199 | 199 |
| 200 if (android_id != android_id_ && security_token != security_token_) { | 200 if (android_id != android_id_ && security_token != security_token_) { |
| 201 DCHECK(android_id); | 201 DCHECK(android_id); |
| 202 DCHECK(security_token); | 202 DCHECK(security_token); |
| 203 android_id_ = android_id; | 203 android_id_ = android_id; |
| 204 security_token_ = security_token; | 204 security_token_ = security_token; |
| 205 } | 205 } |
| 206 | 206 |
| 207 DCHECK(android_id_ != 0 || restored_unackeds_server_ids_.empty()); |
| 208 |
| 207 state_ = CONNECTING; | 209 state_ = CONNECTING; |
| 208 connection_factory_->Connect(); | 210 connection_factory_->Connect(); |
| 209 DCHECK(restored_unackeds_server_ids_.empty()); | |
| 210 } | 211 } |
| 211 | 212 |
| 212 void MCSClient::SendMessage(const MCSMessage& message) { | 213 void MCSClient::SendMessage(const MCSMessage& message) { |
| 213 int ttl = GetTTL(message.GetProtobuf()); | 214 int ttl = GetTTL(message.GetProtobuf()); |
| 214 DCHECK_GE(ttl, 0); | 215 DCHECK_GE(ttl, 0); |
| 215 if (to_send_.size() > kMaxSendQueueSize) { | 216 if (to_send_.size() > kMaxSendQueueSize) { |
| 216 NotifyMessageSendStatus(message.GetProtobuf(), QUEUE_SIZE_LIMIT_REACHED); | 217 NotifyMessageSendStatus(message.GetProtobuf(), QUEUE_SIZE_LIMIT_REACHED); |
| 217 return; | 218 return; |
| 218 } | 219 } |
| 219 if (message.size() > kMaxMessageBytes) { | 220 if (message.size() > kMaxMessageBytes) { |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 const mcs_proto::DataMessageStanza* data_message_stanza = | 739 const mcs_proto::DataMessageStanza* data_message_stanza = |
| 739 reinterpret_cast<const mcs_proto::DataMessageStanza*>(&protobuf); | 740 reinterpret_cast<const mcs_proto::DataMessageStanza*>(&protobuf); |
| 740 message_sent_callback_.Run( | 741 message_sent_callback_.Run( |
| 741 data_message_stanza->device_user_id(), | 742 data_message_stanza->device_user_id(), |
| 742 data_message_stanza->category(), | 743 data_message_stanza->category(), |
| 743 data_message_stanza->id(), | 744 data_message_stanza->id(), |
| 744 status); | 745 status); |
| 745 } | 746 } |
| 746 | 747 |
| 747 } // namespace gcm | 748 } // namespace gcm |
| OLD | NEW |