| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/signin/core/browser/account_fetcher_service.h" | 5 #include "components/signin/core/browser/account_fetcher_service.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 9 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 11 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 14 #include "components/signin/core/browser/account_info_fetcher.h" | 16 #include "components/signin/core/browser/account_info_fetcher.h" |
| 15 #include "components/signin/core/browser/account_tracker_service.h" | 17 #include "components/signin/core/browser/account_tracker_service.h" |
| 16 #include "components/signin/core/browser/child_account_info_fetcher.h" | 18 #include "components/signin/core/browser/child_account_info_fetcher.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void AccountFetcherService::StartFetchingUserInfo( | 199 void AccountFetcherService::StartFetchingUserInfo( |
| 198 const std::string& account_id) { | 200 const std::string& account_id) { |
| 199 DCHECK(CalledOnValidThread()); | 201 DCHECK(CalledOnValidThread()); |
| 200 DCHECK(network_fetches_enabled_); | 202 DCHECK(network_fetches_enabled_); |
| 201 | 203 |
| 202 if (!ContainsKey(user_info_requests_, account_id)) { | 204 if (!ContainsKey(user_info_requests_, account_id)) { |
| 203 DVLOG(1) << "StartFetching " << account_id; | 205 DVLOG(1) << "StartFetching " << account_id; |
| 204 scoped_ptr<AccountInfoFetcher> fetcher(new AccountInfoFetcher( | 206 scoped_ptr<AccountInfoFetcher> fetcher(new AccountInfoFetcher( |
| 205 token_service_, signin_client_->GetURLRequestContext(), this, | 207 token_service_, signin_client_->GetURLRequestContext(), this, |
| 206 account_id)); | 208 account_id)); |
| 207 user_info_requests_.set(account_id, fetcher.Pass()); | 209 user_info_requests_.set(account_id, std::move(fetcher)); |
| 208 user_info_requests_.get(account_id)->Start(); | 210 user_info_requests_.get(account_id)->Start(); |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 | 213 |
| 212 // Starts fetching whether this is a child account. Handles refresh internally. | 214 // Starts fetching whether this is a child account. Handles refresh internally. |
| 213 void AccountFetcherService::StartFetchingChildInfo( | 215 void AccountFetcherService::StartFetchingChildInfo( |
| 214 const std::string& account_id) { | 216 const std::string& account_id) { |
| 215 child_info_request_.reset(ChildAccountInfoFetcher::CreateFrom( | 217 child_info_request_.reset(ChildAccountInfoFetcher::CreateFrom( |
| 216 child_request_account_id_, this, token_service_, | 218 child_request_account_id_, this, token_service_, |
| 217 signin_client_->GetURLRequestContext(), invalidation_service_)); | 219 signin_client_->GetURLRequestContext(), invalidation_service_)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 scoped_ptr<RefreshTokenAnnotationRequest> request = | 264 scoped_ptr<RefreshTokenAnnotationRequest> request = |
| 263 RefreshTokenAnnotationRequest::SendIfNeeded( | 265 RefreshTokenAnnotationRequest::SendIfNeeded( |
| 264 signin_client_->GetPrefs(), token_service_, signin_client_, | 266 signin_client_->GetPrefs(), token_service_, signin_client_, |
| 265 signin_client_->GetURLRequestContext(), account_id, | 267 signin_client_->GetURLRequestContext(), account_id, |
| 266 base::Bind( | 268 base::Bind( |
| 267 &AccountFetcherService::RefreshTokenAnnotationRequestDone, | 269 &AccountFetcherService::RefreshTokenAnnotationRequestDone, |
| 268 base::Unretained(this), account_id)); | 270 base::Unretained(this), account_id)); |
| 269 // If request was sent AccountFetcherService needs to own request till it | 271 // If request was sent AccountFetcherService needs to own request till it |
| 270 // finishes. | 272 // finishes. |
| 271 if (request) | 273 if (request) |
| 272 refresh_token_annotation_requests_.set(account_id, request.Pass()); | 274 refresh_token_annotation_requests_.set(account_id, std::move(request)); |
| 273 } | 275 } |
| 274 #endif | 276 #endif |
| 275 } | 277 } |
| 276 | 278 |
| 277 void AccountFetcherService::RefreshTokenAnnotationRequestDone( | 279 void AccountFetcherService::RefreshTokenAnnotationRequestDone( |
| 278 const std::string& account_id) { | 280 const std::string& account_id) { |
| 279 refresh_token_annotation_requests_.erase(account_id); | 281 refresh_token_annotation_requests_.erase(account_id); |
| 280 } | 282 } |
| 281 | 283 |
| 282 void AccountFetcherService::OnUserInfoFetchSuccess( | 284 void AccountFetcherService::OnUserInfoFetchSuccess( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 user_info_requests_.erase(account_id); | 334 user_info_requests_.erase(account_id); |
| 333 UpdateChildInfo(); | 335 UpdateChildInfo(); |
| 334 account_tracker_service_->StopTrackingAccount(account_id); | 336 account_tracker_service_->StopTrackingAccount(account_id); |
| 335 } | 337 } |
| 336 | 338 |
| 337 void AccountFetcherService::OnRefreshTokensLoaded() { | 339 void AccountFetcherService::OnRefreshTokensLoaded() { |
| 338 DCHECK(CalledOnValidThread()); | 340 DCHECK(CalledOnValidThread()); |
| 339 refresh_tokens_loaded_ = true; | 341 refresh_tokens_loaded_ = true; |
| 340 MaybeEnableNetworkFetches(); | 342 MaybeEnableNetworkFetches(); |
| 341 } | 343 } |
| OLD | NEW |