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_tracker.h" | |
12 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
13 #include "google_apis/gaia/gaia_urls.h" | 12 #include "google_apis/gaia/gaia_urls.h" |
14 #include "net/base/escape.h" | 13 #include "net/base/escape.h" |
15 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
16 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
17 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
18 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
19 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
20 | 19 |
21 using net::ResponseCookies; | 20 using net::ResponseCookies; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 state_ = API_CALL_DONE; | 59 state_ = API_CALL_DONE; |
61 ProcessApiCallSuccess(source); | 60 ProcessApiCallSuccess(source); |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 std::string OAuth2ApiCallFlow::CreateApiCallBodyContentType() { | 64 std::string OAuth2ApiCallFlow::CreateApiCallBodyContentType() { |
66 return "application/x-www-form-urlencoded"; | 65 return "application/x-www-form-urlencoded"; |
67 } | 66 } |
68 | 67 |
69 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { | 68 void OAuth2ApiCallFlow::OnURLFetchComplete(const net::URLFetcher* source) { |
70 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422577 is fixed. | |
71 tracked_objects::ScopedTracker tracking_profile( | |
72 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
73 "422577 OAuth2ApiCallFlow::OnURLFetchComplete")); | |
74 | |
75 CHECK(source); | 69 CHECK(source); |
76 CHECK_EQ(API_CALL_STARTED, state_); | 70 CHECK_EQ(API_CALL_STARTED, state_); |
77 EndApiCall(source); | 71 EndApiCall(source); |
78 } | 72 } |
79 | 73 |
80 URLFetcher* OAuth2ApiCallFlow::CreateURLFetcher( | 74 URLFetcher* OAuth2ApiCallFlow::CreateURLFetcher( |
81 net::URLRequestContextGetter* context, | 75 net::URLRequestContextGetter* context, |
82 const std::string& access_token) { | 76 const std::string& access_token) { |
83 std::string body = CreateApiCallBody(); | 77 std::string body = CreateApiCallBody(); |
84 bool empty_body = body.empty(); | 78 bool empty_body = body.empty(); |
(...skipping 11 matching lines...) Expand all Loading... |
96 // especially at startup and after sign-in on ChromeOS. Retrying once should | 90 // especially at startup and after sign-in on ChromeOS. Retrying once should |
97 // be enough in those cases; let the fetcher retry up to 3 times just in case. | 91 // be enough in those cases; let the fetcher retry up to 3 times just in case. |
98 // http://crbug.com/163710 | 92 // http://crbug.com/163710 |
99 result->SetAutomaticallyRetryOnNetworkChanges(3); | 93 result->SetAutomaticallyRetryOnNetworkChanges(3); |
100 | 94 |
101 if (!empty_body) | 95 if (!empty_body) |
102 result->SetUploadData(CreateApiCallBodyContentType(), body); | 96 result->SetUploadData(CreateApiCallBodyContentType(), body); |
103 | 97 |
104 return result; | 98 return result; |
105 } | 99 } |
OLD | NEW |