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

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

Issue 600053002: [GCM] Loading the account mappings from store to the driver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing account mapper from BUILD.gn android section Created 6 years, 2 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts; 314 device_checkin_info_.last_checkin_accounts = result->last_checkin_accounts;
315 // A case where there were previously no accounts reported with checkin is 315 // A case where there were previously no accounts reported with checkin is
316 // considered to be the same as when the list of accounts is empty. It enables 316 // considered to be the same as when the list of accounts is empty. It enables
317 // scheduling a periodic checkin for devices with no signed in users 317 // scheduling a periodic checkin for devices with no signed in users
318 // immediately after restart, while keeping |accounts_set == false| delays the 318 // immediately after restart, while keeping |accounts_set == false| delays the
319 // checkin until the list of accounts is set explicitly. 319 // checkin until the list of accounts is set explicitly.
320 if (result->last_checkin_accounts.size() == 0) 320 if (result->last_checkin_accounts.size() == 0)
321 device_checkin_info_.accounts_set = true; 321 device_checkin_info_.accounts_set = true;
322 last_checkin_time_ = result->last_checkin_time; 322 last_checkin_time_ = result->last_checkin_time;
323 gservices_settings_.UpdateFromLoadResult(*result); 323 gservices_settings_.UpdateFromLoadResult(*result);
324 // Taking over the value of account_mappings before passing the ownership of
325 // load result to InitializeMCSClient.
326 std::vector<AccountMapping> account_mappings;
327 account_mappings.swap(result->account_mappings);
328
324 InitializeMCSClient(result.Pass()); 329 InitializeMCSClient(result.Pass());
325 330
326 if (device_checkin_info_.IsValid()) { 331 if (device_checkin_info_.IsValid()) {
327 SchedulePeriodicCheckin(); 332 SchedulePeriodicCheckin();
328 OnReady(); 333 OnReady(account_mappings);
329 return; 334 return;
330 } 335 }
331 336
332 state_ = INITIAL_DEVICE_CHECKIN; 337 state_ = INITIAL_DEVICE_CHECKIN;
333 device_checkin_info_.Reset(); 338 device_checkin_info_.Reset();
334 StartCheckin(); 339 StartCheckin();
335 } 340 }
336 341
337 void GCMClientImpl::InitializeMCSClient( 342 void GCMClientImpl::InitializeMCSClient(
338 scoped_ptr<GCMStore::LoadResult> result) { 343 scoped_ptr<GCMStore::LoadResult> result) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 device_checkin_info_.android_id = checkin_info.android_id; 377 device_checkin_info_.android_id = checkin_info.android_id;
373 device_checkin_info_.secret = checkin_info.secret; 378 device_checkin_info_.secret = checkin_info.secret;
374 // If accounts were not set by now, we can consider them set (to empty list) 379 // If accounts were not set by now, we can consider them set (to empty list)
375 // to make sure periodic checkins get scheduled after initial checkin. 380 // to make sure periodic checkins get scheduled after initial checkin.
376 device_checkin_info_.accounts_set = true; 381 device_checkin_info_.accounts_set = true;
377 gcm_store_->SetDeviceCredentials( 382 gcm_store_->SetDeviceCredentials(
378 checkin_info.android_id, checkin_info.secret, 383 checkin_info.android_id, checkin_info.secret,
379 base::Bind(&GCMClientImpl::SetDeviceCredentialsCallback, 384 base::Bind(&GCMClientImpl::SetDeviceCredentialsCallback,
380 weak_ptr_factory_.GetWeakPtr())); 385 weak_ptr_factory_.GetWeakPtr()));
381 386
382 OnReady(); 387 OnReady(std::vector<AccountMapping>());
383 } 388 }
384 389
385 void GCMClientImpl::OnReady() { 390 void GCMClientImpl::OnReady(
391 const std::vector<AccountMapping>& account_mappings) {
386 state_ = READY; 392 state_ = READY;
387 StartMCSLogin(); 393 StartMCSLogin();
388 394
389 delegate_->OnGCMReady(); 395 delegate_->OnGCMReady(account_mappings);
390 } 396 }
391 397
392 void GCMClientImpl::StartMCSLogin() { 398 void GCMClientImpl::StartMCSLogin() {
393 DCHECK_EQ(READY, state_); 399 DCHECK_EQ(READY, state_);
394 DCHECK(device_checkin_info_.IsValid()); 400 DCHECK(device_checkin_info_.IsValid());
395 mcs_client_->Login(device_checkin_info_.android_id, 401 mcs_client_->Login(device_checkin_info_.android_id,
396 device_checkin_info_.secret); 402 device_checkin_info_.secret);
397 } 403 }
398 404
399 void GCMClientImpl::ResetState() { 405 void GCMClientImpl::ResetState() {
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 959
954 recorder_.RecordIncomingSendError( 960 recorder_.RecordIncomingSendError(
955 data_message_stanza.category(), 961 data_message_stanza.category(),
956 data_message_stanza.to(), 962 data_message_stanza.to(),
957 data_message_stanza.id()); 963 data_message_stanza.id());
958 delegate_->OnMessageSendError(data_message_stanza.category(), 964 delegate_->OnMessageSendError(data_message_stanza.category(),
959 send_error_details); 965 send_error_details);
960 } 966 }
961 967
962 } // namespace gcm 968 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl.h ('k') | components/gcm_driver/gcm_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698