Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/chromeos/arc/auth/arc_background_auth_code_fetcher.cc

Issue 2742643002: arc: Change VLOG to LOG for ArcAuthContext and fetcher. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_context.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/auth/arc_background_auth_code_fetcher.h" 5 #include "chrome/browser/chromeos/arc/auth/arc_background_auth_code_fetcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 net::LOAD_BYPASS_CACHE); 110 net::LOAD_BYPASS_CACHE);
111 auth_code_fetcher_->SetAutomaticallyRetryOnNetworkChanges( 111 auth_code_fetcher_->SetAutomaticallyRetryOnNetworkChanges(
112 kGetAuthCodeNetworkRetry); 112 kGetAuthCodeNetworkRetry);
113 auth_code_fetcher_->SetExtraRequestHeaders(kGetAuthCodeHeaders); 113 auth_code_fetcher_->SetExtraRequestHeaders(kGetAuthCodeHeaders);
114 auth_code_fetcher_->Start(); 114 auth_code_fetcher_->Start();
115 } 115 }
116 116
117 void ArcBackgroundAuthCodeFetcher::OnGetTokenFailure( 117 void ArcBackgroundAuthCodeFetcher::OnGetTokenFailure(
118 const OAuth2TokenService::Request* request, 118 const OAuth2TokenService::Request* request,
119 const GoogleServiceAuthError& error) { 119 const GoogleServiceAuthError& error) {
120 VLOG(2) << "Failed to get LST " << error.ToString() << "."; 120 LOG(WARNING) << "Failed to get LST " << error.ToString() << ".";
121 ResetFetchers(); 121 ResetFetchers();
122 ReportResult(std::string(), OptInSilentAuthCode::NO_LST_TOKEN); 122 ReportResult(std::string(), OptInSilentAuthCode::NO_LST_TOKEN);
123 } 123 }
124 124
125 void ArcBackgroundAuthCodeFetcher::OnURLFetchComplete( 125 void ArcBackgroundAuthCodeFetcher::OnURLFetchComplete(
126 const net::URLFetcher* source) { 126 const net::URLFetcher* source) {
127 const int response_code = source->GetResponseCode(); 127 const int response_code = source->GetResponseCode();
128 std::string json_string; 128 std::string json_string;
129 source->GetResponseAsString(&json_string); 129 source->GetResponseAsString(&json_string);
130 130
131 ResetFetchers(); 131 ResetFetchers();
132 132
133 if (response_code != net::HTTP_OK) { 133 if (response_code != net::HTTP_OK) {
134 VLOG(2) << "Server returned wrong response code: " << response_code << "."; 134 LOG(WARNING) << "Server returned wrong response code: " << response_code
135 << ".";
135 OptInSilentAuthCode uma_status; 136 OptInSilentAuthCode uma_status;
136 if (response_code >= 400 && response_code < 500) 137 if (response_code >= 400 && response_code < 500)
137 uma_status = OptInSilentAuthCode::HTTP_CLIENT_FAILURE; 138 uma_status = OptInSilentAuthCode::HTTP_CLIENT_FAILURE;
138 if (response_code >= 500 && response_code < 600) 139 if (response_code >= 500 && response_code < 600)
139 uma_status = OptInSilentAuthCode::HTTP_SERVER_FAILURE; 140 uma_status = OptInSilentAuthCode::HTTP_SERVER_FAILURE;
140 else 141 else
141 uma_status = OptInSilentAuthCode::HTTP_UNKNOWN_FAILURE; 142 uma_status = OptInSilentAuthCode::HTTP_UNKNOWN_FAILURE;
142 ReportResult(std::string(), uma_status); 143 ReportResult(std::string(), uma_status);
143 return; 144 return;
144 } 145 }
145 146
146 JSONStringValueDeserializer deserializer(json_string); 147 JSONStringValueDeserializer deserializer(json_string);
147 std::string error_msg; 148 std::string error_msg;
148 std::unique_ptr<base::Value> auth_code_info = 149 std::unique_ptr<base::Value> auth_code_info =
149 deserializer.Deserialize(nullptr, &error_msg); 150 deserializer.Deserialize(nullptr, &error_msg);
150 if (!auth_code_info) { 151 if (!auth_code_info) {
151 VLOG(2) << "Unable to deserialize auth code json data: " << error_msg 152 LOG(WARNING) << "Unable to deserialize auth code json data: " << error_msg
152 << "."; 153 << ".";
153 ReportResult(std::string(), OptInSilentAuthCode::RESPONSE_PARSE_FAILURE); 154 ReportResult(std::string(), OptInSilentAuthCode::RESPONSE_PARSE_FAILURE);
154 return; 155 return;
155 } 156 }
156 157
157 std::unique_ptr<base::DictionaryValue> auth_code_dictionary = 158 std::unique_ptr<base::DictionaryValue> auth_code_dictionary =
158 base::DictionaryValue::From(std::move(auth_code_info)); 159 base::DictionaryValue::From(std::move(auth_code_info));
159 if (!auth_code_dictionary) { 160 if (!auth_code_dictionary) {
160 NOTREACHED(); 161 NOTREACHED();
161 ReportResult(std::string(), OptInSilentAuthCode::RESPONSE_PARSE_FAILURE); 162 ReportResult(std::string(), OptInSilentAuthCode::RESPONSE_PARSE_FAILURE);
162 return; 163 return;
163 } 164 }
164 165
165 std::string auth_code; 166 std::string auth_code;
166 if (!auth_code_dictionary->GetString(kToken, &auth_code) || 167 if (!auth_code_dictionary->GetString(kToken, &auth_code) ||
167 auth_code.empty()) { 168 auth_code.empty()) {
168 VLOG(2) << "Response does not contain auth code."; 169 LOG(WARNING) << "Response does not contain auth code.";
169 ReportResult(std::string(), OptInSilentAuthCode::NO_AUTH_CODE_IN_RESPONSE); 170 ReportResult(std::string(), OptInSilentAuthCode::NO_AUTH_CODE_IN_RESPONSE);
170 return; 171 return;
171 } 172 }
172 173
173 ReportResult(auth_code, OptInSilentAuthCode::SUCCESS); 174 ReportResult(auth_code, OptInSilentAuthCode::SUCCESS);
174 } 175 }
175 176
176 void ArcBackgroundAuthCodeFetcher::ResetFetchers() { 177 void ArcBackgroundAuthCodeFetcher::ResetFetchers() {
177 login_token_request_.reset(); 178 login_token_request_.reset();
178 auth_code_fetcher_.reset(); 179 auth_code_fetcher_.reset();
179 } 180 }
180 181
181 void ArcBackgroundAuthCodeFetcher::ReportResult( 182 void ArcBackgroundAuthCodeFetcher::ReportResult(
182 const std::string& auth_code, 183 const std::string& auth_code,
183 OptInSilentAuthCode uma_status) { 184 OptInSilentAuthCode uma_status) {
184 UpdateSilentAuthCodeUMA(uma_status); 185 UpdateSilentAuthCodeUMA(uma_status);
185 base::ResetAndReturn(&callback_) 186 base::ResetAndReturn(&callback_)
186 .Run(auth_code.empty() ? ArcAuthInfoFetcher::Status::FAILURE 187 .Run(auth_code.empty() ? ArcAuthInfoFetcher::Status::FAILURE
187 : ArcAuthInfoFetcher::Status::SUCCESS, 188 : ArcAuthInfoFetcher::Status::SUCCESS,
188 auth_code); 189 auth_code);
189 } 190 }
190 191
191 } // namespace arc 192 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698