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

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

Issue 78343004: Net: Standardize HttpByteRange printing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « content/renderer/media/buffered_resource_loader.cc ('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 <string>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
10 12
11 namespace net { 13 namespace net {
12 14
13 // A container class that represents a "range" specified for range request 15 // A container class that represents a "range" specified for range request
14 // specified by RFC 2616 Section 14.35.1. 16 // specified by RFC 2616 Section 14.35.1.
15 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1 17 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
16 class NET_EXPORT HttpByteRange { 18 class NET_EXPORT HttpByteRange {
17 public: 19 public:
18 HttpByteRange(); 20 HttpByteRange();
19 21
22 // Convenience constructors.
23 static HttpByteRange Bounded(int64 first_byte_position,
24 int64 last_byte_position);
25 static HttpByteRange RightUnbounded(int64 first_byte_position);
26 static HttpByteRange Suffix(int64 suffix_length);
27
20 // Since this class is POD, we use constructor, assignment operator 28 // Since this class is POD, we use constructor, assignment operator
21 // and destructor provided by compiler. 29 // and destructor provided by compiler.
22 int64 first_byte_position() const { return first_byte_position_; } 30 int64 first_byte_position() const { return first_byte_position_; }
23 void set_first_byte_position(int64 value) { first_byte_position_ = value; } 31 void set_first_byte_position(int64 value) { first_byte_position_ = value; }
24 32
25 int64 last_byte_position() const { return last_byte_position_; } 33 int64 last_byte_position() const { return last_byte_position_; }
26 void set_last_byte_position(int64 value) { last_byte_position_ = value; } 34 void set_last_byte_position(int64 value) { last_byte_position_ = value; }
27 35
28 int64 suffix_length() const { return suffix_length_; } 36 int64 suffix_length() const { return suffix_length_; }
29 void set_suffix_length(int64 value) { suffix_length_ = value; } 37 void set_suffix_length(int64 value) { suffix_length_ = value; }
30 38
31 // Returns true if this is a suffix byte range. 39 // Returns true if this is a suffix byte range.
32 bool IsSuffixByteRange() const; 40 bool IsSuffixByteRange() const;
33 // Returns true if the first byte position is specified in this request. 41 // Returns true if the first byte position is specified in this request.
34 bool HasFirstBytePosition() const; 42 bool HasFirstBytePosition() const;
35 // Returns true if the last byte position is specified in this request. 43 // Returns true if the last byte position is specified in this request.
36 bool HasLastBytePosition() const; 44 bool HasLastBytePosition() const;
37 45
38 // Returns true if this range is valid. 46 // Returns true if this range is valid.
39 bool IsValid() const; 47 bool IsValid() const;
40 48
49 // Prints the range, e.g. "bytes=0-100", "bytes=100-", "bytes=-100".
50 // Assumes range is valid.
51 std::string PrintHeader() const;
cbentzel 2013/11/23 14:37:20 I'd rather call this GetHeaderValue or GenerateHea
tommycli 2013/11/25 19:00:05 Done.
52
41 // A method that when given the size in bytes of a file, adjust the internal 53 // A method that when given the size in bytes of a file, adjust the internal
42 // |first_byte_position_| and |last_byte_position_| values according to the 54 // |first_byte_position_| and |last_byte_position_| values according to the
43 // range specified by this object. If the range specified is invalid with 55 // range specified by this object. If the range specified is invalid with
44 // regard to the size or |size| is negative, returns false and there will be 56 // regard to the size or |size| is negative, returns false and there will be
45 // no side effect. 57 // no side effect.
46 // Returns false if this method is called more than once and there will be 58 // Returns false if this method is called more than once and there will be
47 // no side effect. 59 // no side effect.
48 bool ComputeBounds(int64 size); 60 bool ComputeBounds(int64 size);
49 61
50 private: 62 private:
51 int64 first_byte_position_; 63 int64 first_byte_position_;
52 int64 last_byte_position_; 64 int64 last_byte_position_;
53 int64 suffix_length_; 65 int64 suffix_length_;
54 bool has_computed_bounds_; 66 bool has_computed_bounds_;
55 }; 67 };
56 68
57 } // namespace net 69 } // namespace net
58 70
59 #endif // NET_HTTP_HTTP_BYTE_RANGE_H_ 71 #endif // NET_HTTP_HTTP_BYTE_RANGE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/buffered_resource_loader.cc ('k') | net/http/http_byte_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698