Index: third_party/mojo/src/mojo/edk/system/remote_consumer_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_consumer_data_pipe_impl.h |
similarity index 60% |
copy from third_party/mojo/src/mojo/edk/system/local_data_pipe_impl.h |
copy to third_party/mojo/src/mojo/edk/system/remote_consumer_data_pipe_impl.h |
index 14defcbe5593c6cbf02a7e646b7397057bbc3d9a..68e856c9eabdbd1e3fb306f5c8ffbe8b6e1c93b9 100644 |
--- a/third_party/mojo/src/mojo/edk/system/local_data_pipe_impl.h |
+++ b/third_party/mojo/src/mojo/edk/system/remote_consumer_data_pipe_impl.h |
@@ -1,31 +1,44 @@ |
-// 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_CONSUMER_DATA_PIPE_IMPL_H_ |
+#define MOJO_EDK_SYSTEM_REMOTE_CONSUMER_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; |
- |
-// |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 { |
+// |RemoteConsumerDataPipeImpl| is a subclass that "implements" |DataPipe| for |
+// data pipes whose producer is local and whose consumer is remote. See |
+// |DataPipeImpl| for more details. |
+class MOJO_SYSTEM_IMPL_EXPORT RemoteConsumerDataPipeImpl : public DataPipeImpl { |
public: |
- LocalDataPipeImpl(); |
- ~LocalDataPipeImpl() override; |
+ RemoteConsumerDataPipeImpl(ChannelEndpoint* channel_endpoint, |
+ size_t consumer_num_bytes); |
+ ~RemoteConsumerDataPipeImpl() override; |
+ |
+ // Processes messages that were received and queued by an |IncomingEndpoint|. |
+ // |*consumer_num_bytes| should be set to the value from the |
+ // |SerializedDataPipeProducerDispatcher|. On success, returns true and |
+ // updates |*consumer_num_bytes|. On failure, returns false (it may or may not |
+ // modify |*consumer_num_bytes|). Always clears |*messages|. |
+ static bool ProcessMessagesFromIncomingEndpoint( |
+ const MojoCreateDataPipeOptions& validated_options, |
+ size_t* consumer_num_bytes, |
+ MessageInTransitQueue* messages); |
private: |
// |DataPipeImpl| implementation: |
+ // Note: None of the |Consumer...()| methods should be called, except |
+ // |ConsumerGetHandleSignalsState()|. |
void ProducerClose() override; |
MojoResult ProducerWriteData(UserPointer<const void> elements, |
UserPointer<uint32_t> num_bytes, |
@@ -67,28 +80,28 @@ 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(); |
- // Get the maximum (single) write/read size right now (in number of elements); |
- // result fits in a |uint32_t|. |
- size_t GetMaxNumBytesToWrite(); |
- size_t GetMaxNumBytesToRead(); |
+ void Disconnect(); |
+ |
+ // Should be valid if and only if |consumer_open()| returns true. |
+ scoped_refptr<ChannelEndpoint> channel_endpoint_; |
- // Marks the given number of bytes as consumed/discarded. |num_bytes| must be |
- // greater than |current_num_bytes_|. |
- void MarkDataAsConsumed(size_t num_bytes); |
+ // The number of bytes we've sent the consumer, but don't *know* have been |
+ // consumed. |
+ size_t consumer_num_bytes_; |
+ // Used for two-phase writes. |
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(RemoteConsumerDataPipeImpl); |
}; |
} // namespace system |
} // namespace mojo |
-#endif // MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_ |
+#endif // MOJO_EDK_SYSTEM_REMOTE_CONSUMER_DATA_PIPE_IMPL_H_ |