Raise SIGKILL if cast_service doesn't Finalize() within timeout.
[chromium-blink-merge.git] / net / spdy / spdy_pinnable_buffer_piece.cc
blob01f8d1db1436b358686fb28c6ce1537b74d1ab9e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_pinnable_buffer_piece.h"
7 namespace net {
9 SpdyPinnableBufferPiece::SpdyPinnableBufferPiece()
10 : buffer_(0), length_(0) {}
12 SpdyPinnableBufferPiece::~SpdyPinnableBufferPiece() {}
14 void SpdyPinnableBufferPiece::Pin() {
15 if (!storage_ && buffer_ != NULL && length_ != 0) {
16 storage_.reset(new char[length_]);
17 std::copy(buffer_, buffer_ + length_, storage_.get());
18 buffer_ = storage_.get();
22 void SpdyPinnableBufferPiece::Swap(SpdyPinnableBufferPiece* other) {
23 size_t length = length_;
24 length_ = other->length_;
25 other->length_ = length;
27 const char* buffer = buffer_;
28 buffer_ = other->buffer_;
29 other->buffer_ = buffer;
31 storage_.swap(other->storage_);
34 } // namespace net