| OLD | NEW |
| 1 // Copyright (c) 2010 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 "chrome/common/net/url_fetcher.h" | 5 #include "chrome/common/net/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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/lock.h" | 11 #include "base/lock.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 DISALLOW_COPY_AND_ASSIGN(Registry); | 84 DISALLOW_COPY_AND_ASSIGN(Registry); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 ~Core(); | 87 ~Core(); |
| 88 | 88 |
| 89 // Wrapper functions that allow us to ensure actions happen on the right | 89 // Wrapper functions that allow us to ensure actions happen on the right |
| 90 // thread. | 90 // thread. |
| 91 void StartURLRequest(); | 91 void StartURLRequest(); |
| 92 void StartURLRequestWhenAppropriate(); | 92 void StartURLRequestWhenAppropriate(); |
| 93 void CancelURLRequest(); | 93 void CancelURLRequest(); |
| 94 void OnCompletedURLRequest(const URLRequestStatus& status); | 94 void OnCompletedURLRequest(const net::URLRequestStatus& status); |
| 95 void NotifyMalformedContent(); | 95 void NotifyMalformedContent(); |
| 96 | 96 |
| 97 // Deletes the request, removes it from the registry, and removes the | 97 // Deletes the request, removes it from the registry, and removes the |
| 98 // destruction observer. | 98 // destruction observer. |
| 99 void ReleaseRequest(); | 99 void ReleaseRequest(); |
| 100 | 100 |
| 101 // Returns the max value of exponential back-off release time for | 101 // Returns the max value of exponential back-off release time for |
| 102 // |original_url_| and |url_|. | 102 // |original_url_| and |url_|. |
| 103 base::TimeTicks GetBackoffReleaseTime(); | 103 base::TimeTicks GetBackoffReleaseTime(); |
| 104 | 104 |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 ReleaseRequest(); | 401 ReleaseRequest(); |
| 402 } | 402 } |
| 403 // Release the reference to the request context. There could be multiple | 403 // Release the reference to the request context. There could be multiple |
| 404 // references to URLFetcher::Core at this point so it may take a while to | 404 // references to URLFetcher::Core at this point so it may take a while to |
| 405 // delete the object, but we cannot delay the destruction of the request | 405 // delete the object, but we cannot delay the destruction of the request |
| 406 // context. | 406 // context. |
| 407 request_context_getter_ = NULL; | 407 request_context_getter_ = NULL; |
| 408 was_cancelled_ = true; | 408 was_cancelled_ = true; |
| 409 } | 409 } |
| 410 | 410 |
| 411 void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { | 411 void URLFetcher::Core::OnCompletedURLRequest( |
| 412 const net::URLRequestStatus& status) { |
| 412 DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); | 413 DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); |
| 413 | 414 |
| 414 // Checks the response from server. | 415 // Checks the response from server. |
| 415 if (response_code_ >= 500 || | 416 if (response_code_ >= 500 || |
| 416 status.os_error() == net::ERR_TEMPORARILY_THROTTLED) { | 417 status.os_error() == net::ERR_TEMPORARILY_THROTTLED) { |
| 417 // When encountering a server error, we will send the request again | 418 // When encountering a server error, we will send the request again |
| 418 // after backoff time. | 419 // after backoff time. |
| 419 ++num_retries_; | 420 ++num_retries_; |
| 420 // Restarts the request if we still need to notify the delegate. | 421 // Restarts the request if we still need to notify the delegate. |
| 421 if (delegate_) { | 422 if (delegate_) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 521 } |
| 521 | 522 |
| 522 // static | 523 // static |
| 523 void URLFetcher::CancelAll() { | 524 void URLFetcher::CancelAll() { |
| 524 Core::CancelAll(); | 525 Core::CancelAll(); |
| 525 } | 526 } |
| 526 | 527 |
| 527 URLFetcher::Delegate* URLFetcher::delegate() const { | 528 URLFetcher::Delegate* URLFetcher::delegate() const { |
| 528 return core_->delegate(); | 529 return core_->delegate(); |
| 529 } | 530 } |
| OLD | NEW |