| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |
| 6 #define MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ | 6 #define MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
| 11 #include "mojo/edk/system/channel_endpoint.h" | 11 #include "mojo/edk/system/channel_endpoint.h" |
| 12 #include "mojo/edk/system/data_pipe_impl.h" | 12 #include "mojo/edk/system/data_pipe_impl.h" |
| 13 #include "mojo/edk/system/ref_ptr.h" | 13 #include "mojo/edk/util/ref_ptr.h" |
| 14 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace system { | 17 namespace system { |
| 18 | 18 |
| 19 class MessageInTransitQueue; | 19 class MessageInTransitQueue; |
| 20 | 20 |
| 21 // |RemoteProducerDataPipeImpl| is a subclass that "implements" |DataPipe| for | 21 // |RemoteProducerDataPipeImpl| is a subclass that "implements" |DataPipe| for |
| 22 // data pipes whose producer is remote and whose consumer is local. See | 22 // data pipes whose producer is remote and whose consumer is local. See |
| 23 // |DataPipeImpl| for more details. | 23 // |DataPipeImpl| for more details. |
| 24 class RemoteProducerDataPipeImpl final : public DataPipeImpl { | 24 class RemoteProducerDataPipeImpl final : public DataPipeImpl { |
| 25 public: | 25 public: |
| 26 explicit RemoteProducerDataPipeImpl( | 26 explicit RemoteProducerDataPipeImpl( |
| 27 RefPtr<ChannelEndpoint>&& channel_endpoint); | 27 util::RefPtr<ChannelEndpoint>&& channel_endpoint); |
| 28 RemoteProducerDataPipeImpl( | 28 RemoteProducerDataPipeImpl( |
| 29 RefPtr<ChannelEndpoint>&& channel_endpoint, | 29 util::RefPtr<ChannelEndpoint>&& channel_endpoint, |
| 30 std::unique_ptr<char, base::AlignedFreeDeleter> buffer, | 30 std::unique_ptr<char, base::AlignedFreeDeleter> buffer, |
| 31 size_t start_index, | 31 size_t start_index, |
| 32 size_t current_num_bytes); | 32 size_t current_num_bytes); |
| 33 ~RemoteProducerDataPipeImpl() override; | 33 ~RemoteProducerDataPipeImpl() override; |
| 34 | 34 |
| 35 // Processes messages that were received and queued by an |IncomingEndpoint|. | 35 // Processes messages that were received and queued by an |IncomingEndpoint|. |
| 36 // On success, returns true and sets |*buffer| (to a buffer of size | 36 // On success, returns true and sets |*buffer| (to a buffer of size |
| 37 // |validated_options.capacity_num_bytes|) and |*buffer_num_bytes|. On | 37 // |validated_options.capacity_num_bytes|) and |*buffer_num_bytes|. On |
| 38 // failure, returns false. Always clears |*messages|. | 38 // failure, returns false. Always clears |*messages|. |
| 39 static bool ProcessMessagesFromIncomingEndpoint( | 39 static bool ProcessMessagesFromIncomingEndpoint( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 size_t GetMaxNumBytesToRead(); | 99 size_t GetMaxNumBytesToRead(); |
| 100 | 100 |
| 101 // Marks the given number of bytes as consumed/discarded. This will send a | 101 // Marks the given number of bytes as consumed/discarded. This will send a |
| 102 // message to the remote producer. |num_bytes| must be no greater than | 102 // message to the remote producer. |num_bytes| must be no greater than |
| 103 // |current_num_bytes_|. | 103 // |current_num_bytes_|. |
| 104 void MarkDataAsConsumed(size_t num_bytes); | 104 void MarkDataAsConsumed(size_t num_bytes); |
| 105 | 105 |
| 106 void Disconnect(); | 106 void Disconnect(); |
| 107 | 107 |
| 108 // Should be valid if and only if |producer_open()| returns true. | 108 // Should be valid if and only if |producer_open()| returns true. |
| 109 RefPtr<ChannelEndpoint> channel_endpoint_; | 109 util::RefPtr<ChannelEndpoint> channel_endpoint_; |
| 110 | 110 |
| 111 std::unique_ptr<char, base::AlignedFreeDeleter> buffer_; | 111 std::unique_ptr<char, base::AlignedFreeDeleter> buffer_; |
| 112 // Circular buffer. | 112 // Circular buffer. |
| 113 size_t start_index_; | 113 size_t start_index_; |
| 114 size_t current_num_bytes_; | 114 size_t current_num_bytes_; |
| 115 | 115 |
| 116 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImpl); | 116 MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImpl); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace system | 119 } // namespace system |
| 120 } // namespace mojo | 120 } // namespace mojo |
| 121 | 121 |
| 122 #endif // MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ | 122 #endif // MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |
| OLD | NEW |