| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/gaia/gaia_oauth_client.h" | 5 #include "google_apis/gaia/gaia_oauth_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 scoped_ptr<net::URLFetcher> old_request = request_.Pass(); | 179 scoped_ptr<net::URLFetcher> old_request = request_.Pass(); |
| 180 DCHECK_EQ(source, old_request.get()); | 180 DCHECK_EQ(source, old_request.get()); |
| 181 | 181 |
| 182 // RC_BAD_REQUEST means the arguments are invalid. No point retrying. We are | 182 // RC_BAD_REQUEST means the arguments are invalid. No point retrying. We are |
| 183 // done here. | 183 // done here. |
| 184 if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) { | 184 if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) { |
| 185 delegate_->OnOAuthError(); | 185 delegate_->OnOAuthError(); |
| 186 return; | 186 return; |
| 187 } | 187 } |
| 188 | 188 |
| 189 scoped_ptr<DictionaryValue> response_dict; | 189 scoped_ptr<base::DictionaryValue> response_dict; |
| 190 if (source->GetResponseCode() == net::HTTP_OK) { | 190 if (source->GetResponseCode() == net::HTTP_OK) { |
| 191 std::string data; | 191 std::string data; |
| 192 source->GetResponseAsString(&data); | 192 source->GetResponseAsString(&data); |
| 193 scoped_ptr<Value> message_value(base::JSONReader::Read(data)); | 193 scoped_ptr<base::Value> message_value(base::JSONReader::Read(data)); |
| 194 if (message_value.get() && | 194 if (message_value.get() && |
| 195 message_value->IsType(Value::TYPE_DICTIONARY)) { | 195 message_value->IsType(base::Value::TYPE_DICTIONARY)) { |
| 196 response_dict.reset( | 196 response_dict.reset( |
| 197 static_cast<DictionaryValue*>(message_value.release())); | 197 static_cast<base::DictionaryValue*>(message_value.release())); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 if (!response_dict.get()) { | 201 if (!response_dict.get()) { |
| 202 // If we don't have an access token yet and the the error was not | 202 // If we don't have an access token yet and the the error was not |
| 203 // RC_BAD_REQUEST, we may need to retry. | 203 // RC_BAD_REQUEST, we may need to retry. |
| 204 if ((source->GetMaxRetriesOn5xx() != -1) && | 204 if ((source->GetMaxRetriesOn5xx() != -1) && |
| 205 (num_retries_ >= source->GetMaxRetriesOn5xx())) { | 205 (num_retries_ >= source->GetMaxRetriesOn5xx())) { |
| 206 // Retry limit reached. Give up. | 206 // Retry limit reached. Give up. |
| 207 delegate_->OnNetworkError(source->GetResponseCode()); | 207 delegate_->OnNetworkError(source->GetResponseCode()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 delegate); | 281 delegate); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void GaiaOAuthClient::GetUserInfo(const std::string& access_token, | 284 void GaiaOAuthClient::GetUserInfo(const std::string& access_token, |
| 285 int max_retries, | 285 int max_retries, |
| 286 Delegate* delegate) { | 286 Delegate* delegate) { |
| 287 return core_->GetUserInfo(access_token, max_retries, delegate); | 287 return core_->GetUserInfo(access_token, max_retries, delegate); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace gaia | 290 } // namespace gaia |
| OLD | NEW |