| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "net/spdy/spdy_buffer.h" | 5 #include "net/spdy/spdy_buffer.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 // This class is an IOBuffer implementation that simply holds a | 36 // This class is an IOBuffer implementation that simply holds a |
| 37 // reference to a SharedFrame object and a fixed offset. Used by | 37 // reference to a SharedFrame object and a fixed offset. Used by |
| 38 // SpdyBuffer::GetIOBufferForRemainingData(). | 38 // SpdyBuffer::GetIOBufferForRemainingData(). |
| 39 class SpdyBuffer::SharedFrameIOBuffer : public IOBuffer { | 39 class SpdyBuffer::SharedFrameIOBuffer : public IOBuffer { |
| 40 public: | 40 public: |
| 41 SharedFrameIOBuffer(const scoped_refptr<SharedFrame>& shared_frame, | 41 SharedFrameIOBuffer(const scoped_refptr<SharedFrame>& shared_frame, |
| 42 size_t offset) | 42 size_t offset) |
| 43 : IOBuffer(shared_frame->data->data() + offset), | 43 : IOBuffer(shared_frame->data->data() + offset), |
| 44 shared_frame_(shared_frame), | 44 shared_frame_(shared_frame) {} |
| 45 offset_(offset) {} | |
| 46 | 45 |
| 47 private: | 46 private: |
| 48 ~SharedFrameIOBuffer() override { | 47 ~SharedFrameIOBuffer() override { |
| 49 // Prevent ~IOBuffer() from trying to delete |data_|. | 48 // Prevent ~IOBuffer() from trying to delete |data_|. |
| 50 data_ = NULL; | 49 data_ = NULL; |
| 51 } | 50 } |
| 52 | 51 |
| 53 const scoped_refptr<SharedFrame> shared_frame_; | 52 const scoped_refptr<SharedFrame> shared_frame_; |
| 54 const size_t offset_; | |
| 55 | 53 |
| 56 DISALLOW_COPY_AND_ASSIGN(SharedFrameIOBuffer); | 54 DISALLOW_COPY_AND_ASSIGN(SharedFrameIOBuffer); |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 SpdyBuffer::SpdyBuffer(scoped_ptr<SpdyFrame> frame) | 57 SpdyBuffer::SpdyBuffer(scoped_ptr<SpdyFrame> frame) |
| 60 : shared_frame_(new SharedFrame()), | 58 : shared_frame_(new SharedFrame()), |
| 61 offset_(0) { | 59 offset_(0) { |
| 62 shared_frame_->data = frame.Pass(); | 60 shared_frame_->data = frame.Pass(); |
| 63 } | 61 } |
| 64 | 62 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 DCHECK_GE(consume_size, 1u); | 100 DCHECK_GE(consume_size, 1u); |
| 103 DCHECK_LE(consume_size, GetRemainingSize()); | 101 DCHECK_LE(consume_size, GetRemainingSize()); |
| 104 offset_ += consume_size; | 102 offset_ += consume_size; |
| 105 for (std::vector<ConsumeCallback>::const_iterator it = | 103 for (std::vector<ConsumeCallback>::const_iterator it = |
| 106 consume_callbacks_.begin(); it != consume_callbacks_.end(); ++it) { | 104 consume_callbacks_.begin(); it != consume_callbacks_.end(); ++it) { |
| 107 it->Run(consume_size, consume_source); | 105 it->Run(consume_size, consume_source); |
| 108 } | 106 } |
| 109 }; | 107 }; |
| 110 | 108 |
| 111 } // namespace net | 109 } // namespace net |
| OLD | NEW |