| Index: net/spdy/spdy_protocol.h
|
| diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h
|
| index 2f2d06de880c5751ac59aca6d40a57c484f4699e..e22f89c026009779fdea38a843d3b13f8408c654 100644
|
| --- a/net/spdy/spdy_protocol.h
|
| +++ b/net/spdy/spdy_protocol.h
|
| @@ -522,14 +522,9 @@ class NET_EXPORT_PRIVATE SpdyConstants {
|
| static std::string GetVersionString(SpdyMajorVersion version);
|
| };
|
|
|
| -class SpdyFrame;
|
| -typedef SpdyFrame SpdySerializedFrame;
|
| -
|
| class SpdyFrameVisitor;
|
|
|
| // Intermediate representation for SPDY frames.
|
| -// TODO(hkhalil): Rename this class to SpdyFrame when the existing SpdyFrame is
|
| -// gone.
|
| class NET_EXPORT_PRIVATE SpdyFrameIR {
|
| public:
|
| virtual ~SpdyFrameIR() {}
|
| @@ -987,35 +982,50 @@ class NET_EXPORT_PRIVATE SpdyPriorityIR : public SpdyFrameWithStreamIdIR {
|
| DISALLOW_COPY_AND_ASSIGN(SpdyPriorityIR);
|
| };
|
|
|
| -// -------------------------------------------------------------------------
|
| -// Wrapper classes for various SPDY frames.
|
| -
|
| -// All Spdy Frame types derive from this SpdyFrame class.
|
| -class SpdyFrame {
|
| +class SpdySerializedFrame {
|
| public:
|
| - // Create a SpdyFrame using a pre-created buffer.
|
| - // If |owns_buffer| is true, this class takes ownership of the buffer
|
| - // and will delete it on cleanup. The buffer must have been created using
|
| - // new char[].
|
| + SpdySerializedFrame()
|
| + : frame_(const_cast<char*>("")), size_(0), owns_buffer_(false) {}
|
| +
|
| + // Create a valid SpdySerializedFrame using a pre-created buffer.
|
| + // If |owns_buffer| is true, this class takes ownership of the buffer and will
|
| + // delete it on cleanup. The buffer must have been created using new char[].
|
| // If |owns_buffer| is false, the caller retains ownership of the buffer and
|
| // is responsible for making sure the buffer outlives this frame. In other
|
| // words, this class does NOT create a copy of the buffer.
|
| - SpdyFrame(char* data, size_t size, bool owns_buffer)
|
| - : frame_(data),
|
| - size_(size),
|
| - owns_buffer_(owns_buffer) {
|
| - DCHECK(frame_);
|
| + SpdySerializedFrame(char* data, size_t size, bool owns_buffer)
|
| + : frame_(data), size_(size), owns_buffer_(owns_buffer) {}
|
| +
|
| + SpdySerializedFrame(SpdySerializedFrame&& other)
|
| + : frame_(other.frame_),
|
| + size_(other.size_),
|
| + owns_buffer_(other.owns_buffer_) {
|
| + // |other| is no longer responsible for the buffer.
|
| + other.owns_buffer_ = false;
|
| + }
|
| +
|
| + SpdySerializedFrame& operator=(SpdySerializedFrame&& other) {
|
| + // Free buffer if necessary.
|
| + if (owns_buffer_) {
|
| + delete[] frame_;
|
| + }
|
| + // Take over |other|.
|
| + frame_ = other.frame_;
|
| + size_ = other.size_;
|
| + owns_buffer_ = other.owns_buffer_;
|
| + // |other| is no longer responsible for the buffer.
|
| + other.owns_buffer_ = false;
|
| + return *this;
|
| }
|
|
|
| - ~SpdyFrame() {
|
| + ~SpdySerializedFrame() {
|
| if (owns_buffer_) {
|
| - delete [] frame_;
|
| + delete[] frame_;
|
| }
|
| - frame_ = NULL;
|
| }
|
|
|
| - // Provides access to the frame bytes, which is a buffer containing
|
| - // the frame packed as expected for sending over the wire.
|
| + // Provides access to the frame bytes, which is a buffer containing the frame
|
| + // packed as expected for sending over the wire.
|
| char* data() const { return frame_; }
|
|
|
| // Returns the actual size of the underlying buffer.
|
| @@ -1027,7 +1037,7 @@ class SpdyFrame {
|
| private:
|
| size_t size_;
|
| bool owns_buffer_;
|
| - DISALLOW_COPY_AND_ASSIGN(SpdyFrame);
|
| + DISALLOW_COPY_AND_ASSIGN(SpdySerializedFrame);
|
| };
|
|
|
| // This interface is for classes that want to process SpdyFrameIRs without
|
|
|