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_mint_token_fetcher.h" | 5 #include "google_apis/gaia/oauth2_mint_token_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 URLFetcherDelegate* delegate) { | 55 URLFetcherDelegate* delegate) { |
56 bool empty_body = body.empty(); | 56 bool empty_body = body.empty(); |
57 URLFetcher* result = net::URLFetcher::Create( | 57 URLFetcher* result = net::URLFetcher::Create( |
58 0, url, | 58 0, url, |
59 empty_body ? URLFetcher::GET : URLFetcher::POST, | 59 empty_body ? URLFetcher::GET : URLFetcher::POST, |
60 delegate); | 60 delegate); |
61 | 61 |
62 result->SetRequestContext(getter); | 62 result->SetRequestContext(getter); |
63 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 63 result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
64 net::LOAD_DO_NOT_SAVE_COOKIES); | 64 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 65 // Fetchers are sometimes cancelled because a network change was detected, |
| 66 // especially at startup and after sign-in on ChromeOS. Retrying once should |
| 67 // be enough in those cases; let the fetcher retry up to 3 times just in case. |
| 68 // http://crbug.com/163710 |
| 69 result->SetAutomaticallyRetryOnNetworkChanges(3); |
65 | 70 |
66 if (!empty_body) | 71 if (!empty_body) |
67 result->SetUploadData("application/x-www-form-urlencoded", body); | 72 result->SetUploadData("application/x-www-form-urlencoded", body); |
68 if (!headers.empty()) | 73 if (!headers.empty()) |
69 result->SetExtraRequestHeaders(headers); | 74 result->SetExtraRequestHeaders(headers); |
70 | 75 |
71 return result; | 76 return result; |
72 } | 77 } |
73 } // namespace | 78 } // namespace |
74 | 79 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 CHECK(access_token); | 186 CHECK(access_token); |
182 std::string data; | 187 std::string data; |
183 source->GetResponseAsString(&data); | 188 source->GetResponseAsString(&data); |
184 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); | 189 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); |
185 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 190 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) |
186 return false; | 191 return false; |
187 | 192 |
188 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); | 193 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
189 return dict->GetString(kAccessTokenKey, access_token); | 194 return dict->GetString(kAccessTokenKey, access_token); |
190 } | 195 } |
OLD | NEW |