| 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 "net/proxy/proxy_script_fetcher_impl.h" | 5 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 12 #include "net/base/data_url.h" | 11 #include "net/base/data_url.h" |
| 13 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 14 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
| 15 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/net_string_util.h" |
| 16 #include "net/base/request_priority.h" | 16 #include "net/base/request_priority.h" |
| 17 #include "net/cert/cert_status_flags.h" | 17 #include "net/cert/cert_status_flags.h" |
| 18 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 19 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| 20 | 20 |
| 21 // TODO(eroman): | 21 // TODO(eroman): |
| 22 // - Support auth-prompts (http://crbug.com/77366) | 22 // - Support auth-prompts (http://crbug.com/77366) |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 49 // Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul | 49 // Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul |
| 50 // to |*utf16|. | 50 // to |*utf16|. |
| 51 // If |charset| is empty, then we don't know what it was and guess. | 51 // If |charset| is empty, then we don't know what it was and guess. |
| 52 void ConvertResponseToUTF16(const std::string& charset, | 52 void ConvertResponseToUTF16(const std::string& charset, |
| 53 const std::string& bytes, | 53 const std::string& bytes, |
| 54 base::string16* utf16) { | 54 base::string16* utf16) { |
| 55 const char* codepage; | 55 const char* codepage; |
| 56 | 56 |
| 57 if (charset.empty()) { | 57 if (charset.empty()) { |
| 58 // Assume ISO-8859-1 if no charset was specified. | 58 // Assume ISO-8859-1 if no charset was specified. |
| 59 codepage = base::kCodepageLatin1; | 59 codepage = kLatin1; |
| 60 } else { | 60 } else { |
| 61 // Otherwise trust the charset that was provided. | 61 // Otherwise trust the charset that was provided. |
| 62 codepage = charset.c_str(); | 62 codepage = charset.c_str(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // We will be generous in the conversion -- if any characters lie | 65 // Be generous in the conversion -- if any characters lie outside of |charset| |
| 66 // outside of |charset| (i.e. invalid), then substitute them with | 66 // (i.e. invalid), then substitute them with U+FFFD rather than failing. |
| 67 // U+FFFD rather than failing. | 67 ConvertToUTF16WithSubstitutions(bytes, codepage, utf16); |
| 68 base::CodepageToUTF16(bytes, codepage, | |
| 69 base::OnStringConversionError::SUBSTITUTE, | |
| 70 utf16); | |
| 71 } | 68 } |
| 72 | 69 |
| 73 } // namespace | 70 } // namespace |
| 74 | 71 |
| 75 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( | 72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( |
| 76 URLRequestContext* url_request_context) | 73 URLRequestContext* url_request_context) |
| 77 : weak_factory_(this), | 74 : weak_factory_(this), |
| 78 url_request_context_(url_request_context), | 75 url_request_context_(url_request_context), |
| 79 buf_(new IOBuffer(kBufSize)), | 76 buf_(new IOBuffer(kBufSize)), |
| 80 next_id_(0), | 77 next_id_(0), |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // is still applicable. | 311 // is still applicable. |
| 315 if (cur_request_id_ != id) | 312 if (cur_request_id_ != id) |
| 316 return; | 313 return; |
| 317 | 314 |
| 318 DCHECK(cur_request_.get()); | 315 DCHECK(cur_request_.get()); |
| 319 result_code_ = ERR_TIMED_OUT; | 316 result_code_ = ERR_TIMED_OUT; |
| 320 cur_request_->Cancel(); | 317 cur_request_->Cancel(); |
| 321 } | 318 } |
| 322 | 319 |
| 323 } // namespace net | 320 } // namespace net |
| OLD | NEW |