| 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_url_request_job.h" | 5 #include "content/browser/appcache/appcache_url_request_job.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 int AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) { | 426 int AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) { |
| 427 DCHECK(is_delivering_appcache_response()); | 427 DCHECK(is_delivering_appcache_response()); |
| 428 DCHECK_NE(buf_size, 0); | 428 DCHECK_NE(buf_size, 0); |
| 429 DCHECK(!reader_->IsReadPending()); | 429 DCHECK(!reader_->IsReadPending()); |
| 430 reader_->ReadData(buf, buf_size, | 430 reader_->ReadData(buf, buf_size, |
| 431 base::Bind(&AppCacheURLRequestJob::OnReadComplete, | 431 base::Bind(&AppCacheURLRequestJob::OnReadComplete, |
| 432 base::Unretained(this))); | 432 base::Unretained(this))); |
| 433 return net::ERR_IO_PENDING; | 433 return net::ERR_IO_PENDING; |
| 434 } | 434 } |
| 435 | 435 |
| 436 net::HostPortPair AppCacheURLRequestJob::GetSocketAddress() const { |
| 437 if (!http_info()) |
| 438 return net::HostPortPair(); |
| 439 return http_info()->socket_address; |
| 440 } |
| 441 |
| 436 void AppCacheURLRequestJob::SetExtraRequestHeaders( | 442 void AppCacheURLRequestJob::SetExtraRequestHeaders( |
| 437 const net::HttpRequestHeaders& headers) { | 443 const net::HttpRequestHeaders& headers) { |
| 438 std::string value; | 444 std::string value; |
| 439 std::vector<net::HttpByteRange> ranges; | 445 std::vector<net::HttpByteRange> ranges; |
| 440 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) || | 446 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) || |
| 441 !net::HttpUtil::ParseRangeHeader(value, &ranges)) { | 447 !net::HttpUtil::ParseRangeHeader(value, &ranges)) { |
| 442 return; | 448 return; |
| 443 } | 449 } |
| 444 | 450 |
| 445 // If multiple ranges are requested, we play dumb and | 451 // If multiple ranges are requested, we play dumb and |
| 446 // return the entire response with 200 OK. | 452 // return the entire response with 200 OK. |
| 447 if (ranges.size() == 1U) | 453 if (ranges.size() == 1U) |
| 448 range_requested_ = ranges[0]; | 454 range_requested_ = ranges[0]; |
| 449 } | 455 } |
| 450 | 456 |
| 451 void AppCacheURLRequestJob::NotifyRestartRequired() { | 457 void AppCacheURLRequestJob::NotifyRestartRequired() { |
| 452 on_prepare_to_restart_callback_.Run(); | 458 on_prepare_to_restart_callback_.Run(); |
| 453 URLRequestJob::NotifyRestartRequired(); | 459 URLRequestJob::NotifyRestartRequired(); |
| 454 } | 460 } |
| 455 | 461 |
| 456 } // namespace content | 462 } // namespace content |
| OLD | NEW |