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

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

Issue 745123002: Link GCM heartbeat with wake on wifi preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing include 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/mcs_client.h ('k') | google_apis/gcm/engine/mcs_client_unittest.cc » ('j') | 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 default: 152 default:
153 NOTREACHED(); 153 NOTREACHED();
154 return std::string(); 154 return std::string();
155 } 155 }
156 } 156 }
157 157
158 MCSClient::MCSClient(const std::string& version_string, 158 MCSClient::MCSClient(const std::string& version_string,
159 base::Clock* clock, 159 base::Clock* clock,
160 ConnectionFactory* connection_factory, 160 ConnectionFactory* connection_factory,
161 GCMStore* gcm_store, 161 GCMStore* gcm_store,
162 GCMStatsRecorder* recorder, 162 GCMStatsRecorder* recorder)
163 scoped_ptr<base::Timer> heartbeat_timer)
164 : version_string_(version_string), 163 : version_string_(version_string),
165 clock_(clock), 164 clock_(clock),
166 state_(UNINITIALIZED), 165 state_(UNINITIALIZED),
167 android_id_(0), 166 android_id_(0),
168 security_token_(0), 167 security_token_(0),
169 connection_factory_(connection_factory), 168 connection_factory_(connection_factory),
170 connection_handler_(NULL), 169 connection_handler_(NULL),
171 last_device_to_server_stream_id_received_(0), 170 last_device_to_server_stream_id_received_(0),
172 last_server_to_device_stream_id_received_(0), 171 last_server_to_device_stream_id_received_(0),
173 stream_id_out_(0), 172 stream_id_out_(0),
174 stream_id_in_(0), 173 stream_id_in_(0),
175 gcm_store_(gcm_store), 174 gcm_store_(gcm_store),
176 heartbeat_manager_(heartbeat_timer.Pass()),
177 recorder_(recorder), 175 recorder_(recorder),
178 weak_ptr_factory_(this) { 176 weak_ptr_factory_(this) {
179 } 177 }
180 178
181 MCSClient::~MCSClient() { 179 MCSClient::~MCSClient() {
182 } 180 }
183 181
184 void MCSClient::Initialize( 182 void MCSClient::Initialize(
185 const ErrorCallback& error_callback, 183 const ErrorCallback& error_callback,
186 const OnMessageReceivedCallback& message_received_callback, 184 const OnMessageReceivedCallback& message_received_callback,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 359
362 to_send_.push_back(make_linked_ptr(packet_info.release())); 360 to_send_.push_back(make_linked_ptr(packet_info.release()));
363 361
364 // Notify that the messages has been succsfully queued for sending. 362 // Notify that the messages has been succsfully queued for sending.
365 // TODO(jianli): We should report QUEUED after writing to GCM store succeeds. 363 // TODO(jianli): We should report QUEUED after writing to GCM store succeeds.
366 NotifyMessageSendStatus(message.GetProtobuf(), QUEUED); 364 NotifyMessageSendStatus(message.GetProtobuf(), QUEUED);
367 365
368 MaybeSendMessage(); 366 MaybeSendMessage();
369 } 367 }
370 368
369 void MCSClient::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) {
370 heartbeat_manager_.UpdateHeartbeatTimer(timer.Pass());
371 }
372
371 void MCSClient::ResetStateAndBuildLoginRequest( 373 void MCSClient::ResetStateAndBuildLoginRequest(
372 mcs_proto::LoginRequest* request) { 374 mcs_proto::LoginRequest* request) {
373 DCHECK(android_id_); 375 DCHECK(android_id_);
374 DCHECK(security_token_); 376 DCHECK(security_token_);
375 stream_id_in_ = 0; 377 stream_id_in_ = 0;
376 stream_id_out_ = 1; 378 stream_id_out_ = 1;
377 last_device_to_server_stream_id_received_ = 0; 379 last_device_to_server_stream_id_received_ = 0;
378 last_server_to_device_stream_id_received_ = 0; 380 last_server_to_device_stream_id_received_ = 0;
379 381
380 heartbeat_manager_.Stop(); 382 heartbeat_manager_.Stop();
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get()); 903 reinterpret_cast<mcs_proto::DataMessageStanza*>(packet->protobuf.get());
902 CollapseKey collapse_key(*data_message); 904 CollapseKey collapse_key(*data_message);
903 if (collapse_key.IsValid()) 905 if (collapse_key.IsValid())
904 collapse_key_map_.erase(collapse_key); 906 collapse_key_map_.erase(collapse_key);
905 } 907 }
906 908
907 return packet; 909 return packet;
908 } 910 }
909 911
910 } // namespace gcm 912 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/mcs_client.h ('k') | google_apis/gcm/engine/mcs_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698