OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_HTTP_HTTP_BYTE_RANGE_H_ |
| 6 #define NET_HTTP_HTTP_BYTE_RANGE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 // A container class that represents a "range" specified for range request |
| 13 // specified by RFC 2616 Section 14.35.1. |
| 14 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 |
| 15 class HttpByteRange { |
| 16 public: |
| 17 HttpByteRange(); |
| 18 |
| 19 // Since this class is POD, we use constructor, assignment operator |
| 20 // and destructor provided by compiler. |
| 21 int64 first_byte_position() const { return first_byte_position_; } |
| 22 void set_first_byte_position(int64 value) { first_byte_position_ = value; } |
| 23 |
| 24 int64 last_byte_position() const { return last_byte_position_; } |
| 25 void set_last_byte_position(int64 value) { last_byte_position_ = value; } |
| 26 |
| 27 int64 suffix_length() const { return suffix_length_; } |
| 28 void set_suffix_length(int64 value) { suffix_length_ = value; } |
| 29 |
| 30 // Returns true if this is a suffix byte range. |
| 31 bool IsSuffixByteRange() const; |
| 32 // Returns true if the first byte position is specified in this request. |
| 33 bool HasFirstBytePosition() const; |
| 34 // Returns true if the last byte position is specified in this request. |
| 35 bool HasLastBytePosition() const; |
| 36 |
| 37 // Returns true if this range is valid. |
| 38 bool IsValid() const; |
| 39 |
| 40 // A method that when given the size in bytes of a file, adjust the internal |
| 41 // |first_byte_position_| and |last_byte_position_| values according to the |
| 42 // range specified by this object. If the range specified is invalid with |
| 43 // regard to the size or |size| is negative, returns false and there will be |
| 44 // no side effect. |
| 45 // Returns false if this method is called more than once and there will be |
| 46 // no side effect. |
| 47 bool ComputeBounds(int64 size); |
| 48 |
| 49 private: |
| 50 int64 first_byte_position_; |
| 51 int64 last_byte_position_; |
| 52 int64 suffix_length_; |
| 53 bool has_computed_bounds_; |
| 54 }; |
| 55 |
| 56 } // namespace net |
| 57 |
| 58 #endif // NET_HTTP_HTTP_BYTE_RANGE_H_ |
OLD | NEW |