Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: google_apis/gcm/engine/mcs_client.cc

Issue 793883003: [GCM] Fix gcm network change handling before connect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix leak Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « google_apis/gcm/engine/connection_factory_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/connection_factory_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698