| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 void CompoundBuffer::CropFront(int bytes) { | 93 void CompoundBuffer::CropFront(int bytes) { |
| 94 CHECK(!locked_); | 94 CHECK(!locked_); |
| 95 | 95 |
| 96 if (total_bytes_ <= bytes) { | 96 if (total_bytes_ <= bytes) { |
| 97 Clear(); | 97 Clear(); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 | 100 |
| 101 total_bytes_ -= bytes; | 101 total_bytes_ -= bytes; |
| 102 while (chunks_.size() > 0 && chunks_.front().size <= bytes) { | 102 while (!chunks_.empty() && chunks_.front().size <= bytes) { |
| 103 bytes -= chunks_.front().size; | 103 bytes -= chunks_.front().size; |
| 104 chunks_.pop_front(); | 104 chunks_.pop_front(); |
| 105 } | 105 } |
| 106 if (chunks_.size() > 0 && bytes > 0) { | 106 if (!chunks_.empty() && bytes > 0) { |
| 107 chunks_.front().start += bytes; | 107 chunks_.front().start += bytes; |
| 108 chunks_.front().size -= bytes; | 108 chunks_.front().size -= bytes; |
| 109 DCHECK_GT(chunks_.front().size, 0); | 109 DCHECK_GT(chunks_.front().size, 0); |
| 110 bytes = 0; | 110 bytes = 0; |
| 111 } | 111 } |
| 112 DCHECK_EQ(bytes, 0); | 112 DCHECK_EQ(bytes, 0); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void CompoundBuffer::CropBack(int bytes) { | 115 void CompoundBuffer::CropBack(int bytes) { |
| 116 CHECK(!locked_); | 116 CHECK(!locked_); |
| 117 | 117 |
| 118 if (total_bytes_ <= bytes) { | 118 if (total_bytes_ <= bytes) { |
| 119 Clear(); | 119 Clear(); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 total_bytes_ -= bytes; | 123 total_bytes_ -= bytes; |
| 124 while (chunks_.size() > 0 && chunks_.back().size <= bytes) { | 124 while (!chunks_.empty() && chunks_.back().size <= bytes) { |
| 125 bytes -= chunks_.back().size; | 125 bytes -= chunks_.back().size; |
| 126 chunks_.pop_back(); | 126 chunks_.pop_back(); |
| 127 } | 127 } |
| 128 if (chunks_.size() > 0 && bytes > 0) { | 128 if (!chunks_.empty() && bytes > 0) { |
| 129 chunks_.back().size -= bytes; | 129 chunks_.back().size -= bytes; |
| 130 DCHECK_GT(chunks_.back().size, 0); | 130 DCHECK_GT(chunks_.back().size, 0); |
| 131 bytes = 0; | 131 bytes = 0; |
| 132 } | 132 } |
| 133 DCHECK_EQ(bytes, 0); | 133 DCHECK_EQ(bytes, 0); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CompoundBuffer::Lock() { | 136 void CompoundBuffer::Lock() { |
| 137 locked_ = true; | 137 locked_ = true; |
| 138 } | 138 } |
| (...skipping 129 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 |