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 "content/browser/appcache/appcache_update_job.h" | 5 #include "content/browser/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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // data out to the disk cache. | 117 // data out to the disk cache. |
118 AppCacheUpdateJob::URLFetcher::URLFetcher(const GURL& url, | 118 AppCacheUpdateJob::URLFetcher::URLFetcher(const GURL& url, |
119 FetchType fetch_type, | 119 FetchType fetch_type, |
120 AppCacheUpdateJob* job) | 120 AppCacheUpdateJob* job) |
121 : url_(url), | 121 : url_(url), |
122 job_(job), | 122 job_(job), |
123 fetch_type_(fetch_type), | 123 fetch_type_(fetch_type), |
124 retry_503_attempts_(0), | 124 retry_503_attempts_(0), |
125 buffer_(new net::IOBuffer(kBufferSize)), | 125 buffer_(new net::IOBuffer(kBufferSize)), |
126 request_(job->service_->request_context() | 126 request_(job->service_->request_context() |
127 ->CreateRequest(url, net::DEFAULT_PRIORITY, this, NULL)), | 127 ->CreateRequest(url, net::DEFAULT_PRIORITY, this)), |
128 result_(UPDATE_OK), | 128 result_(UPDATE_OK), |
129 redirect_response_code_(-1) {} | 129 redirect_response_code_(-1) {} |
130 | 130 |
131 AppCacheUpdateJob::URLFetcher::~URLFetcher() { | 131 AppCacheUpdateJob::URLFetcher::~URLFetcher() { |
132 } | 132 } |
133 | 133 |
134 void AppCacheUpdateJob::URLFetcher::Start() { | 134 void AppCacheUpdateJob::URLFetcher::Start() { |
135 request_->set_first_party_for_cookies(job_->manifest_url_); | 135 request_->set_first_party_for_cookies(job_->manifest_url_); |
136 if (existing_response_headers_.get()) | 136 if (existing_response_headers_.get()) |
137 AddConditionalHeaders(existing_response_headers_.get()); | 137 AddConditionalHeaders(existing_response_headers_.get()); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() { | 349 bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() { |
350 if (retry_503_attempts_ >= kMax503Retries || | 350 if (retry_503_attempts_ >= kMax503Retries || |
351 !request_->response_headers()->HasHeaderValue("retry-after", "0")) { | 351 !request_->response_headers()->HasHeaderValue("retry-after", "0")) { |
352 return false; | 352 return false; |
353 } | 353 } |
354 ++retry_503_attempts_; | 354 ++retry_503_attempts_; |
355 result_ = UPDATE_OK; | 355 result_ = UPDATE_OK; |
356 request_ = job_->service_->request_context()->CreateRequest( | 356 request_ = job_->service_->request_context()->CreateRequest( |
357 url_, net::DEFAULT_PRIORITY, this, NULL); | 357 url_, net::DEFAULT_PRIORITY, this); |
358 Start(); | 358 Start(); |
359 return true; | 359 return true; |
360 } | 360 } |
361 | 361 |
362 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheServiceImpl* service, | 362 AppCacheUpdateJob::AppCacheUpdateJob(AppCacheServiceImpl* service, |
363 AppCacheGroup* group) | 363 AppCacheGroup* group) |
364 : service_(service), | 364 : service_(service), |
365 manifest_url_(group->manifest_url()), | 365 manifest_url_(group->manifest_url()), |
366 group_(group), | 366 group_(group), |
367 update_type_(UNKNOWN_TYPE), | 367 update_type_(UNKNOWN_TYPE), |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 | 1621 |
1622 // Break the connection with the group so the group cannot call delete | 1622 // Break the connection with the group so the group cannot call delete |
1623 // on this object after we've posted a task to delete ourselves. | 1623 // on this object after we've posted a task to delete ourselves. |
1624 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1624 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
1625 group_ = NULL; | 1625 group_ = NULL; |
1626 | 1626 |
1627 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1627 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1628 } | 1628 } |
1629 | 1629 |
1630 } // namespace content | 1630 } // namespace content |
OLD | NEW |