| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/common/url_fetcher.h" | 5 #include "content/common/url_fetcher.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/memory/scoped_callback_factory.h" | 13 #include "base/memory/scoped_callback_factory.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop_proxy.h" | 15 #include "base/message_loop_proxy.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 #include "net/base/host_port_pair.h" |
| 22 #include "net/base/io_buffer.h" |
| 21 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 22 #include "net/base/io_buffer.h" | |
| 23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 24 #include "net/base/host_port_pair.h" | |
| 25 #include "net/http/http_request_headers.h" | 25 #include "net/http/http_request_headers.h" |
| 26 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 28 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
| 29 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| 30 #include "net/url_request/url_request_throttler_manager.h" | 30 #include "net/url_request/url_request_throttler_manager.h" |
| 31 | 31 |
| 32 static const int kBufferSize = 4096; | 32 static const int kBufferSize = 4096; |
| 33 const int URLFetcher::kInvalidHttpResponseCode = -1; | 33 const int URLFetcher::kInvalidHttpResponseCode = -1; |
| 34 | 34 |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 } | 717 } |
| 718 } | 718 } |
| 719 } | 719 } |
| 720 | 720 |
| 721 void URLFetcher::Core::RetryOrCompleteUrlFetch() { | 721 void URLFetcher::Core::RetryOrCompleteUrlFetch() { |
| 722 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 722 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 723 base::TimeDelta backoff_delay; | 723 base::TimeDelta backoff_delay; |
| 724 | 724 |
| 725 // Checks the response from server. | 725 // Checks the response from server. |
| 726 if (response_code_ >= 500 || | 726 if (response_code_ >= 500 || |
| 727 status_.os_error() == net::ERR_TEMPORARILY_THROTTLED) { | 727 status_.error() == net::ERR_TEMPORARILY_THROTTLED) { |
| 728 // When encountering a server error, we will send the request again | 728 // When encountering a server error, we will send the request again |
| 729 // after backoff time. | 729 // after backoff time. |
| 730 ++num_retries_; | 730 ++num_retries_; |
| 731 | 731 |
| 732 // Note that backoff_delay_ may be 0 because (a) the URLRequestThrottler | 732 // Note that backoff_delay_ may be 0 because (a) the URLRequestThrottler |
| 733 // code does not necessarily back off on the first error, and (b) it | 733 // code does not necessarily back off on the first error, and (b) it |
| 734 // only backs off on some of the 5xx status codes. | 734 // only backs off on some of the 5xx status codes. |
| 735 base::TimeTicks backoff_release_time = GetBackoffReleaseTime(); | 735 base::TimeTicks backoff_release_time = GetBackoffReleaseTime(); |
| 736 backoff_delay = backoff_release_time - base::TimeTicks::Now(); | 736 backoff_delay = backoff_release_time - base::TimeTicks::Now(); |
| 737 if (backoff_delay < base::TimeDelta()) | 737 if (backoff_delay < base::TimeDelta()) |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 // static | 1116 // static |
| 1117 int URLFetcher::GetNumFetcherCores() { | 1117 int URLFetcher::GetNumFetcherCores() { |
| 1118 return Core::g_registry.Get().size(); | 1118 return Core::g_registry.Get().size(); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 URLFetcher::Delegate* URLFetcher::delegate() const { | 1121 URLFetcher::Delegate* URLFetcher::delegate() const { |
| 1122 return core_->delegate(); | 1122 return core_->delegate(); |
| 1123 } | 1123 } |
| OLD | NEW |