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

Side by Side Diff: net/spdy/spdy_frame_builder.h

Issue 1852423004: Implement SpdySerializedFrame move semantics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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/spdy/spdy_buffer_unittest.cc ('k') | net/spdy/spdy_frame_builder_test.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) 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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Populates this frame with a SPDY4/HTTP2 frame prefix using 67 // Populates this frame with a SPDY4/HTTP2 frame prefix using
68 // version-specific information from the |framer| and length information from 68 // version-specific information from the |framer| and length information from
69 // capacity_. The given type must be a control frame type. 69 // capacity_. The given type must be a control frame type.
70 // Used only for SPDY versions >=4. 70 // Used only for SPDY versions >=4.
71 bool BeginNewFrame(const SpdyFramer& framer, 71 bool BeginNewFrame(const SpdyFramer& framer,
72 SpdyFrameType type, 72 SpdyFrameType type,
73 uint8_t flags, 73 uint8_t flags,
74 SpdyStreamId stream_id); 74 SpdyStreamId stream_id);
75 75
76 // Takes the buffer from the SpdyFrameBuilder. 76 // Takes the buffer from the SpdyFrameBuilder.
77 SpdyFrame* take() { 77 SpdySerializedFrame take() {
78 if (version_ == HTTP2) { 78 if (version_ == HTTP2) {
79 DLOG_IF(DFATAL, SpdyConstants::GetFrameMaximumSize(version_) < length_) 79 DLOG_IF(DFATAL, SpdyConstants::GetFrameMaximumSize(version_) < length_)
80 << "Frame length " << length_ 80 << "Frame length " << length_
81 << " is longer than the maximum allowed length."; 81 << " is longer than the maximum allowed length.";
82 } 82 }
83 SpdyFrame* rv = new SpdyFrame(buffer_.release(), length(), true); 83 SpdySerializedFrame rv(buffer_.release(), length(), true);
84 capacity_ = 0; 84 capacity_ = 0;
85 length_ = 0; 85 length_ = 0;
86 offset_ = 0; 86 offset_ = 0;
87 return rv; 87 return rv;
88 } 88 }
89 89
90 // Methods for adding to the payload. These values are appended to the end 90 // Methods for adding to the payload. These values are appended to the end
91 // of the SpdyFrameBuilder payload. Note - binary integers are converted from 91 // of the SpdyFrameBuilder payload. Note - binary integers are converted from
92 // host to network form. 92 // host to network form.
93 bool WriteUInt8(uint8_t value) { return WriteBytes(&value, sizeof(value)); } 93 bool WriteUInt8(uint8_t value) { return WriteBytes(&value, sizeof(value)); }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 size_t capacity_; // Allocation size of payload, set by constructor. 142 size_t capacity_; // Allocation size of payload, set by constructor.
143 size_t length_; // Length of the latest frame in the buffer. 143 size_t length_; // Length of the latest frame in the buffer.
144 size_t offset_; // Position at which the latest frame begins. 144 size_t offset_; // Position at which the latest frame begins.
145 145
146 const SpdyMajorVersion version_; 146 const SpdyMajorVersion version_;
147 }; 147 };
148 148
149 } // namespace net 149 } // namespace net
150 150
151 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ 151 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_buffer_unittest.cc ('k') | net/spdy/spdy_frame_builder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698