| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 // Be generous in the conversion -- if any characters lie outside of |charset| | 65 // Be generous in the conversion -- if any characters lie outside of |charset| |
| 66 // (i.e. invalid), then substitute them with U+FFFD rather than failing. | 66 // (i.e. invalid), then substitute them with U+FFFD rather than failing. |
| 67 ConvertToUTF16WithSubstitutions(bytes, codepage, utf16); | 67 ConvertToUTF16WithSubstitutions(bytes, codepage, utf16); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( | 72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( |
| 73 URLRequestContext* url_request_context) | 73 URLRequestContext* url_request_context) |
| 74 : weak_factory_(this), | 74 : url_request_context_(url_request_context), |
| 75 url_request_context_(url_request_context), | |
| 76 buf_(new IOBuffer(kBufSize)), | 75 buf_(new IOBuffer(kBufSize)), |
| 77 next_id_(0), | 76 next_id_(0), |
| 78 cur_request_id_(0), | 77 cur_request_id_(0), |
| 79 result_code_(OK), | 78 result_code_(OK), |
| 80 result_text_(NULL), | 79 result_text_(NULL), |
| 81 max_response_bytes_(kDefaultMaxResponseBytes), | 80 max_response_bytes_(kDefaultMaxResponseBytes), |
| 82 max_duration_(base::TimeDelta::FromMilliseconds(kDefaultMaxDurationMs)) { | 81 max_duration_(base::TimeDelta::FromMilliseconds(kDefaultMaxDurationMs)), |
| 82 weak_factory_(this) { |
| 83 DCHECK(url_request_context); | 83 DCHECK(url_request_context); |
| 84 } | 84 } |
| 85 | 85 |
| 86 ProxyScriptFetcherImpl::~ProxyScriptFetcherImpl() { | 86 ProxyScriptFetcherImpl::~ProxyScriptFetcherImpl() { |
| 87 // The URLRequest's destructor will cancel the outstanding request, and | 87 // The URLRequest's destructor will cancel the outstanding request, and |
| 88 // ensure that the delegate (this) is not called again. | 88 // ensure that the delegate (this) is not called again. |
| 89 } | 89 } |
| 90 | 90 |
| 91 base::TimeDelta ProxyScriptFetcherImpl::SetTimeoutConstraint( | 91 base::TimeDelta ProxyScriptFetcherImpl::SetTimeoutConstraint( |
| 92 base::TimeDelta timeout) { | 92 base::TimeDelta timeout) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // is still applicable. | 311 // is still applicable. |
| 312 if (cur_request_id_ != id) | 312 if (cur_request_id_ != id) |
| 313 return; | 313 return; |
| 314 | 314 |
| 315 DCHECK(cur_request_.get()); | 315 DCHECK(cur_request_.get()); |
| 316 result_code_ = ERR_TIMED_OUT; | 316 result_code_ = ERR_TIMED_OUT; |
| 317 cur_request_->Cancel(); | 317 cur_request_->Cancel(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 } // namespace net | 320 } // namespace net |
| OLD | NEW |