OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/net/url_fetcher.h" | 5 #include "chrome/browser/net/url_fetcher.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/thread.h" | 9 #include "base/thread.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 request_context_ = NULL; | 247 request_context_ = NULL; |
248 } | 248 } |
249 | 249 |
250 void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { | 250 void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { |
251 DCHECK(MessageLoop::current() == delegate_loop_); | 251 DCHECK(MessageLoop::current() == delegate_loop_); |
252 | 252 |
253 // Checks the response from server. | 253 // Checks the response from server. |
254 if (response_code_ >= 500) { | 254 if (response_code_ >= 500) { |
255 // When encountering a server error, we will send the request again | 255 // When encountering a server error, we will send the request again |
256 // after backoff time. | 256 // after backoff time. |
257 const int wait = | 257 const int64 wait = |
258 protect_entry_->UpdateBackoff(URLFetcherProtectEntry::FAILURE); | 258 protect_entry_->UpdateBackoff(URLFetcherProtectEntry::FAILURE); |
259 ++num_retries_; | 259 ++num_retries_; |
260 // Restarts the request if we still need to notify the delegate. | 260 // Restarts the request if we still need to notify the delegate. |
261 if (delegate_) { | 261 if (delegate_) { |
262 if (num_retries_ <= protect_entry_->max_retries()) { | 262 if (num_retries_ <= protect_entry_->max_retries()) { |
263 io_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod( | 263 io_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod( |
264 this, &Core::StartURLRequest), wait); | 264 this, &Core::StartURLRequest), wait); |
265 } else { | 265 } else { |
266 delegate_->OnURLFetchComplete(fetcher_, url_, status, response_code_, | 266 delegate_->OnURLFetchComplete(fetcher_, url_, status, response_code_, |
267 cookies_, data_); | 267 cookies_, data_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 core_->Start(); | 306 core_->Start(); |
307 } | 307 } |
308 | 308 |
309 const GURL& URLFetcher::url() const { | 309 const GURL& URLFetcher::url() const { |
310 return core_->url_; | 310 return core_->url_; |
311 } | 311 } |
312 | 312 |
313 URLFetcher::Delegate* URLFetcher::delegate() const { | 313 URLFetcher::Delegate* URLFetcher::delegate() const { |
314 return core_->delegate(); | 314 return core_->delegate(); |
315 } | 315 } |
OLD | NEW |