OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/io_buffer.h" | 5 #include "net/base/io_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 IOBuffer::IOBuffer() | 11 IOBuffer::IOBuffer() |
12 : data_(NULL) { | 12 : data_(NULL) { |
13 } | 13 } |
14 | 14 |
15 IOBuffer::IOBuffer(int buffer_size) { | 15 IOBuffer::IOBuffer(int buffer_size) { |
16 DCHECK(buffer_size > 0); | 16 DCHECK(buffer_size > 0); |
17 data_ = new char[buffer_size]; | 17 data_ = new char[buffer_size]; |
| 18 sctp_stream_id_ = 0; |
18 } | 19 } |
19 | 20 |
20 IOBuffer::IOBuffer(char* data) | 21 IOBuffer::IOBuffer(char* data) |
21 : data_(data) { | 22 : data_(data), |
| 23 sctp_stream_id_(0) { |
22 } | 24 } |
23 | 25 |
24 IOBuffer::~IOBuffer() { | 26 IOBuffer::~IOBuffer() { |
25 delete[] data_; | 27 delete[] data_; |
26 } | 28 } |
27 | 29 |
28 IOBufferWithSize::IOBufferWithSize(int size) | 30 IOBufferWithSize::IOBufferWithSize(int size) |
29 : IOBuffer(size), | 31 : IOBuffer(size), |
30 size_(size) { | 32 size_(size) { |
31 } | 33 } |
(...skipping 11 matching lines...) Expand all Loading... |
43 // We haven't allocated the buffer, so remove it before the base class | 45 // We haven't allocated the buffer, so remove it before the base class |
44 // destructor tries to delete[] it. | 46 // destructor tries to delete[] it. |
45 data_ = NULL; | 47 data_ = NULL; |
46 } | 48 } |
47 | 49 |
48 DrainableIOBuffer::DrainableIOBuffer(IOBuffer* base, int size) | 50 DrainableIOBuffer::DrainableIOBuffer(IOBuffer* base, int size) |
49 : IOBuffer(base->data()), | 51 : IOBuffer(base->data()), |
50 base_(base), | 52 base_(base), |
51 size_(size), | 53 size_(size), |
52 used_(0) { | 54 used_(0) { |
| 55 base_->set_sctp_stream_id(base->sctp_stream_id()); |
53 } | 56 } |
54 | 57 |
55 void DrainableIOBuffer::DidConsume(int bytes) { | 58 void DrainableIOBuffer::DidConsume(int bytes) { |
56 SetOffset(used_ + bytes); | 59 SetOffset(used_ + bytes); |
57 } | 60 } |
58 | 61 |
59 int DrainableIOBuffer::BytesRemaining() const { | 62 int DrainableIOBuffer::BytesRemaining() const { |
60 return size_ - used_; | 63 return size_ - used_; |
61 } | 64 } |
62 | 65 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 124 |
122 WrappedIOBuffer::WrappedIOBuffer(const char* data) | 125 WrappedIOBuffer::WrappedIOBuffer(const char* data) |
123 : IOBuffer(const_cast<char*>(data)) { | 126 : IOBuffer(const_cast<char*>(data)) { |
124 } | 127 } |
125 | 128 |
126 WrappedIOBuffer::~WrappedIOBuffer() { | 129 WrappedIOBuffer::~WrappedIOBuffer() { |
127 data_ = NULL; | 130 data_ = NULL; |
128 } | 131 } |
129 | 132 |
130 } // namespace net | 133 } // namespace net |
OLD | NEW |