| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "webkit/appcache/appcache_url_request_job.h" | 7 #include "webkit/appcache/appcache_url_request_job.h" |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 13 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
| 14 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 15 #include "net/http/http_util.h" | 16 #include "net/http/http_util.h" |
| 16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 | 19 |
| 19 namespace appcache { | 20 namespace appcache { |
| 20 | 21 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const char kLengthHeader[] = "Content-Length"; | 165 const char kLengthHeader[] = "Content-Length"; |
| 165 const char kRangeHeader[] = "Content-Range"; | 166 const char kRangeHeader[] = "Content-Range"; |
| 166 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content"; | 167 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content"; |
| 167 range_response_info_.reset( | 168 range_response_info_.reset( |
| 168 new net::HttpResponseInfo(*info_->http_response_info())); | 169 new net::HttpResponseInfo(*info_->http_response_info())); |
| 169 net::HttpResponseHeaders* headers = range_response_info_->headers; | 170 net::HttpResponseHeaders* headers = range_response_info_->headers; |
| 170 headers->RemoveHeader(kLengthHeader); | 171 headers->RemoveHeader(kLengthHeader); |
| 171 headers->RemoveHeader(kRangeHeader); | 172 headers->RemoveHeader(kRangeHeader); |
| 172 headers->ReplaceStatusLine(kPartialStatusLine); | 173 headers->ReplaceStatusLine(kPartialStatusLine); |
| 173 headers->AddHeader( | 174 headers->AddHeader( |
| 174 StringPrintf("%s: %d", kLengthHeader, length)); | 175 base::StringPrintf("%s: %d", kLengthHeader, length)); |
| 175 headers->AddHeader( | 176 headers->AddHeader( |
| 176 StringPrintf("%s: bytes %d-%d/%d", | 177 base::StringPrintf("%s: bytes %d-%d/%d", |
| 177 kRangeHeader, | 178 kRangeHeader, |
| 178 offset, | 179 offset, |
| 179 offset + length - 1, | 180 offset + length - 1, |
| 180 resource_size)); | 181 resource_size)); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void AppCacheURLRequestJob::OnReadComplete(int result) { | 184 void AppCacheURLRequestJob::OnReadComplete(int result) { |
| 184 DCHECK(is_delivering_appcache_response()); | 185 DCHECK(is_delivering_appcache_response()); |
| 185 if (result == 0) | 186 if (result == 0) |
| 186 NotifyDone(URLRequestStatus()); | 187 NotifyDone(URLRequestStatus()); |
| 187 else if (result < 0) | 188 else if (result < 0) |
| 188 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 189 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 189 else | 190 else |
| 190 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status | 191 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 272 } |
| 272 | 273 |
| 273 // If multiple ranges are requested, we play dumb and | 274 // If multiple ranges are requested, we play dumb and |
| 274 // return the entire response with 200 OK. | 275 // return the entire response with 200 OK. |
| 275 if (ranges.size() == 1U) | 276 if (ranges.size() == 1U) |
| 276 range_requested_ = ranges[0]; | 277 range_requested_ = ranges[0]; |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace appcache | 280 } // namespace appcache |
| 280 | 281 |
| OLD | NEW |