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

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

Issue 452003: Revert 33133 - Http cache: Add code to restart a network request when the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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/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
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
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
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