| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/http/partial_data.h" | 5 #include "net/http/partial_data.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void PartialData::SetHeaders(const std::string& headers) { | 41 void PartialData::SetHeaders(const std::string& headers) { |
| 42 DCHECK(extra_headers_.empty()); | 42 DCHECK(extra_headers_.empty()); |
| 43 extra_headers_ = headers; | 43 extra_headers_ = headers; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PartialData::RestoreHeaders(std::string* headers) const { | 46 void PartialData::RestoreHeaders(std::string* headers) const { |
| 47 DCHECK(current_range_start_ >= 0 || byte_range_.IsSuffixByteRange()); | 47 DCHECK(current_range_start_ >= 0 || byte_range_.IsSuffixByteRange()); |
| 48 int64 end = byte_range_.IsSuffixByteRange() ? | 48 int64 end = byte_range_.IsSuffixByteRange() ? |
| 49 byte_range_.suffix_length() : byte_range_.last_byte_position(); | 49 byte_range_.suffix_length() : byte_range_.last_byte_position(); |
| 50 | 50 |
| 51 headers->assign(extra_headers_); | 51 AddRangeHeader(current_range_start_, end, headers); |
| 52 if (byte_range_.IsValid()) | |
| 53 AddRangeHeader(current_range_start_, end, headers); | |
| 54 } | 52 } |
| 55 | 53 |
| 56 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry, | 54 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry, |
| 57 std::string* headers) { | 55 std::string* headers) { |
| 58 DCHECK(current_range_start_ >= 0); | 56 DCHECK(current_range_start_ >= 0); |
| 59 | 57 |
| 60 // Scan the disk cache for the first cached portion within this range. | 58 // Scan the disk cache for the first cached portion within this range. |
| 61 int64 range_len = byte_range_.HasLastBytePosition() ? | 59 int64 range_len = byte_range_.HasLastBytePosition() ? |
| 62 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max; | 60 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max; |
| 63 if (range_len > kint32max) | 61 if (range_len > kint32max) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (start >= 0) | 316 if (start >= 0) |
| 319 my_start = Int64ToString(start); | 317 my_start = Int64ToString(start); |
| 320 if (end >= 0) | 318 if (end >= 0) |
| 321 my_end = Int64ToString(end); | 319 my_end = Int64ToString(end); |
| 322 | 320 |
| 323 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), | 321 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), |
| 324 my_end.c_str())); | 322 my_end.c_str())); |
| 325 } | 323 } |
| 326 | 324 |
| 327 } // namespace net | 325 } // namespace net |
| OLD | NEW |