OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/arc_auth_context.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_context.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 OnRefreshTokensLoaded(); | 74 OnRefreshTokensLoaded(); |
75 } | 75 } |
76 | 76 |
77 void ArcAuthContext::OnRefreshTokensLoaded() { | 77 void ArcAuthContext::OnRefreshTokensLoaded() { |
78 token_service_->RemoveObserver(this); | 78 token_service_->RemoveObserver(this); |
79 refresh_token_timeout_.Stop(); | 79 refresh_token_timeout_.Stop(); |
80 StartFetchers(); | 80 StartFetchers(); |
81 } | 81 } |
82 | 82 |
83 void ArcAuthContext::OnRefreshTokenTimeout() { | 83 void ArcAuthContext::OnRefreshTokenTimeout() { |
84 VLOG(2) << "Failed to wait for refresh token."; | 84 LOG(WARNING) << "Failed to wait for refresh token."; |
85 token_service_->RemoveObserver(this); | 85 token_service_->RemoveObserver(this); |
86 base::ResetAndReturn(&callback_).Run(nullptr); | 86 base::ResetAndReturn(&callback_).Run(nullptr); |
87 } | 87 } |
88 | 88 |
89 void ArcAuthContext::StartFetchers() { | 89 void ArcAuthContext::StartFetchers() { |
90 DCHECK(!refresh_token_timeout_.IsRunning()); | 90 DCHECK(!refresh_token_timeout_.IsRunning()); |
91 ResetFetchers(); | 91 ResetFetchers(); |
92 ubertoken_fetcher_.reset( | 92 ubertoken_fetcher_.reset( |
93 new UbertokenFetcher(token_service_, this, GaiaConstants::kChromeOSSource, | 93 new UbertokenFetcher(token_service_, this, GaiaConstants::kChromeOSSource, |
94 storage_partition_->GetURLRequestContext())); | 94 storage_partition_->GetURLRequestContext())); |
95 ubertoken_fetcher_->StartFetchingToken(account_id_); | 95 ubertoken_fetcher_->StartFetchingToken(account_id_); |
96 } | 96 } |
97 | 97 |
98 void ArcAuthContext::OnUbertokenSuccess(const std::string& token) { | 98 void ArcAuthContext::OnUbertokenSuccess(const std::string& token) { |
99 ResetFetchers(); | 99 ResetFetchers(); |
100 merger_fetcher_.reset( | 100 merger_fetcher_.reset( |
101 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, | 101 new GaiaAuthFetcher(this, GaiaConstants::kChromeOSSource, |
102 storage_partition_->GetURLRequestContext())); | 102 storage_partition_->GetURLRequestContext())); |
103 merger_fetcher_->StartMergeSession(token, std::string()); | 103 merger_fetcher_->StartMergeSession(token, std::string()); |
104 } | 104 } |
105 | 105 |
106 void ArcAuthContext::OnUbertokenFailure(const GoogleServiceAuthError& error) { | 106 void ArcAuthContext::OnUbertokenFailure(const GoogleServiceAuthError& error) { |
107 VLOG(2) << "Failed to get ubertoken " << error.ToString() << "."; | 107 LOG(WARNING) << "Failed to get ubertoken " << error.ToString() << "."; |
108 ResetFetchers(); | 108 ResetFetchers(); |
109 base::ResetAndReturn(&callback_).Run(nullptr); | 109 base::ResetAndReturn(&callback_).Run(nullptr); |
110 } | 110 } |
111 | 111 |
112 void ArcAuthContext::OnMergeSessionSuccess(const std::string& data) { | 112 void ArcAuthContext::OnMergeSessionSuccess(const std::string& data) { |
113 context_prepared_ = true; | 113 context_prepared_ = true; |
114 ResetFetchers(); | 114 ResetFetchers(); |
115 base::ResetAndReturn(&callback_) | 115 base::ResetAndReturn(&callback_) |
116 .Run(storage_partition_->GetURLRequestContext()); | 116 .Run(storage_partition_->GetURLRequestContext()); |
117 } | 117 } |
118 | 118 |
119 void ArcAuthContext::OnMergeSessionFailure( | 119 void ArcAuthContext::OnMergeSessionFailure( |
120 const GoogleServiceAuthError& error) { | 120 const GoogleServiceAuthError& error) { |
121 VLOG(2) << "Failed to merge gaia session " << error.ToString() << "."; | 121 LOG(WARNING) << "Failed to merge gaia session " << error.ToString() << "."; |
122 ResetFetchers(); | 122 ResetFetchers(); |
123 base::ResetAndReturn(&callback_).Run(nullptr); | 123 base::ResetAndReturn(&callback_).Run(nullptr); |
124 } | 124 } |
125 | 125 |
126 void ArcAuthContext::ResetFetchers() { | 126 void ArcAuthContext::ResetFetchers() { |
127 merger_fetcher_.reset(); | 127 merger_fetcher_.reset(); |
128 ubertoken_fetcher_.reset(); | 128 ubertoken_fetcher_.reset(); |
129 } | 129 } |
130 | 130 |
131 } // namespace arc | 131 } // namespace arc |
OLD | NEW |