| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SPDY_SPDY_FRAME_BUILDER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| 6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_ | 6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 value = htonl(value); | 99 value = htonl(value); |
| 100 return WriteBytes(reinterpret_cast<char*>(&value) + 1, | 100 return WriteBytes(reinterpret_cast<char*>(&value) + 1, |
| 101 sizeof(value) - 1); | 101 sizeof(value) - 1); |
| 102 } | 102 } |
| 103 bool WriteUInt32(uint32 value) { | 103 bool WriteUInt32(uint32 value) { |
| 104 value = htonl(value); | 104 value = htonl(value); |
| 105 return WriteBytes(&value, sizeof(value)); | 105 return WriteBytes(&value, sizeof(value)); |
| 106 } | 106 } |
| 107 bool WriteUInt64(uint64 value) { | 107 bool WriteUInt64(uint64 value) { |
| 108 uint32 upper = htonl(value >> 32); | 108 uint32 upper = htonl(value >> 32); |
| 109 uint32 lower = htonl(value); | 109 uint32 lower = htonl(static_cast<uint32>(value)); |
| 110 return (WriteBytes(&upper, sizeof(upper)) && | 110 return (WriteBytes(&upper, sizeof(upper)) && |
| 111 WriteBytes(&lower, sizeof(lower))); | 111 WriteBytes(&lower, sizeof(lower))); |
| 112 } | 112 } |
| 113 // TODO(hkhalil) Rename to WriteStringPiece16(). | 113 // TODO(hkhalil) Rename to WriteStringPiece16(). |
| 114 bool WriteString(const std::string& value); | 114 bool WriteString(const std::string& value); |
| 115 bool WriteStringPiece32(const base::StringPiece& value); | 115 bool WriteStringPiece32(const base::StringPiece& value); |
| 116 bool WriteBytes(const void* data, uint32 data_len); | 116 bool WriteBytes(const void* data, uint32 data_len); |
| 117 | 117 |
| 118 // Update (in-place) the length field in the frame being built to reflect the | 118 // Update (in-place) the length field in the frame being built to reflect the |
| 119 // current actual length of bytes written to said frame through this builder. | 119 // current actual length of bytes written to said frame through this builder. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 143 size_t capacity_; // Allocation size of payload, set by constructor. | 143 size_t capacity_; // Allocation size of payload, set by constructor. |
| 144 size_t length_; // Length of the latest frame in the buffer. | 144 size_t length_; // Length of the latest frame in the buffer. |
| 145 size_t offset_; // Position at which the latest frame begins. | 145 size_t offset_; // Position at which the latest frame begins. |
| 146 | 146 |
| 147 const SpdyMajorVersion version_; | 147 const SpdyMajorVersion version_; |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 } // namespace net | 150 } // namespace net |
| 151 | 151 |
| 152 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 152 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| OLD | NEW |