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

Side by Side Diff: net/http/http_version.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_util_unittest.cc ('k') | net/http/md4.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_VERSION_H_ 5 #ifndef NET_HTTP_HTTP_VERSION_H_
6 #define NET_HTTP_HTTP_VERSION_H_ 6 #define NET_HTTP_HTTP_VERSION_H_
7 7
8 #include "base/basictypes.h" 8 #include <stdint.h>
9 9
10 namespace net { 10 namespace net {
11 11
12 // Wrapper for an HTTP (major,minor) version pair. 12 // Wrapper for an HTTP (major,minor) version pair.
13 class HttpVersion { 13 class HttpVersion {
14 public: 14 public:
15 // Default constructor (major=0, minor=0). 15 // Default constructor (major=0, minor=0).
16 HttpVersion() : value_(0) { } 16 HttpVersion() : value_(0) { }
17 17
18 // Build from unsigned major/minor pair. 18 // Build from unsigned major/minor pair.
19 HttpVersion(uint16 major, uint16 minor) : value_(major << 16 | minor) { } 19 HttpVersion(uint16_t major, uint16_t minor) : value_(major << 16 | minor) {}
20 20
21 // Major version number. 21 // Major version number.
22 uint16 major_value() const { 22 uint16_t major_value() const { return value_ >> 16; }
23 return value_ >> 16;
24 }
25 23
26 // Minor version number. 24 // Minor version number.
27 uint16 minor_value() const { 25 uint16_t minor_value() const { return value_ & 0xffff; }
28 return value_ & 0xffff;
29 }
30 26
31 // Overloaded operators: 27 // Overloaded operators:
32 28
33 bool operator==(const HttpVersion& v) const { 29 bool operator==(const HttpVersion& v) const {
34 return value_ == v.value_; 30 return value_ == v.value_;
35 } 31 }
36 bool operator!=(const HttpVersion& v) const { 32 bool operator!=(const HttpVersion& v) const {
37 return value_ != v.value_; 33 return value_ != v.value_;
38 } 34 }
39 bool operator>(const HttpVersion& v) const { 35 bool operator>(const HttpVersion& v) const {
40 return value_ > v.value_; 36 return value_ > v.value_;
41 } 37 }
42 bool operator>=(const HttpVersion& v) const { 38 bool operator>=(const HttpVersion& v) const {
43 return value_ >= v.value_; 39 return value_ >= v.value_;
44 } 40 }
45 bool operator<(const HttpVersion& v) const { 41 bool operator<(const HttpVersion& v) const {
46 return value_ < v.value_; 42 return value_ < v.value_;
47 } 43 }
48 bool operator<=(const HttpVersion& v) const { 44 bool operator<=(const HttpVersion& v) const {
49 return value_ <= v.value_; 45 return value_ <= v.value_;
50 } 46 }
51 47
52 private: 48 private:
53 uint32 value_; // Packed as <major>:<minor> 49 uint32_t value_; // Packed as <major>:<minor>
54 }; 50 };
55 51
56 } // namespace net 52 } // namespace net
57 53
58 #endif // NET_HTTP_HTTP_VERSION_H_ 54 #endif // NET_HTTP_HTTP_VERSION_H_
OLDNEW
« no previous file with comments | « net/http/http_util_unittest.cc ('k') | net/http/md4.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698