Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: net/http/partial_data.cc

Issue 455019: Merge 33412 - Http cache: Add code to restart a network request when the... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/partial_data.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/disk_cache/disk_cache.h" 10 #include "net/disk_cache/disk_cache.h"
(...skipping 29 matching lines...) Expand all
40 void PartialData::SetHeaders(const std::string& headers) { 40 void PartialData::SetHeaders(const std::string& headers) {
41 DCHECK(extra_headers_.empty()); 41 DCHECK(extra_headers_.empty());
42 extra_headers_ = headers; 42 extra_headers_ = headers;
43 } 43 }
44 44
45 void PartialData::RestoreHeaders(std::string* headers) const { 45 void PartialData::RestoreHeaders(std::string* headers) const {
46 DCHECK(current_range_start_ >= 0 || byte_range_.IsSuffixByteRange()); 46 DCHECK(current_range_start_ >= 0 || byte_range_.IsSuffixByteRange());
47 int64 end = byte_range_.IsSuffixByteRange() ? 47 int64 end = byte_range_.IsSuffixByteRange() ?
48 byte_range_.suffix_length() : byte_range_.last_byte_position(); 48 byte_range_.suffix_length() : byte_range_.last_byte_position();
49 49
50 AddRangeHeader(current_range_start_, end, headers); 50 headers->assign(extra_headers_);
51 if (byte_range_.IsValid())
52 AddRangeHeader(current_range_start_, end, headers);
51 } 53 }
52 54
53 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry, 55 int PartialData::PrepareCacheValidation(disk_cache::Entry* entry,
54 std::string* headers) { 56 std::string* headers) {
55 DCHECK(current_range_start_ >= 0); 57 DCHECK(current_range_start_ >= 0);
56 58
57 // Scan the disk cache for the first cached portion within this range. 59 // Scan the disk cache for the first cached portion within this range.
58 int64 range_len = byte_range_.HasLastBytePosition() ? 60 int64 range_len = byte_range_.HasLastBytePosition() ?
59 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max; 61 byte_range_.last_byte_position() - current_range_start_ + 1 : kint32max;
60 if (range_len > kint32max) 62 if (range_len > kint32max)
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (start >= 0) 314 if (start >= 0)
313 my_start = Int64ToString(start); 315 my_start = Int64ToString(start);
314 if (end >= 0) 316 if (end >= 0)
315 my_end = Int64ToString(end); 317 my_end = Int64ToString(end);
316 318
317 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), 319 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(),
318 my_end.c_str())); 320 my_end.c_str()));
319 } 321 }
320 322
321 } // namespace net 323 } // namespace net
OLDNEW
« no previous file with comments | « net/http/partial_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698