OLD | NEW |
1 // Copyright (c) 2010 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return; | 249 return; |
250 *info = *http_info(); | 250 *info = *http_info(); |
251 } | 251 } |
252 | 252 |
253 int AppCacheURLRequestJob::GetResponseCode() const { | 253 int AppCacheURLRequestJob::GetResponseCode() const { |
254 if (!http_info()) | 254 if (!http_info()) |
255 return -1; | 255 return -1; |
256 return http_info()->headers->response_code(); | 256 return http_info()->headers->response_code(); |
257 } | 257 } |
258 | 258 |
| 259 bool AppCacheURLRequestJob::IsCachedContent() const { |
| 260 return is_delivering_appcache_response(); |
| 261 } |
| 262 |
259 bool AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size, | 263 bool AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size, |
260 int *bytes_read) { | 264 int *bytes_read) { |
261 DCHECK(is_delivering_appcache_response()); | 265 DCHECK(is_delivering_appcache_response()); |
262 DCHECK_NE(buf_size, 0); | 266 DCHECK_NE(buf_size, 0); |
263 DCHECK(bytes_read); | 267 DCHECK(bytes_read); |
264 DCHECK(!reader_->IsReadPending()); | 268 DCHECK(!reader_->IsReadPending()); |
265 reader_->ReadData(buf, buf_size, &read_callback_); | 269 reader_->ReadData(buf, buf_size, &read_callback_); |
266 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 270 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
267 return false; | 271 return false; |
268 } | 272 } |
269 | 273 |
270 void AppCacheURLRequestJob::SetExtraRequestHeaders( | 274 void AppCacheURLRequestJob::SetExtraRequestHeaders( |
271 const net::HttpRequestHeaders& headers) { | 275 const net::HttpRequestHeaders& headers) { |
272 std::string value; | 276 std::string value; |
273 std::vector<net::HttpByteRange> ranges; | 277 std::vector<net::HttpByteRange> ranges; |
274 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) || | 278 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) || |
275 !net::HttpUtil::ParseRangeHeader(value, &ranges)) { | 279 !net::HttpUtil::ParseRangeHeader(value, &ranges)) { |
276 return; | 280 return; |
277 } | 281 } |
278 | 282 |
279 // If multiple ranges are requested, we play dumb and | 283 // If multiple ranges are requested, we play dumb and |
280 // return the entire response with 200 OK. | 284 // return the entire response with 200 OK. |
281 if (ranges.size() == 1U) | 285 if (ranges.size() == 1U) |
282 range_requested_ = ranges[0]; | 286 range_requested_ = ranges[0]; |
283 } | 287 } |
284 | 288 |
285 } // namespace appcache | 289 } // namespace appcache |
OLD | NEW |