| 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 AddRangeHeader(current_range_start_, end, headers); | 51 headers->assign(extra_headers_); |
| 52 if (byte_range_.IsValid()) |
| 53 AddRangeHeader(current_range_start_, end, headers); |
| 52 } | 54 } |
| 53 | 55 |
| 54 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry, | 56 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry, |
| 55 std::string* headers) { | 57 std::string* headers) { |
| 56 DCHECK(current_range_start_ >= 0); | 58 DCHECK(current_range_start_ >= 0); |
| 57 | 59 |
| 58 // Scan the disk cache for the first cached portion within this range. | 60 // Scan the disk cache for the first cached portion within this range. |
| 59 int64 range_len = byte_range_.HasLastBytePosition() ? | 61 int64 range_len = byte_range_.HasLastBytePosition() ? |
| 60 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max; | 62 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max; |
| 61 if (range_len > kint32max) | 63 if (range_len > kint32max) |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (start >= 0) | 318 if (start >= 0) |
| 317 my_start = Int64ToString(start); | 319 my_start = Int64ToString(start); |
| 318 if (end >= 0) | 320 if (end >= 0) |
| 319 my_end = Int64ToString(end); | 321 my_end = Int64ToString(end); |
| 320 | 322 |
| 321 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), | 323 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), |
| 322 my_end.c_str())); | 324 my_end.c_str())); |
| 323 } | 325 } |
| 324 | 326 |
| 325 } // namespace net | 327 } // namespace net |
| OLD | NEW |