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/signin/core/browser/gaia_cookie_manager_service.h" | 5 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
6 | 6 |
| 7 #include <queue> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "components/signin/core/browser/signin_metrics.h" | 16 #include "components/signin/core/browser/signin_metrics.h" |
16 #include "google_apis/gaia/gaia_auth_fetcher.h" | 17 #include "google_apis/gaia/gaia_auth_fetcher.h" |
17 #include "google_apis/gaia/gaia_constants.h" | 18 #include "google_apis/gaia/gaia_constants.h" |
18 #include "google_apis/gaia/gaia_urls.h" | 19 #include "google_apis/gaia/gaia_urls.h" |
19 #include "google_apis/gaia/oauth2_token_service.h" | 20 #include "google_apis/gaia/oauth2_token_service.h" |
20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
21 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
22 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
23 #include "net/url_request/url_fetcher_delegate.h" | 24 #include "net/url_request/url_fetcher_delegate.h" |
24 | 25 |
25 | |
26 namespace { | 26 namespace { |
27 | 27 |
28 // In case of an error while fetching using the GaiaAuthFetcher, retry with | 28 // In case of an error while fetching using the GaiaAuthFetcher, retry with |
29 // exponential backoff. Try up to 7 times within 15 minutes. | 29 // exponential backoff. Try up to 7 times within 15 minutes. |
30 const net::BackoffEntry::Policy kBackoffPolicy = { | 30 const net::BackoffEntry::Policy kBackoffPolicy = { |
31 // Number of initial errors (in sequence) to ignore before applying | 31 // Number of initial errors (in sequence) to ignore before applying |
32 // exponential back-off rules. | 32 // exponential back-off rules. |
33 0, | 33 0, |
34 | 34 |
35 // Initial delay for exponential backoff in ms. | 35 // Initial delay for exponential backoff in ms. |
(...skipping 18 matching lines...) Expand all Loading... |
54 }; | 54 }; |
55 | 55 |
56 const int kMaxGaiaAuthFetcherRetries = 8; | 56 const int kMaxGaiaAuthFetcherRetries = 8; |
57 | 57 |
58 bool IsTransientError(const GoogleServiceAuthError& error) { | 58 bool IsTransientError(const GoogleServiceAuthError& error) { |
59 return error.state() == GoogleServiceAuthError::CONNECTION_FAILED || | 59 return error.state() == GoogleServiceAuthError::CONNECTION_FAILED || |
60 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE || | 60 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE || |
61 error.state() == GoogleServiceAuthError::REQUEST_CANCELED; | 61 error.state() == GoogleServiceAuthError::REQUEST_CANCELED; |
62 } | 62 } |
63 | 63 |
| 64 enum GaiaCookieRequestType { |
| 65 ADD_ACCOUNT, |
| 66 LOG_OUT_ALL_ACCOUNTS, |
| 67 LOG_OUT_ONE_ACCOUNT, |
| 68 LIST_ACCOUNTS |
| 69 }; |
| 70 |
64 } // namespace | 71 } // namespace |
65 | 72 |
| 73 GaiaCookieManagerService::GaiaCookieRequest::GaiaCookieRequest( |
| 74 GaiaCookieRequestType request_type, |
| 75 const std::string& account_id, |
| 76 const GaiaCookieManagerService::ListAccountsCallback& |
| 77 list_accounts_callback) |
| 78 : request_type_(request_type), |
| 79 account_id_(account_id), |
| 80 list_accounts_callback_(list_accounts_callback) {} |
| 81 |
| 82 GaiaCookieManagerService::GaiaCookieRequest::~GaiaCookieRequest() { |
| 83 } |
| 84 |
| 85 // static |
| 86 GaiaCookieManagerService::GaiaCookieRequest |
| 87 GaiaCookieManagerService::GaiaCookieRequest::CreateAddAccountRequest( |
| 88 const std::string& account_id) { |
| 89 return GaiaCookieManagerService::GaiaCookieRequest( |
| 90 GaiaCookieManagerService::GaiaCookieRequestType::ADD_ACCOUNT, |
| 91 account_id, |
| 92 GaiaCookieManagerService::ListAccountsCallback()); |
| 93 } |
| 94 |
| 95 // static |
| 96 GaiaCookieManagerService::GaiaCookieRequest |
| 97 GaiaCookieManagerService::GaiaCookieRequest::CreateLogOutRequest() { |
| 98 return GaiaCookieManagerService::GaiaCookieRequest( |
| 99 GaiaCookieManagerService::GaiaCookieRequestType::LOG_OUT, |
| 100 std::string(), |
| 101 GaiaCookieManagerService::ListAccountsCallback()); |
| 102 } |
| 103 |
| 104 GaiaCookieManagerService::GaiaCookieRequest |
| 105 GaiaCookieManagerService::GaiaCookieRequest::CreateListAccountsRequest( |
| 106 const GaiaCookieManagerService::ListAccountsCallback& |
| 107 list_accounts_callback) { |
| 108 return GaiaCookieManagerService::GaiaCookieRequest( |
| 109 GaiaCookieManagerService::GaiaCookieRequestType::LIST_ACCOUNTS, |
| 110 std::string(), |
| 111 list_accounts_callback); |
| 112 } |
| 113 |
66 GaiaCookieManagerService::ExternalCcResultFetcher::ExternalCcResultFetcher( | 114 GaiaCookieManagerService::ExternalCcResultFetcher::ExternalCcResultFetcher( |
67 GaiaCookieManagerService* helper) | 115 GaiaCookieManagerService* helper) |
68 : helper_(helper) { | 116 : helper_(helper) { |
69 DCHECK(helper_); | 117 DCHECK(helper_); |
70 } | 118 } |
71 | 119 |
72 GaiaCookieManagerService::ExternalCcResultFetcher::~ExternalCcResultFetcher() { | 120 GaiaCookieManagerService::ExternalCcResultFetcher::~ExternalCcResultFetcher() { |
73 CleanupTransientState(); | 121 CleanupTransientState(); |
74 } | 122 } |
75 | 123 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 : token_service_(token_service), | 276 : token_service_(token_service), |
229 signin_client_(signin_client), | 277 signin_client_(signin_client), |
230 external_cc_result_fetcher_(this), | 278 external_cc_result_fetcher_(this), |
231 gaia_auth_fetcher_backoff_(&kBackoffPolicy), | 279 gaia_auth_fetcher_backoff_(&kBackoffPolicy), |
232 gaia_auth_fetcher_retries_(0), | 280 gaia_auth_fetcher_retries_(0), |
233 source_(source) { | 281 source_(source) { |
234 } | 282 } |
235 | 283 |
236 GaiaCookieManagerService::~GaiaCookieManagerService() { | 284 GaiaCookieManagerService::~GaiaCookieManagerService() { |
237 CancelAll(); | 285 CancelAll(); |
238 DCHECK(accounts_.empty()); | 286 DCHECK(requests_.empty()); |
239 } | 287 } |
240 | 288 |
241 void GaiaCookieManagerService::AddAccountToCookie( | 289 void GaiaCookieManagerService::AddAccountToCookie( |
242 const std::string& account_id) { | 290 const std::string& account_id) { |
243 DCHECK(!account_id.empty()); | 291 DCHECK(!account_id.empty()); |
244 VLOG(1) << "GaiaCookieManagerService::AddAccountToCookie: " << account_id; | 292 VLOG(1) << "GaiaCookieManagerService::AddAccountToCookie: " << account_id; |
245 accounts_.push_back(account_id); | 293 requests_.push_back(GaiaCookieRequest::CreateAddAccountRequest(account_id)); |
246 if (accounts_.size() == 1) | 294 if (requests_.size() == 1) |
247 StartFetching(); | 295 StartFetchingUbertoken(); |
| 296 } |
| 297 |
| 298 void GaiaCookieManagerService::ListAccounts( |
| 299 const ListAccountsCallback& callback) { |
| 300 // Not implemented yet. |
| 301 NOTREACHED(); |
| 302 |
| 303 // TODO(mlerman): Once this service listens to all GAIA cookie changes, cache |
| 304 // the results of ListAccounts, and return them here if the GAIA cookie |
| 305 // hasn't changed since the last call. |
| 306 |
| 307 // If there's a GAIA call being executed, wait for it to complete. If it was |
| 308 // another /ListAccounts then we'll use the results it caches. |
| 309 if (gaia_auth_fetcher_) |
| 310 return; |
| 311 |
| 312 VLOG(1) << "GaiaCookieManagerService::ListAccounts"; |
| 313 gaia_auth_fetcher_.reset( |
| 314 new GaiaAuthFetcher(this, source_, |
| 315 signin_client_->GetURLRequestContext())); |
| 316 gaia_auth_fetcher_->StartListAccounts(); |
| 317 } |
| 318 |
| 319 void GaiaCookieManagerService::LogOutAllAccounts() { |
| 320 VLOG(1) << "GaiaCookieManagerService::LogOutAllAccounts"; |
| 321 |
| 322 bool log_out_queued = false; |
| 323 if (!requests_.empty()) { |
| 324 // Track requests to keep; all other unstarted requests will be removed. |
| 325 std::vector<GaiaCookieRequest> requests_to_keep; |
| 326 |
| 327 // Check all pending, non-executing requests. |
| 328 for (auto it = requests_.begin() + 1; it != requests_.end(); ++it) { |
| 329 if (it->request_type() == GaiaCookieRequestType::ADD_ACCOUNT) { |
| 330 // We have a pending log in request for an account followed by |
| 331 // a signout. |
| 332 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); |
| 333 SignalComplete(it->account_id(), error); |
| 334 } |
| 335 |
| 336 // Keep all requests except for ADD_ACCOUNTS. |
| 337 if (it->request_type() != GaiaCookieRequestType::ADD_ACCOUNT) |
| 338 requests_to_keep.push_back(*it); |
| 339 |
| 340 // Verify a LOG_OUT isn't already queued. |
| 341 if (it->request_type() == GaiaCookieRequestType::LOG_OUT) |
| 342 log_out_queued = true; |
| 343 } |
| 344 |
| 345 // Verify a LOG_OUT isn't currently being processed. |
| 346 if (requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT) |
| 347 log_out_queued = true; |
| 348 |
| 349 // Remove all but the executing request. Re-add all requests being kept. |
| 350 if (requests_.size() > 1) { |
| 351 requests_.erase(requests_.begin() + 1, requests_.end()); |
| 352 requests_.insert( |
| 353 requests_.end(), requests_to_keep.begin(), requests_to_keep.end()); |
| 354 } |
| 355 } |
| 356 |
| 357 if (!log_out_queued) { |
| 358 requests_.push_back(GaiaCookieRequest::CreateLogOutRequest()); |
| 359 if (requests_.size() == 1) |
| 360 StartLogOutUrlFetch(); |
| 361 } |
248 } | 362 } |
249 | 363 |
250 void GaiaCookieManagerService::AddObserver(Observer* observer) { | 364 void GaiaCookieManagerService::AddObserver(Observer* observer) { |
251 observer_list_.AddObserver(observer); | 365 observer_list_.AddObserver(observer); |
252 } | 366 } |
253 | 367 |
254 void GaiaCookieManagerService::RemoveObserver(Observer* observer) { | 368 void GaiaCookieManagerService::RemoveObserver(Observer* observer) { |
255 observer_list_.RemoveObserver(observer); | 369 observer_list_.RemoveObserver(observer); |
256 } | 370 } |
257 | 371 |
258 void GaiaCookieManagerService::CancelAll() { | 372 void GaiaCookieManagerService::CancelAll() { |
259 VLOG(1) << "GaiaCookieManagerService::CancelAll"; | 373 VLOG(1) << "GaiaCookieManagerService::CancelAll"; |
260 gaia_auth_fetcher_.reset(); | 374 gaia_auth_fetcher_.reset(); |
261 uber_token_fetcher_.reset(); | 375 uber_token_fetcher_.reset(); |
262 accounts_.clear(); | 376 requests_.clear(); |
263 gaia_auth_fetcher_timer_.Stop(); | 377 gaia_auth_fetcher_timer_.Stop(); |
264 } | 378 } |
265 | 379 |
266 void GaiaCookieManagerService::LogOut( | |
267 const std::string& account_id, | |
268 const std::vector<std::string>& accounts) { | |
269 DCHECK(!account_id.empty()); | |
270 VLOG(1) << "GaiaCookieManagerService::LogOut: " << account_id | |
271 << " accounts=" << accounts.size(); | |
272 LogOutInternal(account_id, accounts); | |
273 } | |
274 | |
275 void GaiaCookieManagerService::LogOutInternal( | |
276 const std::string& account_id, | |
277 const std::vector<std::string>& accounts) { | |
278 bool pending = !accounts_.empty(); | |
279 | |
280 if (pending) { | |
281 for (std::deque<std::string>::const_iterator it = accounts_.begin() + 1; | |
282 it != accounts_.end(); it++) { | |
283 if (!it->empty() && | |
284 (std::find(accounts.begin(), accounts.end(), *it) == accounts.end() || | |
285 *it == account_id)) { | |
286 // We have a pending log in request for an account followed by | |
287 // a signout. | |
288 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); | |
289 SignalComplete(*it, error); | |
290 } | |
291 } | |
292 | |
293 // Remove every thing in the work list besides the one that is running. | |
294 accounts_.resize(1); | |
295 } | |
296 | |
297 // Signal a logout to be the next thing to do unless the pending | |
298 // action is already a logout. | |
299 if (!pending || !accounts_.front().empty()) | |
300 accounts_.push_back(""); | |
301 | |
302 for (std::vector<std::string>::const_iterator it = accounts.begin(); | |
303 it != accounts.end(); it++) { | |
304 if (*it != account_id) { | |
305 DCHECK(!it->empty()); | |
306 accounts_.push_back(*it); | |
307 } | |
308 } | |
309 | |
310 if (!pending) | |
311 StartLogOutUrlFetch(); | |
312 } | |
313 | |
314 void GaiaCookieManagerService::LogOutAllAccounts() { | |
315 VLOG(1) << "GaiaCookieManagerService::LogOutAllAccounts"; | |
316 LogOutInternal("", std::vector<std::string>()); | |
317 } | |
318 | |
319 void GaiaCookieManagerService::SignalComplete( | 380 void GaiaCookieManagerService::SignalComplete( |
320 const std::string& account_id, | 381 const std::string& account_id, |
321 const GoogleServiceAuthError& error) { | 382 const GoogleServiceAuthError& error) { |
322 // Its possible for the observer to delete |this| object. Don't access | 383 // Its possible for the observer to delete |this| object. Don't access |
323 // access any members after this calling the observer. This method should | 384 // access any members after this calling the observer. This method should |
324 // be the last call in any other method. | 385 // be the last call in any other method. |
325 FOR_EACH_OBSERVER(Observer, observer_list_, | 386 FOR_EACH_OBSERVER(Observer, observer_list_, |
326 OnAddAccountToCookieCompleted(account_id, error)); | 387 OnAddAccountToCookieCompleted(account_id, error)); |
327 } | 388 } |
328 | 389 |
329 void GaiaCookieManagerService::StartFetchingExternalCcResult() { | 390 void GaiaCookieManagerService::StartFetchingExternalCcResult() { |
330 if (!external_cc_result_fetcher_.IsRunning()) | 391 if (!external_cc_result_fetcher_.IsRunning()) |
331 external_cc_result_fetcher_.Start(); | 392 external_cc_result_fetcher_.Start(); |
332 } | 393 } |
333 | 394 |
334 void GaiaCookieManagerService::StartLogOutUrlFetch() { | 395 void GaiaCookieManagerService::StartLogOutUrlFetch() { |
335 DCHECK(accounts_.front().empty()); | 396 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); |
336 VLOG(1) << "GaiaCookieManagerService::StartLogOutUrlFetch"; | 397 VLOG(1) << "GaiaCookieManagerService::StartLogOutUrlFetch"; |
337 GURL logout_url(GaiaUrls::GetInstance()->service_logout_url().Resolve( | 398 GURL logout_url(GaiaUrls::GetInstance()->service_logout_url().Resolve( |
338 base::StringPrintf("?source=%s", source_.c_str()))); | 399 base::StringPrintf("?source=%s", source_.c_str()))); |
339 net::URLFetcher* fetcher = | 400 net::URLFetcher* fetcher = |
340 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this); | 401 net::URLFetcher::Create(logout_url, net::URLFetcher::GET, this); |
341 fetcher->SetRequestContext(signin_client_->GetURLRequestContext()); | 402 fetcher->SetRequestContext(signin_client_->GetURLRequestContext()); |
342 fetcher->Start(); | 403 fetcher->Start(); |
343 } | 404 } |
344 | 405 |
345 void GaiaCookieManagerService::OnUbertokenSuccess( | 406 void GaiaCookieManagerService::OnUbertokenSuccess( |
346 const std::string& uber_token) { | 407 const std::string& uber_token) { |
347 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" | 408 VLOG(1) << "GaiaCookieManagerService::OnUbertokenSuccess" |
348 << " account=" << accounts_.front(); | 409 << " account=" << requests_.front().account_id(); |
349 gaia_auth_fetcher_retries_ = 0; | 410 gaia_auth_fetcher_retries_ = 0; |
350 uber_token_ = uber_token; | 411 uber_token_ = uber_token; |
351 StartFetchingMergeSession(); | 412 StartFetchingMergeSession(); |
352 } | 413 } |
353 | 414 |
354 void GaiaCookieManagerService::OnUbertokenFailure( | 415 void GaiaCookieManagerService::OnUbertokenFailure( |
355 const GoogleServiceAuthError& error) { | 416 const GoogleServiceAuthError& error) { |
356 VLOG(1) << "Failed to retrieve ubertoken" | 417 VLOG(1) << "Failed to retrieve ubertoken" |
357 << " account=" << accounts_.front() << " error=" << error.ToString(); | 418 << " account=" << requests_.front().account_id() |
358 const std::string account_id = accounts_.front(); | 419 << " error=" << error.ToString(); |
359 HandleNextAccount(); | 420 const std::string account_id = requests_.front().account_id(); |
| 421 HandleNextRequest(); |
360 SignalComplete(account_id, error); | 422 SignalComplete(account_id, error); |
361 } | 423 } |
362 | 424 |
363 void GaiaCookieManagerService::OnMergeSessionSuccess(const std::string& data) { | 425 void GaiaCookieManagerService::OnMergeSessionSuccess(const std::string& data) { |
364 VLOG(1) << "MergeSession successful account=" << accounts_.front(); | 426 VLOG(1) << "MergeSession successful account=" |
365 const std::string account_id = accounts_.front(); | 427 << requests_.front().account_id(); |
366 HandleNextAccount(); | 428 const std::string account_id = requests_.front().account_id(); |
| 429 HandleNextRequest(); |
367 SignalComplete(account_id, GoogleServiceAuthError::AuthErrorNone()); | 430 SignalComplete(account_id, GoogleServiceAuthError::AuthErrorNone()); |
368 | 431 |
369 gaia_auth_fetcher_backoff_.InformOfRequest(true); | 432 gaia_auth_fetcher_backoff_.InformOfRequest(true); |
370 uber_token_ = std::string(); | 433 uber_token_ = std::string(); |
371 } | 434 } |
372 | 435 |
373 void GaiaCookieManagerService::OnMergeSessionFailure( | 436 void GaiaCookieManagerService::OnMergeSessionFailure( |
374 const GoogleServiceAuthError& error) { | 437 const GoogleServiceAuthError& error) { |
375 VLOG(1) << "Failed MergeSession" | 438 VLOG(1) << "Failed MergeSession" |
376 << " account=" << accounts_.front() << " error=" << error.ToString() | 439 << " account=" << requests_.front().account_id() |
377 << " on retry=" << gaia_auth_fetcher_retries_; | 440 << " error=" << error.ToString(); |
378 | 441 |
379 if (++gaia_auth_fetcher_retries_ < kMaxGaiaAuthFetcherRetries && | 442 if (++gaia_auth_fetcher_retries_ < kMaxGaiaAuthFetcherRetries && |
380 IsTransientError(error)) { | 443 IsTransientError(error)) { |
381 gaia_auth_fetcher_backoff_.InformOfRequest(false); | 444 gaia_auth_fetcher_backoff_.InformOfRequest(false); |
382 gaia_auth_fetcher_timer_.Start( | 445 gaia_auth_fetcher_timer_.Start( |
383 FROM_HERE, gaia_auth_fetcher_backoff_.GetTimeUntilRelease(), this, | 446 FROM_HERE, gaia_auth_fetcher_backoff_.GetTimeUntilRelease(), this, |
384 &GaiaCookieManagerService::StartFetchingMergeSession); | 447 &GaiaCookieManagerService::StartFetchingMergeSession); |
385 return; | 448 return; |
386 } | 449 } |
387 | 450 |
388 uber_token_ = std::string(); | 451 uber_token_ = std::string(); |
389 const std::string account_id = accounts_.front(); | 452 const std::string account_id = requests_.front().account_id(); |
390 HandleNextAccount(); | 453 HandleNextRequest(); |
391 SignalComplete(account_id, error); | 454 SignalComplete(account_id, error); |
392 } | 455 } |
393 | 456 |
394 void GaiaCookieManagerService::StartFetching() { | 457 void GaiaCookieManagerService::StartFetchingUbertoken() { |
395 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" | 458 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" |
396 << accounts_.front(); | 459 << requests_.front().account_id(); |
397 uber_token_fetcher_.reset( | 460 uber_token_fetcher_.reset( |
398 new UbertokenFetcher(token_service_, this, source_, | 461 new UbertokenFetcher(token_service_, this, source_, |
399 signin_client_->GetURLRequestContext())); | 462 signin_client_->GetURLRequestContext())); |
400 uber_token_fetcher_->StartFetchingToken(accounts_.front()); | 463 uber_token_fetcher_->StartFetchingToken(requests_.front().account_id()); |
401 } | 464 } |
402 | 465 |
403 void GaiaCookieManagerService::StartFetchingMergeSession() { | 466 void GaiaCookieManagerService::StartFetchingMergeSession() { |
404 DCHECK(!uber_token_.empty()); | 467 DCHECK(!uber_token_.empty()); |
405 gaia_auth_fetcher_.reset( | 468 gaia_auth_fetcher_.reset( |
406 new GaiaAuthFetcher(this, source_, | 469 new GaiaAuthFetcher(this, source_, |
407 signin_client_->GetURLRequestContext())); | 470 signin_client_->GetURLRequestContext())); |
408 | 471 |
409 // It's possible that not all external checks have completed. | 472 // It's possible that not all external checks have completed. |
410 // GetExternalCcResult() returns results for those that have. | 473 // GetExternalCcResult() returns results for those that have. |
411 gaia_auth_fetcher_->StartMergeSession(uber_token_, | 474 gaia_auth_fetcher_->StartMergeSession(uber_token_, |
412 external_cc_result_fetcher_.GetExternalCcResult()); | 475 external_cc_result_fetcher_.GetExternalCcResult()); |
413 } | 476 } |
414 | 477 |
415 void GaiaCookieManagerService::OnURLFetchComplete( | 478 void GaiaCookieManagerService::OnURLFetchComplete( |
416 const net::URLFetcher* source) { | 479 const net::URLFetcher* source) { |
417 DCHECK(accounts_.front().empty()); | 480 DCHECK(requests_.front().request_type() == GaiaCookieRequestType::LOG_OUT); |
418 VLOG(1) << "GaiaCookieManagerService::OnURLFetchComplete"; | 481 VLOG(1) << "GaiaCookieManagerService::OnURLFetchComplete"; |
419 HandleNextAccount(); | 482 HandleNextRequest(); |
420 } | 483 } |
421 | 484 |
422 void GaiaCookieManagerService::HandleNextAccount() { | 485 void GaiaCookieManagerService::HandleNextRequest() { |
423 VLOG(1) << "GaiaCookieManagerService::HandleNextAccount"; | 486 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest"; |
424 accounts_.pop_front(); | 487 requests_.pop_front(); |
425 gaia_auth_fetcher_.reset(); | 488 gaia_auth_fetcher_.reset(); |
426 if (accounts_.empty()) { | 489 if (requests_.empty()) { |
427 VLOG(1) << "GaiaCookieManagerService::HandleNextAccount: no more"; | 490 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest: no more"; |
428 uber_token_fetcher_.reset(); | 491 uber_token_fetcher_.reset(); |
429 } else { | 492 } else { |
430 if (accounts_.front().empty()) { | 493 switch (requests_.front().request_type()) { |
431 StartLogOutUrlFetch(); | 494 case GaiaCookieRequestType::ADD_ACCOUNT: |
432 } else { | 495 StartFetchingUbertoken(); |
433 StartFetching(); | 496 break; |
434 } | 497 case GaiaCookieRequestType::LOG_OUT: |
| 498 StartLogOutUrlFetch(); |
| 499 break; |
| 500 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 501 break; |
| 502 }; |
435 } | 503 } |
436 } | 504 } |
OLD | NEW |