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/local_discovery/privet_url_fetcher.h" | 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 byte_range_end_ = end; | 141 byte_range_end_ = end; |
142 has_byte_range_ = true; | 142 has_byte_range_ = true; |
143 } | 143 } |
144 | 144 |
145 void PrivetURLFetcher::Try() { | 145 void PrivetURLFetcher::Try() { |
146 tries_++; | 146 tries_++; |
147 if (tries_ < kPrivetMaxRetries) { | 147 if (tries_ < kPrivetMaxRetries) { |
148 | 148 |
149 | 149 |
150 url_fetcher_.reset(net::URLFetcher::Create(url_, request_type_, this)); | 150 url_fetcher_.reset(net::URLFetcher::Create(url_, request_type_, this)); |
151 url_fetcher_->SetRequestContext(request_context_); | 151 url_fetcher_->SetRequestContext(request_context_.get()); |
152 | 152 |
153 if (v3_mode_) { | 153 if (v3_mode_) { |
154 std::string auth_token = delegate_->GetAuthToken(); | 154 std::string auth_token = delegate_->GetAuthToken(); |
155 | 155 |
156 url_fetcher_->AddExtraRequestHeader( | 156 url_fetcher_->AddExtraRequestHeader( |
157 std::string(kXPrivetAuthTokenHeaderPrefix) + auth_token); | 157 std::string(kXPrivetAuthTokenHeaderPrefix) + auth_token); |
158 } else { | 158 } else { |
159 std::string token = GetPrivetAccessToken(); | 159 std::string token = GetPrivetAccessToken(); |
160 | 160 |
161 if (token.empty()) | 161 if (token.empty()) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 367 } |
368 | 368 |
369 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { | 369 bool PrivetURLFetcher::PrivetErrorTransient(const std::string& error) { |
370 return (error == kPrivetErrorDeviceBusy) || | 370 return (error == kPrivetErrorDeviceBusy) || |
371 (error == kPrivetV3ErrorDeviceBusy) || | 371 (error == kPrivetV3ErrorDeviceBusy) || |
372 (error == kPrivetErrorPendingUserAction) || | 372 (error == kPrivetErrorPendingUserAction) || |
373 (error == kPrivetErrorPrinterBusy); | 373 (error == kPrivetErrorPrinterBusy); |
374 } | 374 } |
375 | 375 |
376 } // namespace local_discovery | 376 } // namespace local_discovery |
OLD | NEW |