OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/printing/cloud_print/privet_url_fetcher.h" | 5 #include "chrome/browser/printing/cloud_print/privet_url_fetcher.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/debug/dump_without_crashing.h" | |
15 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
16 #include "base/location.h" | 15 #include "base/location.h" |
17 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
18 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
19 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/printing/cloud_print/privet_constants.h" | 22 #include "chrome/browser/printing/cloud_print/privet_constants.h" |
24 #include "components/data_use_measurement/core/data_use_user_data.h" | 23 #include "components/data_use_measurement/core/data_use_user_data.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 url_fetcher_->Start(); | 194 url_fetcher_->Start(); |
196 } else { | 195 } else { |
197 delegate_->OnError(this, UNKNOWN_ERROR); | 196 delegate_->OnError(this, UNKNOWN_ERROR); |
198 } | 197 } |
199 } | 198 } |
200 | 199 |
201 void PrivetURLFetcher::Start() { | 200 void PrivetURLFetcher::Start() { |
202 DCHECK_EQ(tries_, 0); // We haven't called |Start()| yet. | 201 DCHECK_EQ(tries_, 0); // We haven't called |Start()| yet. |
203 | 202 |
204 if (!url_.is_valid()) { | 203 if (!url_.is_valid()) { |
205 // Not yet clear why it's possible. crbug.com/513505 | |
206 base::debug::DumpWithoutCrashing(); | |
207 return delegate_->OnError(this, UNKNOWN_ERROR); | 204 return delegate_->OnError(this, UNKNOWN_ERROR); |
208 } | 205 } |
209 | 206 |
210 if (!send_empty_privet_token_) { | 207 if (!send_empty_privet_token_) { |
211 std::string privet_access_token; | 208 std::string privet_access_token; |
212 privet_access_token = GetPrivetAccessToken(); | 209 privet_access_token = GetPrivetAccessToken(); |
213 if (privet_access_token.empty()) { | 210 if (privet_access_token.empty()) { |
214 RequestTokenRefresh(); | 211 RequestTokenRefresh(); |
215 return; | 212 return; |
216 } | 213 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 382 } |
386 | 383 |
387 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { | 384 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { |
388 return (error == kPrivetErrorDeviceBusy) || | 385 return (error == kPrivetErrorDeviceBusy) || |
389 (error == kPrivetV3ErrorDeviceBusy) || | 386 (error == kPrivetV3ErrorDeviceBusy) || |
390 (error == kPrivetErrorPendingUserAction) || | 387 (error == kPrivetErrorPendingUserAction) || |
391 (error == kPrivetErrorPrinterBusy); | 388 (error == kPrivetErrorPrinterBusy); |
392 } | 389 } |
393 | 390 |
394 } // namespace cloud_print | 391 } // namespace cloud_print |
OLD | NEW |