OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <functional> | 5 #include <functional> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "remoting/base/compound_buffer.h" | 9 #include "remoting/base/compound_buffer.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 total_bytes_ += size; | 45 total_bytes_ += size; |
46 } | 46 } |
47 | 47 |
48 void CompoundBuffer::Append(net::IOBuffer* buffer, int size) { | 48 void CompoundBuffer::Append(net::IOBuffer* buffer, int size) { |
49 Append(buffer, buffer->data(), size); | 49 Append(buffer, buffer->data(), size); |
50 } | 50 } |
51 | 51 |
52 void CompoundBuffer::Append(const CompoundBuffer& buffer) { | 52 void CompoundBuffer::Append(const CompoundBuffer& buffer) { |
53 for (DataChunkList::const_iterator it = buffer.chunks_.begin(); | 53 for (DataChunkList::const_iterator it = buffer.chunks_.begin(); |
54 it != buffer.chunks_.end(); ++it) { | 54 it != buffer.chunks_.end(); ++it) { |
55 Append(it->buffer, it->start, it->size); | 55 Append(it->buffer.get(), it->start, it->size); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void CompoundBuffer::Prepend(net::IOBuffer* buffer, | 59 void CompoundBuffer::Prepend(net::IOBuffer* buffer, |
60 const char* start, int size) { | 60 const char* start, int size) { |
61 // A weak check that the |start| is within |buffer|. | 61 // A weak check that the |start| is within |buffer|. |
62 DCHECK_GE(start, buffer->data()); | 62 DCHECK_GE(start, buffer->data()); |
63 DCHECK_GT(size, 0); | 63 DCHECK_GT(size, 0); |
64 | 64 |
65 CHECK(!locked_); | 65 CHECK(!locked_); |
66 | 66 |
67 chunks_.push_front(DataChunk(buffer, start, size)); | 67 chunks_.push_front(DataChunk(buffer, start, size)); |
68 total_bytes_ += size; | 68 total_bytes_ += size; |
69 } | 69 } |
70 | 70 |
71 void CompoundBuffer::Prepend(net::IOBuffer* buffer, int size) { | 71 void CompoundBuffer::Prepend(net::IOBuffer* buffer, int size) { |
72 Prepend(buffer, buffer->data(), size); | 72 Prepend(buffer, buffer->data(), size); |
73 } | 73 } |
74 | 74 |
75 void CompoundBuffer::Prepend(const CompoundBuffer& buffer) { | 75 void CompoundBuffer::Prepend(const CompoundBuffer& buffer) { |
76 for (DataChunkList::const_iterator it = buffer.chunks_.begin(); | 76 for (DataChunkList::const_iterator it = buffer.chunks_.begin(); |
77 it != buffer.chunks_.end(); ++it) { | 77 it != buffer.chunks_.end(); ++it) { |
78 Prepend(it->buffer, it->start, it->size); | 78 Prepend(it->buffer.get(), it->start, it->size); |
79 } | 79 } |
80 } | 80 } |
81 void CompoundBuffer::AppendCopyOf(const char* data, int size) { | 81 void CompoundBuffer::AppendCopyOf(const char* data, int size) { |
82 net::IOBuffer* buffer = new net::IOBuffer(size); | 82 net::IOBuffer* buffer = new net::IOBuffer(size); |
83 memcpy(buffer->data(), data, size); | 83 memcpy(buffer->data(), data, size); |
84 Append(buffer, size); | 84 Append(buffer, size); |
85 } | 85 } |
86 | 86 |
87 void CompoundBuffer::PrependCopyOf(const char* data, int size) { | 87 void CompoundBuffer::PrependCopyOf(const char* data, int size) { |
88 net::IOBuffer* buffer = new net::IOBuffer(size); | 88 net::IOBuffer* buffer = new net::IOBuffer(size); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 return count == 0; | 270 return count == 0; |
271 } | 271 } |
272 | 272 |
273 int64 CompoundBufferInputStream::ByteCount() const { | 273 int64 CompoundBufferInputStream::ByteCount() const { |
274 return position_; | 274 return position_; |
275 } | 275 } |
276 | 276 |
277 } // namespace remoting | 277 } // namespace remoting |
OLD | NEW |