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

Side by Side Diff: google_apis/gcm/gcm_client_impl.cc

Issue 183013007: [GCM] Stop/restart GCM when the state is forced off/on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 6 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('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/gcm_client_impl.h" 5 #include "google_apis/gcm/gcm_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // TODO(fgorski): Reset the checkin timer. 279 // TODO(fgorski): Reset the checkin timer.
280 } 280 }
281 } 281 }
282 } 282 }
283 283
284 void GCMClientImpl::SetDeviceCredentialsCallback(bool success) { 284 void GCMClientImpl::SetDeviceCredentialsCallback(bool success) {
285 // TODO(fgorski): This is one of the signals that store needs a rebuild. 285 // TODO(fgorski): This is one of the signals that store needs a rebuild.
286 DCHECK(success); 286 DCHECK(success);
287 } 287 }
288 288
289 void GCMClientImpl::CheckOut() { 289 void GCMClientImpl::Stop() {
290 device_checkin_info_.Reset(); 290 device_checkin_info_.Reset();
291 mcs_client_.reset(); 291 mcs_client_.reset();
292 gcm_store_->Destroy(base::Bind(&GCMClientImpl::OnGCMStoreDestroyed,
293 weak_ptr_factory_.GetWeakPtr()));
294 checkin_request_.reset(); 292 checkin_request_.reset();
295 pending_registrations_.clear(); 293 pending_registrations_.clear();
296 state_ = INITIALIZED; 294 state_ = INITIALIZED;
295 gcm_store_->Close();
296 }
297
298 void GCMClientImpl::CheckOut() {
299 Stop();
300 gcm_store_->Destroy(base::Bind(&GCMClientImpl::OnGCMStoreDestroyed,
301 weak_ptr_factory_.GetWeakPtr()));
297 } 302 }
298 303
299 void GCMClientImpl::Register(const std::string& app_id, 304 void GCMClientImpl::Register(const std::string& app_id,
300 const std::string& cert, 305 const std::string& cert,
301 const std::vector<std::string>& sender_ids) { 306 const std::vector<std::string>& sender_ids) {
302 DCHECK_EQ(state_, READY); 307 DCHECK_EQ(state_, READY);
303 RegistrationRequest::RequestInfo request_info( 308 RegistrationRequest::RequestInfo request_info(
304 device_checkin_info_.android_id, 309 device_checkin_info_.android_id,
305 device_checkin_info_.secret, 310 device_checkin_info_.secret,
306 app_id, 311 app_id,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 if (iter != incoming_message.data.end()) 510 if (iter != incoming_message.data.end())
506 message_id = iter->second; 511 message_id = iter->second;
507 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); 512 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR);
508 } 513 }
509 514
510 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { 515 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) {
511 mcs_client_ = mcs_client.Pass(); 516 mcs_client_ = mcs_client.Pass();
512 } 517 }
513 518
514 } // namespace gcm 519 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698