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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 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
« no previous file with comments | « net/http/http_byte_range.h ('k') | net/http/http_byte_range_unittest.cc » ('j') | 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 <algorithm> 5 #include <algorithm>
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/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/http/http_byte_range.h" 10 #include "net/http/http_byte_range.h"
11 11
12 namespace { 12 namespace {
13 13
14 const int64 kPositionNotSpecified = -1; 14 const int64_t kPositionNotSpecified = -1;
15 15
16 } // namespace 16 } // namespace
17 17
18 namespace net { 18 namespace net {
19 19
20 HttpByteRange::HttpByteRange() 20 HttpByteRange::HttpByteRange()
21 : first_byte_position_(kPositionNotSpecified), 21 : first_byte_position_(kPositionNotSpecified),
22 last_byte_position_(kPositionNotSpecified), 22 last_byte_position_(kPositionNotSpecified),
23 suffix_length_(kPositionNotSpecified), 23 suffix_length_(kPositionNotSpecified),
24 has_computed_bounds_(false) { 24 has_computed_bounds_(false) {
25 } 25 }
26 26
27 // static 27 // static
28 HttpByteRange HttpByteRange::Bounded(int64 first_byte_position, 28 HttpByteRange HttpByteRange::Bounded(int64_t first_byte_position,
29 int64 last_byte_position) { 29 int64_t last_byte_position) {
30 HttpByteRange range; 30 HttpByteRange range;
31 range.set_first_byte_position(first_byte_position); 31 range.set_first_byte_position(first_byte_position);
32 range.set_last_byte_position(last_byte_position); 32 range.set_last_byte_position(last_byte_position);
33 return range; 33 return range;
34 } 34 }
35 35
36 // static 36 // static
37 HttpByteRange HttpByteRange::RightUnbounded(int64 first_byte_position) { 37 HttpByteRange HttpByteRange::RightUnbounded(int64_t first_byte_position) {
38 HttpByteRange range; 38 HttpByteRange range;
39 range.set_first_byte_position(first_byte_position); 39 range.set_first_byte_position(first_byte_position);
40 return range; 40 return range;
41 } 41 }
42 42
43 // static 43 // static
44 HttpByteRange HttpByteRange::Suffix(int64 suffix_length) { 44 HttpByteRange HttpByteRange::Suffix(int64_t suffix_length) {
45 HttpByteRange range; 45 HttpByteRange range;
46 range.set_suffix_length(suffix_length); 46 range.set_suffix_length(suffix_length);
47 return range; 47 return range;
48 } 48 }
49 49
50 bool HttpByteRange::IsSuffixByteRange() const { 50 bool HttpByteRange::IsSuffixByteRange() const {
51 return suffix_length_ != kPositionNotSpecified; 51 return suffix_length_ != kPositionNotSpecified;
52 } 52 }
53 53
54 bool HttpByteRange::HasFirstBytePosition() const { 54 bool HttpByteRange::HasFirstBytePosition() const {
(...skipping 20 matching lines...) Expand all
75 75
76 DCHECK(HasFirstBytePosition()); 76 DCHECK(HasFirstBytePosition());
77 77
78 if (!HasLastBytePosition()) 78 if (!HasLastBytePosition())
79 return base::StringPrintf("bytes=%" PRId64 "-", first_byte_position()); 79 return base::StringPrintf("bytes=%" PRId64 "-", first_byte_position());
80 80
81 return base::StringPrintf("bytes=%" PRId64 "-%" PRId64, 81 return base::StringPrintf("bytes=%" PRId64 "-%" PRId64,
82 first_byte_position(), last_byte_position()); 82 first_byte_position(), last_byte_position());
83 } 83 }
84 84
85 bool HttpByteRange::ComputeBounds(int64 size) { 85 bool HttpByteRange::ComputeBounds(int64_t size) {
86 if (size < 0) 86 if (size < 0)
87 return false; 87 return false;
88 if (has_computed_bounds_) 88 if (has_computed_bounds_)
89 return false; 89 return false;
90 has_computed_bounds_ = true; 90 has_computed_bounds_ = true;
91 91
92 // Empty values. 92 // Empty values.
93 if (!HasFirstBytePosition() && 93 if (!HasFirstBytePosition() &&
94 !HasLastBytePosition() && 94 !HasLastBytePosition() &&
95 !IsSuffixByteRange()) { 95 !IsSuffixByteRange()) {
(...skipping 12 matching lines...) Expand all
108 if (HasLastBytePosition()) 108 if (HasLastBytePosition())
109 last_byte_position_ = std::min(size - 1, last_byte_position_); 109 last_byte_position_ = std::min(size - 1, last_byte_position_);
110 else 110 else
111 last_byte_position_ = size - 1; 111 last_byte_position_ = size - 1;
112 return true; 112 return true;
113 } 113 }
114 return false; 114 return false;
115 } 115 }
116 116
117 } // namespace net 117 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_byte_range.h ('k') | net/http/http_byte_range_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698