| 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_account_mapper.h" | 5 #include "components/gcm_driver/gcm_account_mapper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/time/clock.h" | 9 #include "base/time/clock.h" |
| 10 #include "base/time/default_clock.h" | 10 #include "base/time/default_clock.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void GCMAccountMapper::Initialize( | 49 void GCMAccountMapper::Initialize( |
| 50 const std::vector<AccountMapping>& account_mappings) { | 50 const std::vector<AccountMapping>& account_mappings) { |
| 51 DCHECK(!initialized_); | 51 DCHECK(!initialized_); |
| 52 initialized_ = true; | 52 initialized_ = true; |
| 53 accounts_ = account_mappings; | 53 accounts_ = account_mappings; |
| 54 gcm_driver_->AddAppHandler(kGCMAccountMapperAppId, this); | 54 gcm_driver_->AddAppHandler(kGCMAccountMapperAppId, this); |
| 55 GetRegistration(); | 55 GetRegistration(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void GCMAccountMapper::SetAccountTokens( | 58 void GCMAccountMapper::SetAccountTokens( |
| 59 const std::vector<GCMClient::AccountTokenInfo> account_tokens) { | 59 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) { |
| 60 // If account mapper is not ready to handle tasks yet, save the latest | 60 // If account mapper is not ready to handle tasks yet, save the latest |
| 61 // account tokens and return. | 61 // account tokens and return. |
| 62 if (!IsReady()) { | 62 if (!IsReady()) { |
| 63 pending_account_tokens_ = account_tokens; | 63 pending_account_tokens_ = account_tokens; |
| 64 // If mapper is initialized, but still does not have registration ID, | 64 // If mapper is initialized, but still does not have registration ID, |
| 65 // maybe the registration gave up. Retrying in case. | 65 // maybe the registration gave up. Retrying in case. |
| 66 if (initialized_) | 66 if (initialized_) |
| 67 GetRegistration(); | 67 GetRegistration(); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 | 349 |
| 350 return accounts_.end(); | 350 return accounts_.end(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void GCMAccountMapper::SetClockForTesting(scoped_ptr<base::Clock> clock) { | 353 void GCMAccountMapper::SetClockForTesting(scoped_ptr<base::Clock> clock) { |
| 354 clock_ = clock.Pass(); | 354 clock_ = clock.Pass(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace gcm | 357 } // namespace gcm |
| OLD | NEW |