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

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

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_basic_stream.h ('k') | net/http/http_byte_range.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_HTTP_HTTP_BYTE_RANGE_H_ 5 #ifndef NET_HTTP_HTTP_BYTE_RANGE_H_
6 #define NET_HTTP_HTTP_BYTE_RANGE_H_ 6 #define NET_HTTP_HTTP_BYTE_RANGE_H_
7 7
8 #include <stdint.h>
9
8 #include <string> 10 #include <string>
9 11
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 // A container class that represents a "range" specified for range request 16 // A container class that represents a "range" specified for range request
16 // specified by RFC 7233 Section 2.1. 17 // specified by RFC 7233 Section 2.1.
17 // https://tools.ietf.org/html/rfc7233#section-2.1 18 // https://tools.ietf.org/html/rfc7233#section-2.1
18 class NET_EXPORT HttpByteRange { 19 class NET_EXPORT HttpByteRange {
19 public: 20 public:
20 HttpByteRange(); 21 HttpByteRange();
21 22
22 // Convenience constructors. 23 // Convenience constructors.
23 static HttpByteRange Bounded(int64 first_byte_position, 24 static HttpByteRange Bounded(int64_t first_byte_position,
24 int64 last_byte_position); 25 int64_t last_byte_position);
25 static HttpByteRange RightUnbounded(int64 first_byte_position); 26 static HttpByteRange RightUnbounded(int64_t first_byte_position);
26 static HttpByteRange Suffix(int64 suffix_length); 27 static HttpByteRange Suffix(int64_t suffix_length);
27 28
28 // Since this class is POD, we use constructor, assignment operator 29 // Since this class is POD, we use constructor, assignment operator
29 // and destructor provided by compiler. 30 // and destructor provided by compiler.
30 int64 first_byte_position() const { return first_byte_position_; } 31 int64_t first_byte_position() const { return first_byte_position_; }
31 void set_first_byte_position(int64 value) { first_byte_position_ = value; } 32 void set_first_byte_position(int64_t value) { first_byte_position_ = value; }
32 33
33 int64 last_byte_position() const { return last_byte_position_; } 34 int64_t last_byte_position() const { return last_byte_position_; }
34 void set_last_byte_position(int64 value) { last_byte_position_ = value; } 35 void set_last_byte_position(int64_t value) { last_byte_position_ = value; }
35 36
36 int64 suffix_length() const { return suffix_length_; } 37 int64_t suffix_length() const { return suffix_length_; }
37 void set_suffix_length(int64 value) { suffix_length_ = value; } 38 void set_suffix_length(int64_t value) { suffix_length_ = value; }
38 39
39 // Returns true if this is a suffix byte range. 40 // Returns true if this is a suffix byte range.
40 bool IsSuffixByteRange() const; 41 bool IsSuffixByteRange() const;
41 // Returns true if the first byte position is specified in this request. 42 // Returns true if the first byte position is specified in this request.
42 bool HasFirstBytePosition() const; 43 bool HasFirstBytePosition() const;
43 // Returns true if the last byte position is specified in this request. 44 // Returns true if the last byte position is specified in this request.
44 bool HasLastBytePosition() const; 45 bool HasLastBytePosition() const;
45 46
46 // Returns true if this range is valid. 47 // Returns true if this range is valid.
47 bool IsValid() const; 48 bool IsValid() const;
48 49
49 // Gets the header string, e.g. "bytes=0-100", "bytes=100-", "bytes=-100". 50 // Gets the header string, e.g. "bytes=0-100", "bytes=100-", "bytes=-100".
50 // Assumes range is valid. 51 // Assumes range is valid.
51 std::string GetHeaderValue() const; 52 std::string GetHeaderValue() const;
52 53
53 // A method that when given the size in bytes of a file, adjust the internal 54 // A method that when given the size in bytes of a file, adjust the internal
54 // |first_byte_position_| and |last_byte_position_| values according to the 55 // |first_byte_position_| and |last_byte_position_| values according to the
55 // range specified by this object. If the range specified is invalid with 56 // range specified by this object. If the range specified is invalid with
56 // regard to the size or |size| is negative, returns false and there will be 57 // regard to the size or |size| is negative, returns false and there will be
57 // no side effect. 58 // no side effect.
58 // Returns false if this method is called more than once and there will be 59 // Returns false if this method is called more than once and there will be
59 // no side effect. 60 // no side effect.
60 bool ComputeBounds(int64 size); 61 bool ComputeBounds(int64_t size);
61 62
62 private: 63 private:
63 int64 first_byte_position_; 64 int64_t first_byte_position_;
64 int64 last_byte_position_; 65 int64_t last_byte_position_;
65 int64 suffix_length_; 66 int64_t suffix_length_;
66 bool has_computed_bounds_; 67 bool has_computed_bounds_;
67 }; 68 };
68 69
69 } // namespace net 70 } // namespace net
70 71
71 #endif // NET_HTTP_HTTP_BYTE_RANGE_H_ 72 #endif // NET_HTTP_HTTP_BYTE_RANGE_H_
OLDNEW
« no previous file with comments | « net/http/http_basic_stream.h ('k') | net/http/http_byte_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698