OLD | NEW |
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 DCHECK(device_checkin_info_.IsValid()); | 400 DCHECK(device_checkin_info_.IsValid()); |
401 mcs_client_->Login(device_checkin_info_.android_id, | 401 mcs_client_->Login(device_checkin_info_.android_id, |
402 device_checkin_info_.secret); | 402 device_checkin_info_.secret); |
403 } | 403 } |
404 | 404 |
405 void GCMClientImpl::ResetState() { | 405 void GCMClientImpl::ResetState() { |
406 state_ = UNINITIALIZED; | 406 state_ = UNINITIALIZED; |
407 // TODO(fgorski): reset all of the necessart objects and start over. | 407 // TODO(fgorski): reset all of the necessart objects and start over. |
408 } | 408 } |
409 | 409 |
410 void GCMClientImpl::SetAccountsForCheckin( | 410 void GCMClientImpl::SetAccountTokens( |
411 const std::map<std::string, std::string>& account_tokens) { | 411 const std::vector<AccountTokenInfo>& account_tokens) { |
| 412 device_checkin_info_.account_tokens.clear(); |
| 413 for (std::vector<AccountTokenInfo>::const_iterator iter = |
| 414 account_tokens.begin(); |
| 415 iter != account_tokens.end(); |
| 416 ++iter) { |
| 417 device_checkin_info_.account_tokens[iter->email] = iter->access_token; |
| 418 } |
| 419 |
412 bool accounts_set_before = device_checkin_info_.accounts_set; | 420 bool accounts_set_before = device_checkin_info_.accounts_set; |
413 device_checkin_info_.account_tokens = account_tokens; | |
414 device_checkin_info_.accounts_set = true; | 421 device_checkin_info_.accounts_set = true; |
415 | 422 |
416 DVLOG(1) << "Set account called with: " << account_tokens.size() | 423 DVLOG(1) << "Set account called with: " << account_tokens.size() |
417 << " accounts."; | 424 << " accounts."; |
418 | 425 |
419 if (state_ != READY && state_ != INITIAL_DEVICE_CHECKIN) | 426 if (state_ != READY && state_ != INITIAL_DEVICE_CHECKIN) |
420 return; | 427 return; |
421 | 428 |
422 bool account_removed = false; | 429 bool account_removed = false; |
423 for (std::set<std::string>::iterator iter = | 430 for (std::set<std::string>::iterator iter = |
424 device_checkin_info_.last_checkin_accounts.begin(); | 431 device_checkin_info_.last_checkin_accounts.begin(); |
425 iter != device_checkin_info_.last_checkin_accounts.end(); | 432 iter != device_checkin_info_.last_checkin_accounts.end(); |
426 ++iter) { | 433 ++iter) { |
427 if (account_tokens.find(*iter) == account_tokens.end()) | 434 if (device_checkin_info_.account_tokens.find(*iter) == |
| 435 device_checkin_info_.account_tokens.end()) { |
428 account_removed = true; | 436 account_removed = true; |
| 437 } |
429 } | 438 } |
430 | 439 |
431 // Checkin will be forced when any of the accounts was removed during the | 440 // Checkin will be forced when any of the accounts was removed during the |
432 // current Chrome session or if there has been an account removed between the | 441 // current Chrome session or if there has been an account removed between the |
433 // restarts of Chrome. If there is a checkin in progress, it will be canceled. | 442 // restarts of Chrome. If there is a checkin in progress, it will be canceled. |
434 // We only force checkin when user signs out. When there is a new account | 443 // We only force checkin when user signs out. When there is a new account |
435 // signed in, the periodic checkin will take care of adding the association in | 444 // signed in, the periodic checkin will take care of adding the association in |
436 // reasonable time. | 445 // reasonable time. |
437 if (account_removed) { | 446 if (account_removed) { |
438 DVLOG(1) << "Detected that account has been removed. Forcing checkin."; | 447 DVLOG(1) << "Detected that account has been removed. Forcing checkin."; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 | 968 |
960 recorder_.RecordIncomingSendError( | 969 recorder_.RecordIncomingSendError( |
961 data_message_stanza.category(), | 970 data_message_stanza.category(), |
962 data_message_stanza.to(), | 971 data_message_stanza.to(), |
963 data_message_stanza.id()); | 972 data_message_stanza.id()); |
964 delegate_->OnMessageSendError(data_message_stanza.category(), | 973 delegate_->OnMessageSendError(data_message_stanza.category(), |
965 send_error_details); | 974 send_error_details); |
966 } | 975 } |
967 | 976 |
968 } // namespace gcm | 977 } // namespace gcm |
OLD | NEW |