| OLD | NEW |
| 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_VERSION_H_ | 5 #ifndef NET_HTTP_VERSION_H_ |
| 6 #define NET_HTTP_VERSION_H_ | 6 #define NET_HTTP_VERSION_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.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 private: | 14 private: |
| 15 uint32 value; // Packed as <major>:<minor> | 15 uint32 value; // Packed as <major>:<minor> |
| 16 | 16 |
| 17 public: | 17 public: |
| 18 // Default constructor (major=0, minor=0). | 18 // Default constructor (major=0, minor=0). |
| 19 HttpVersion() : value(0) { } | 19 HttpVersion() : value(0) { } |
| 20 | 20 |
| 21 // Build from unsigned major/minor pair. | 21 // Build from unsigned major/minor pair. |
| 22 HttpVersion(uint16 major, uint16 minor) : value(major << 16 | minor) { } | 22 HttpVersion(uint16 major, uint16 minor) : value(major << 16 | minor) { } |
| 23 | 23 |
| 24 // Major version number. | 24 // Major version number. |
| 25 uint16 major() const { | 25 uint16 major_version() const { |
| 26 return value >> 16; | 26 return value >> 16; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // Minor version number. | 29 // Minor version number. |
| 30 uint16 minor() const { | 30 uint16 minor_version() const { |
| 31 return value & 0xffff; | 31 return value & 0xffff; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Overloaded operators: | 34 // Overloaded operators: |
| 35 | 35 |
| 36 bool operator==(const HttpVersion& v) const { | 36 bool operator==(const HttpVersion& v) const { |
| 37 return value == v.value; | 37 return value == v.value; |
| 38 } | 38 } |
| 39 bool operator!=(const HttpVersion& v) const { | 39 bool operator!=(const HttpVersion& v) const { |
| 40 return value != v.value; | 40 return value != v.value; |
| 41 } | 41 } |
| 42 bool operator>(const HttpVersion& v) const { | 42 bool operator>(const HttpVersion& v) const { |
| 43 return value > v.value; | 43 return value > v.value; |
| 44 } | 44 } |
| 45 bool operator>=(const HttpVersion& v) const { | 45 bool operator>=(const HttpVersion& v) const { |
| 46 return value >= v.value; | 46 return value >= v.value; |
| 47 } | 47 } |
| 48 bool operator<(const HttpVersion& v) const { | 48 bool operator<(const HttpVersion& v) const { |
| 49 return value < v.value; | 49 return value < v.value; |
| 50 } | 50 } |
| 51 bool operator<=(const HttpVersion& v) const { | 51 bool operator<=(const HttpVersion& v) const { |
| 52 return value <= v.value; | 52 return value <= v.value; |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace net | 56 } // namespace net |
| 57 | 57 |
| 58 #endif // NET_HTTP_VERSION_H_ | 58 #endif // NET_HTTP_VERSION_H_ |
| 59 | 59 |
| OLD | NEW |