Index: third_party/mojo/src/mojo/edk/system/remote_producer_data_pipe_impl.h |
diff --git a/third_party/mojo/src/mojo/edk/system/local_data_pipe_impl.h b/third_party/mojo/src/mojo/edk/system/remote_producer_data_pipe_impl.h |
similarity index 59% |
copy from third_party/mojo/src/mojo/edk/system/local_data_pipe_impl.h |
copy to third_party/mojo/src/mojo/edk/system/remote_producer_data_pipe_impl.h |
index 14defcbe5593c6cbf02a7e646b7397057bbc3d9a..77117c58c8e57479dc6d15d0ce5b7ff722ffa32f 100644 |
--- a/third_party/mojo/src/mojo/edk/system/local_data_pipe_impl.h |
+++ b/third_party/mojo/src/mojo/edk/system/remote_producer_data_pipe_impl.h |
@@ -1,31 +1,49 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_ |
-#define MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_ |
+#ifndef MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |
+#define MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |
#include "base/macros.h" |
#include "base/memory/aligned_memory.h" |
+#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "mojo/edk/system/channel_endpoint.h" |
#include "mojo/edk/system/data_pipe_impl.h" |
#include "mojo/edk/system/system_impl_export.h" |
namespace mojo { |
namespace system { |
-class DataPipe; |
+class MessageInTransitQueue; |
-// |LocalDataPipeImpl| is a subclass that "implements" |DataPipe| for data pipes |
-// whose producer and consumer are both local. See |DataPipeImpl| for more |
-// details. |
-class MOJO_SYSTEM_IMPL_EXPORT LocalDataPipeImpl : public DataPipeImpl { |
+// |RemoteProducerDataPipeImpl| is a subclass that "implements" |DataPipe| for |
+// data pipes whose producer is remote and whose consumer is local. See |
+// |DataPipeImpl| for more details. |
+class MOJO_SYSTEM_IMPL_EXPORT RemoteProducerDataPipeImpl : public DataPipeImpl { |
public: |
- LocalDataPipeImpl(); |
- ~LocalDataPipeImpl() override; |
+ explicit RemoteProducerDataPipeImpl(ChannelEndpoint* channel_endpoint); |
+ RemoteProducerDataPipeImpl(ChannelEndpoint* channel_endpoint, |
+ scoped_ptr<char, base::AlignedFreeDeleter> buffer, |
+ size_t start_index, |
+ size_t current_num_bytes); |
+ ~RemoteProducerDataPipeImpl() override; |
+ |
+ // Processes messages that were received and queued by an |IncomingEndpoint|. |
+ // On success, returns true and sets |*buffer| (to a buffer of size |
+ // |validated_options.capacity_num_bytes|) and |*buffer_num_bytes|. On |
+ // failure, returns false. Always clears |*messages|. |
+ static bool ProcessMessagesFromIncomingEndpoint( |
+ const MojoCreateDataPipeOptions& validated_options, |
+ MessageInTransitQueue* messages, |
+ scoped_ptr<char, base::AlignedFreeDeleter>* buffer, |
+ size_t* buffer_num_bytes); |
private: |
// |DataPipeImpl| implementation: |
+ // Note: None of the |Producer...()| methods should be called, except |
+ // |ProducerGetHandleSignalsState()|. |
void ProducerClose() override; |
MojoResult ProducerWriteData(UserPointer<const void> elements, |
UserPointer<uint32_t> num_bytes, |
@@ -67,6 +85,8 @@ class MOJO_SYSTEM_IMPL_EXPORT LocalDataPipeImpl : public DataPipeImpl { |
void* destination, |
size_t* actual_size, |
embedder::PlatformHandleVector* platform_handles) override; |
+ bool OnReadMessage(unsigned port, MessageInTransit* message) override; |
+ void OnDetachFromChannel(unsigned port) override; |
void EnsureBuffer(); |
void DestroyBuffer(); |
@@ -76,19 +96,25 @@ class MOJO_SYSTEM_IMPL_EXPORT LocalDataPipeImpl : public DataPipeImpl { |
size_t GetMaxNumBytesToWrite(); |
size_t GetMaxNumBytesToRead(); |
- // Marks the given number of bytes as consumed/discarded. |num_bytes| must be |
- // greater than |current_num_bytes_|. |
+ // Marks the given number of bytes as consumed/discarded. This will send a |
+ // message to the remote producer. |num_bytes| must be no greater than |
+ // |current_num_bytes_|. |
void MarkDataAsConsumed(size_t num_bytes); |
+ void Disconnect(); |
+ |
+ // Should be valid if and only if |producer_open()| returns true. |
+ scoped_refptr<ChannelEndpoint> channel_endpoint_; |
+ |
scoped_ptr<char, base::AlignedFreeDeleter> buffer_; |
// Circular buffer. |
size_t start_index_; |
size_t current_num_bytes_; |
- DISALLOW_COPY_AND_ASSIGN(LocalDataPipeImpl); |
+ DISALLOW_COPY_AND_ASSIGN(RemoteProducerDataPipeImpl); |
}; |
} // namespace system |
} // namespace mojo |
-#endif // MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_ |
+#endif // MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_ |