| 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 "base/profiler/scoped_tracker.h" | 5 #include "base/profiler/scoped_tracker.h" |
| 6 #include "google_apis/gaia/oauth2_token_service.h" | 6 #include "google_apis/gaia/oauth2_token_service.h" |
| 7 #include "google_apis/gaia/oauth2_token_service_delegate.h" | 7 #include "google_apis/gaia/oauth2_token_service_delegate.h" |
| 8 | 8 |
| 9 OAuth2TokenServiceDelegate::ScopedBatchChange::ScopedBatchChange( | 9 OAuth2TokenServiceDelegate::ScopedBatchChange::ScopedBatchChange( |
| 10 OAuth2TokenServiceDelegate* delegate) | 10 OAuth2TokenServiceDelegate* delegate) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 observer_list_.RemoveObserver(observer); | 51 observer_list_.RemoveObserver(observer); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // static | 54 // static |
| 55 bool OAuth2TokenServiceDelegate::IsError(const GoogleServiceAuthError& error) { | 55 bool OAuth2TokenServiceDelegate::IsError(const GoogleServiceAuthError& error) { |
| 56 return error.IsPersistentError(); | 56 return error.IsPersistentError(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void OAuth2TokenServiceDelegate::StartBatchChanges() { | 59 void OAuth2TokenServiceDelegate::StartBatchChanges() { |
| 60 ++batch_change_depth_; | 60 ++batch_change_depth_; |
| 61 if (batch_change_depth_ == 1) | 61 if (batch_change_depth_ == 1) { |
| 62 FOR_EACH_OBSERVER(OAuth2TokenService::Observer, observer_list_, | 62 for (auto& observer : observer_list_) |
| 63 OnStartBatchChanges()); | 63 observer.OnStartBatchChanges(); |
| 64 } |
| 64 } | 65 } |
| 65 | 66 |
| 66 void OAuth2TokenServiceDelegate::EndBatchChanges() { | 67 void OAuth2TokenServiceDelegate::EndBatchChanges() { |
| 67 --batch_change_depth_; | 68 --batch_change_depth_; |
| 68 DCHECK_LE(0, batch_change_depth_); | 69 DCHECK_LE(0, batch_change_depth_); |
| 69 if (batch_change_depth_ == 0) | 70 if (batch_change_depth_ == 0) { |
| 70 FOR_EACH_OBSERVER(OAuth2TokenService::Observer, observer_list_, | 71 for (auto& observer : observer_list_) |
| 71 OnEndBatchChanges()); | 72 observer.OnEndBatchChanges(); |
| 73 } |
| 72 } | 74 } |
| 73 | 75 |
| 74 void OAuth2TokenServiceDelegate::FireRefreshTokenAvailable( | 76 void OAuth2TokenServiceDelegate::FireRefreshTokenAvailable( |
| 75 const std::string& account_id) { | 77 const std::string& account_id) { |
| 76 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 78 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 77 // fixed. | 79 // fixed. |
| 78 tracked_objects::ScopedTracker tracking_profile( | 80 tracked_objects::ScopedTracker tracking_profile( |
| 79 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 81 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 80 "422460 OAuth2TokenService::FireRefreshTokenAvailable")); | 82 "422460 OAuth2TokenService::FireRefreshTokenAvailable")); |
| 81 | 83 |
| 82 FOR_EACH_OBSERVER(OAuth2TokenService::Observer, observer_list_, | 84 for (auto& observer : observer_list_) |
| 83 OnRefreshTokenAvailable(account_id)); | 85 observer.OnRefreshTokenAvailable(account_id); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void OAuth2TokenServiceDelegate::FireRefreshTokenRevoked( | 88 void OAuth2TokenServiceDelegate::FireRefreshTokenRevoked( |
| 87 const std::string& account_id) { | 89 const std::string& account_id) { |
| 88 FOR_EACH_OBSERVER(OAuth2TokenService::Observer, observer_list_, | 90 for (auto& observer : observer_list_) |
| 89 OnRefreshTokenRevoked(account_id)); | 91 observer.OnRefreshTokenRevoked(account_id); |
| 90 } | 92 } |
| 91 | 93 |
| 92 void OAuth2TokenServiceDelegate::FireRefreshTokensLoaded() { | 94 void OAuth2TokenServiceDelegate::FireRefreshTokensLoaded() { |
| 93 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 95 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 94 // fixed. | 96 // fixed. |
| 95 tracked_objects::ScopedTracker tracking_profile( | 97 tracked_objects::ScopedTracker tracking_profile( |
| 96 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 98 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 97 "422460 OAuth2TokenService::FireRefreshTokensLoaded")); | 99 "422460 OAuth2TokenService::FireRefreshTokensLoaded")); |
| 98 | 100 |
| 99 FOR_EACH_OBSERVER(OAuth2TokenService::Observer, observer_list_, | 101 for (auto& observer : observer_list_) |
| 100 OnRefreshTokensLoaded()); | 102 observer.OnRefreshTokensLoaded(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 net::URLRequestContextGetter* OAuth2TokenServiceDelegate::GetRequestContext() | 105 net::URLRequestContextGetter* OAuth2TokenServiceDelegate::GetRequestContext() |
| 104 const { | 106 const { |
| 105 return nullptr; | 107 return nullptr; |
| 106 } | 108 } |
| 107 | 109 |
| 108 bool OAuth2TokenServiceDelegate::RefreshTokenHasError( | 110 bool OAuth2TokenServiceDelegate::RefreshTokenHasError( |
| 109 const std::string& account_id) const { | 111 const std::string& account_id) const { |
| 110 return false; | 112 return false; |
| 111 } | 113 } |
| 112 | 114 |
| 113 std::vector<std::string> OAuth2TokenServiceDelegate::GetAccounts() { | 115 std::vector<std::string> OAuth2TokenServiceDelegate::GetAccounts() { |
| 114 return std::vector<std::string>(); | 116 return std::vector<std::string>(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 const net::BackoffEntry* OAuth2TokenServiceDelegate::BackoffEntry() const { | 119 const net::BackoffEntry* OAuth2TokenServiceDelegate::BackoffEntry() const { |
| 118 return nullptr; | 120 return nullptr; |
| 119 } | 121 } |
| OLD | NEW |