| 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/oauth2_api_call_flow.h" | 5 #include "google_apis/gaia/oauth2_api_call_flow.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/profiler/scoped_profile.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "google_apis/gaia/gaia_urls.h" | 13 #include "google_apis/gaia/gaia_urls.h" |
| 13 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" | 14 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" |
| 14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 16 #include "net/http/http_status_code.h" | 17 #include "net/http/http_status_code.h" |
| 17 #include "net/url_request/url_fetcher.h" | 18 #include "net/url_request/url_fetcher.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 19 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
| 20 | 21 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 std::string OAuth2ApiCallFlow::CreateApiCallBodyContentType() { | 132 std::string OAuth2ApiCallFlow::CreateApiCallBodyContentType() { |
| 132 return "application/x-www-form-urlencoded"; | 133 return "application/x-www-form-urlencoded"; |
| 133 } | 134 } |
| 134 | 135 |
| 135 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() { | 136 OAuth2AccessTokenFetcher* OAuth2ApiCallFlow::CreateAccessTokenFetcher() { |
| 136 return new OAuth2AccessTokenFetcherImpl(this, context_, refresh_token_); | 137 return new OAuth2AccessTokenFetcherImpl(this, context_, refresh_token_); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { | 140 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { |
| 141 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. |
| 142 tracked_objects::ScopedProfile tracking_profile( |
| 143 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 144 "422577 OAuth2ApiCallFlow::OnURLFetchComplete")); |
| 145 |
| 140 CHECK(source); | 146 CHECK(source); |
| 141 CHECK_EQ(API_CALL_STARTED, state_); | 147 CHECK_EQ(API_CALL_STARTED, state_); |
| 142 EndApiCall(source); | 148 EndApiCall(source); |
| 143 } | 149 } |
| 144 | 150 |
| 145 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token, | 151 void OAuth2ApiCallFlow::OnGetTokenSuccess(const std::string& access_token, |
| 146 const base::Time& expiration_time) { | 152 const base::Time& expiration_time) { |
| 147 access_token_ = access_token; | 153 access_token_ = access_token; |
| 148 EndMintAccessToken(NULL); | 154 EndMintAccessToken(NULL); |
| 149 } | 155 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 170 // especially at startup and after sign-in on ChromeOS. Retrying once should | 176 // especially at startup and after sign-in on ChromeOS. Retrying once should |
| 171 // be enough in those cases; let the fetcher retry up to 3 times just in case. | 177 // be enough in those cases; let the fetcher retry up to 3 times just in case. |
| 172 // http://crbug.com/163710 | 178 // http://crbug.com/163710 |
| 173 result->SetAutomaticallyRetryOnNetworkChanges(3); | 179 result->SetAutomaticallyRetryOnNetworkChanges(3); |
| 174 | 180 |
| 175 if (!empty_body) | 181 if (!empty_body) |
| 176 result->SetUploadData(CreateApiCallBodyContentType(), body); | 182 result->SetUploadData(CreateApiCallBodyContentType(), body); |
| 177 | 183 |
| 178 return result; | 184 return result; |
| 179 } | 185 } |
| OLD | NEW |