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

Side by Side Diff: components/gcm_driver/gcm_client_impl.cc

Issue 1126233004: Persist Instance ID data to GCM store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/gcm_driver/gcm_client_impl.h" 5 #include "components/gcm_driver/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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts; 341 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts;
342 // A case where there were previously no accounts reported with checkin is 342 // A case where there were previously no accounts reported with checkin is
343 // considered to be the same as when the list of accounts is empty. It enables 343 // considered to be the same as when the list of accounts is empty. It enables
344 // scheduling a periodic checkin for devices with no signed in users 344 // scheduling a periodic checkin for devices with no signed in users
345 // immediately after restart, while keeping |accounts_set == false| delays the 345 // immediately after restart, while keeping |accounts_set == false| delays the
346 // checkin until the list of accounts is set explicitly. 346 // checkin until the list of accounts is set explicitly.
347 if (result->last_checkin_accounts.size() == 0) 347 if (result->last_checkin_accounts.size() == 0)
348 device_checkin_info_.accounts_set = true; 348 device_checkin_info_.accounts_set = true;
349 last_checkin_time_ = result->last_checkin_time; 349 last_checkin_time_ = result->last_checkin_time;
350 gservices_settings_.UpdateFromLoadResult(*result); 350 gservices_settings_.UpdateFromLoadResult(*result);
351 instance_id_data_ = result->instance_id_data;
351 load_result_ = result.Pass(); 352 load_result_ = result.Pass();
352 state_ = LOADED; 353 state_ = LOADED;
353 354
354 // Don't initiate the GCM connection when GCM is in delayed start mode and 355 // Don't initiate the GCM connection when GCM is in delayed start mode and
355 // not any standalone app has registered GCM yet. 356 // not any standalone app has registered GCM yet.
356 if (start_mode_ == DELAYED_START && !HasStandaloneRegisteredApp()) 357 if (start_mode_ == DELAYED_START && !HasStandaloneRegisteredApp())
357 return; 358 return;
358 359
359 StartGCM(); 360 StartGCM();
360 } 361 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 time, 524 time,
524 base::Bind(&GCMClientImpl::IgnoreWriteResultCallback, 525 base::Bind(&GCMClientImpl::IgnoreWriteResultCallback,
525 weak_ptr_factory_.GetWeakPtr())); 526 weak_ptr_factory_.GetWeakPtr()));
526 } 527 }
527 528
528 void GCMClientImpl::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) { 529 void GCMClientImpl::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) {
529 DCHECK(mcs_client_); 530 DCHECK(mcs_client_);
530 mcs_client_->UpdateHeartbeatTimer(timer.Pass()); 531 mcs_client_->UpdateHeartbeatTimer(timer.Pass());
531 } 532 }
532 533
534 void GCMClientImpl::AddInstanceIDData(const std::string& app_id,
535 const std::string& instance_id_data) {
fgorski 2015/05/08 17:12:33 Also add to the instance_id_data_
jianli 2015/05/08 20:56:01 Done.
536 gcm_store_->AddInstanceIDData(
537 app_id,
538 instance_id_data,
539 base::Bind(&GCMClientImpl::IgnoreWriteResultCallback,
540 weak_ptr_factory_.GetWeakPtr()));
541 }
542
543 void GCMClientImpl::RemoveInstanceIDData(const std::string& app_id) {
fgorski 2015/05/08 17:12:33 remove from instance ID data_ This and above coul
jianli 2015/05/08 20:56:01 Done.
544 gcm_store_->RemoveInstanceIDData(
545 app_id,
546 base::Bind(&GCMClientImpl::IgnoreWriteResultCallback,
547 weak_ptr_factory_.GetWeakPtr()));
548 }
549
550 std::string GCMClientImpl::GetInstanceIDData(const std::string& app_id) {
551 auto iter = instance_id_data_.find(app_id);
552 if (iter == instance_id_data_.cend())
553 return std::string();
554 return iter->second;
555 }
556
533 void GCMClientImpl::StartCheckin() { 557 void GCMClientImpl::StartCheckin() {
534 // Make sure no checkin is in progress. 558 // Make sure no checkin is in progress.
535 if (checkin_request_.get()) 559 if (checkin_request_.get())
536 return; 560 return;
537 561
538 checkin_proto::ChromeBuildProto chrome_build_proto; 562 checkin_proto::ChromeBuildProto chrome_build_proto;
539 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto); 563 ToCheckinProtoVersion(chrome_build_info_, &chrome_build_proto);
540 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id, 564 CheckinRequest::RequestInfo request_info(device_checkin_info_.android_id,
541 device_checkin_info_.secret, 565 device_checkin_info_.secret,
542 device_checkin_info_.account_tokens, 566 device_checkin_info_.account_tokens,
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 bool GCMClientImpl::HasStandaloneRegisteredApp() const { 1083 bool GCMClientImpl::HasStandaloneRegisteredApp() const {
1060 if (registrations_.empty()) 1084 if (registrations_.empty())
1061 return false; 1085 return false;
1062 // Note that account mapper is not counted as a standalone app since it is 1086 // Note that account mapper is not counted as a standalone app since it is
1063 // automatically started when other app uses GCM. 1087 // automatically started when other app uses GCM.
1064 return registrations_.size() > 1 || 1088 return registrations_.size() > 1 ||
1065 !registrations_.count(kGCMAccountMapperAppId); 1089 !registrations_.count(kGCMAccountMapperAppId);
1066 } 1090 }
1067 1091
1068 } // namespace gcm 1092 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698