| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // TODO(vtl): I currently potentially overflow in doing index calculations. | 5 // TODO(vtl): I currently potentially overflow in doing index calculations. |
| 6 // E.g., |start_index_| and |current_num_bytes_| fit into a |uint32_t|, but | 6 // E.g., |start_index_| and |current_num_bytes_| fit into a |uint32_t|, but |
| 7 // their sum may not. This is bad and poses a security risk. (We're currently | 7 // their sum may not. This is bad and poses a security risk. (We're currently |
| 8 // saved by the limit on capacity -- the maximum size of the buffer, checked in | 8 // saved by the limit on capacity -- the maximum size of the buffer, checked in |
| 9 // |DataPipe::ValidateOptions()|, is currently sufficiently small.) | 9 // |DataPipe::ValidateOptions()|, is currently sufficiently small.) |
| 10 | 10 |
| 11 #include "mojo/edk/system/local_data_pipe_impl.h" | 11 #include "mojo/edk/system/local_data_pipe_impl.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 | 14 |
| 15 #include <algorithm> | 15 #include <algorithm> |
| 16 #include <utility> | 16 #include <utility> |
| 17 | 17 |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "mojo/edk/system/channel.h" | 19 #include "mojo/edk/system/channel.h" |
| 20 #include "mojo/edk/system/configuration.h" | 20 #include "mojo/edk/system/configuration.h" |
| 21 #include "mojo/edk/system/data_pipe.h" | 21 #include "mojo/edk/system/data_pipe.h" |
| 22 #include "mojo/edk/system/message_in_transit.h" | 22 #include "mojo/edk/system/message_in_transit.h" |
| 23 #include "mojo/edk/system/message_in_transit_queue.h" | 23 #include "mojo/edk/system/message_in_transit_queue.h" |
| 24 #include "mojo/edk/system/remote_consumer_data_pipe_impl.h" | 24 #include "mojo/edk/system/remote_consumer_data_pipe_impl.h" |
| 25 #include "mojo/edk/system/remote_producer_data_pipe_impl.h" | 25 #include "mojo/edk/system/remote_producer_data_pipe_impl.h" |
| 26 #include "mojo/edk/util/make_unique.h" | 26 #include "mojo/edk/util/make_unique.h" |
| 27 | 27 |
| 28 using mojo::embedder::ScopedPlatformHandle; | 28 using mojo::platform::ScopedPlatformHandle; |
| 29 using mojo::util::MakeUnique; | 29 using mojo::util::MakeUnique; |
| 30 using mojo::util::RefPtr; | 30 using mojo::util::RefPtr; |
| 31 | 31 |
| 32 namespace mojo { | 32 namespace mojo { |
| 33 namespace system { | 33 namespace system { |
| 34 | 34 |
| 35 // Assert some things about some things defined in data_pipe_impl.h (don't make | 35 // Assert some things about some things defined in data_pipe_impl.h (don't make |
| 36 // the assertions there, to avoid including message_in_transit.h). | 36 // the assertions there, to avoid including message_in_transit.h). |
| 37 static_assert(MOJO_ALIGNOF(SerializedDataPipeConsumerDispatcher) == | 37 static_assert(MOJO_ALIGNOF(SerializedDataPipeConsumerDispatcher) == |
| 38 MessageInTransit::kMessageAlignment, | 38 MessageInTransit::kMessageAlignment, |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 void LocalDataPipeImpl::MarkDataAsConsumed(size_t num_bytes) { | 433 void LocalDataPipeImpl::MarkDataAsConsumed(size_t num_bytes) { |
| 434 DCHECK_LE(num_bytes, current_num_bytes_); | 434 DCHECK_LE(num_bytes, current_num_bytes_); |
| 435 start_index_ += num_bytes; | 435 start_index_ += num_bytes; |
| 436 start_index_ %= capacity_num_bytes(); | 436 start_index_ %= capacity_num_bytes(); |
| 437 current_num_bytes_ -= num_bytes; | 437 current_num_bytes_ -= num_bytes; |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace system | 440 } // namespace system |
| 441 } // namespace mojo | 441 } // namespace mojo |
| OLD | NEW |