| 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 "webkit/appcache/appcache_update_job.h" | 5 #include "webkit/appcache/appcache_update_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // can either fetch to an in-memory string or write the response | 91 // can either fetch to an in-memory string or write the response |
| 92 // data out to the disk cache. | 92 // data out to the disk cache. |
| 93 AppCacheUpdateJob::URLFetcher::URLFetcher( | 93 AppCacheUpdateJob::URLFetcher::URLFetcher( |
| 94 const GURL& url, FetchType fetch_type, AppCacheUpdateJob* job) | 94 const GURL& url, FetchType fetch_type, AppCacheUpdateJob* job) |
| 95 : url_(url), | 95 : url_(url), |
| 96 job_(job), | 96 job_(job), |
| 97 fetch_type_(fetch_type), | 97 fetch_type_(fetch_type), |
| 98 retry_503_attempts_(0), | 98 retry_503_attempts_(0), |
| 99 buffer_(new net::IOBuffer(kBufferSize)), | 99 buffer_(new net::IOBuffer(kBufferSize)), |
| 100 ALLOW_THIS_IN_INITIALIZER_LIST( | 100 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 101 request_(new net::URLRequest(url, this))) { | 101 request_(new net::URLRequest(url, |
| 102 this, |
| 103 job->service_->request_context()))) { |
| 102 } | 104 } |
| 103 | 105 |
| 104 AppCacheUpdateJob::URLFetcher::~URLFetcher() { | 106 AppCacheUpdateJob::URLFetcher::~URLFetcher() { |
| 105 } | 107 } |
| 106 | 108 |
| 107 void AppCacheUpdateJob::URLFetcher::Start() { | 109 void AppCacheUpdateJob::URLFetcher::Start() { |
| 108 request_->set_context(job_->service_->request_context()); | |
| 109 request_->set_first_party_for_cookies(job_->manifest_url_); | 110 request_->set_first_party_for_cookies(job_->manifest_url_); |
| 110 request_->set_load_flags(request_->load_flags() | | 111 request_->set_load_flags(request_->load_flags() | |
| 111 net::LOAD_DISABLE_INTERCEPT); | 112 net::LOAD_DISABLE_INTERCEPT); |
| 112 if (existing_response_headers_) | 113 if (existing_response_headers_) |
| 113 AddConditionalHeaders(existing_response_headers_); | 114 AddConditionalHeaders(existing_response_headers_); |
| 114 request_->Start(); | 115 request_->Start(); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( | 118 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( |
| 118 net::URLRequest* request, const GURL& new_url, bool* defer_redirect) { | 119 net::URLRequest* request, const GURL& new_url, bool* defer_redirect) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 281 |
| 281 delete this; | 282 delete this; |
| 282 } | 283 } |
| 283 | 284 |
| 284 bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() { | 285 bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() { |
| 285 if (retry_503_attempts_ >= kMax503Retries || | 286 if (retry_503_attempts_ >= kMax503Retries || |
| 286 !request_->response_headers()->HasHeaderValue("retry-after", "0")) { | 287 !request_->response_headers()->HasHeaderValue("retry-after", "0")) { |
| 287 return false; | 288 return false; |
| 288 } | 289 } |
| 289 ++retry_503_attempts_; | 290 ++retry_503_attempts_; |
| 290 request_.reset(new net::URLRequest(url_, this)); | 291 request_.reset(new net::URLRequest(url_, |
| 292 this, |
| 293 job_->service_->request_context())); |
| 291 Start(); | 294 Start(); |
| 292 return true; | 295 return true; |
| 293 } | 296 } |
| 294 | 297 |
| 295 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service, | 298 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service, |
| 296 AppCacheGroup* group) | 299 AppCacheGroup* group) |
| 297 : service_(service), | 300 : service_(service), |
| 298 manifest_url_(group->manifest_url()), | 301 manifest_url_(group->manifest_url()), |
| 299 group_(group), | 302 group_(group), |
| 300 update_type_(UNKNOWN_TYPE), | 303 update_type_(UNKNOWN_TYPE), |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 | 1341 |
| 1339 // Break the connection with the group so the group cannot call delete | 1342 // Break the connection with the group so the group cannot call delete |
| 1340 // on this object after we've posted a task to delete ourselves. | 1343 // on this object after we've posted a task to delete ourselves. |
| 1341 group_->SetUpdateStatus(AppCacheGroup::IDLE); | 1344 group_->SetUpdateStatus(AppCacheGroup::IDLE); |
| 1342 group_ = NULL; | 1345 group_ = NULL; |
| 1343 | 1346 |
| 1344 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1347 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1345 } | 1348 } |
| 1346 | 1349 |
| 1347 } // namespace appcache | 1350 } // namespace appcache |
| OLD | NEW |