| Index: mojo/edk/system/data_pipe.h
|
| diff --git a/mojo/edk/system/data_pipe.h b/mojo/edk/system/data_pipe.h
|
| index 585893eb096064eef13bcc9a86f89ade6bb11ae4..2d6bd1227be6d5cda94ae9d79b9b2f618c189d2b 100644
|
| --- a/mojo/edk/system/data_pipe.h
|
| +++ b/mojo/edk/system/data_pipe.h
|
| @@ -24,6 +24,7 @@ namespace system {
|
| class Awakable;
|
| class AwakableList;
|
| class Channel;
|
| +class DataPipeImpl;
|
|
|
| // |DataPipe| is a base class for secondary objects implementing data pipes,
|
| // similar to |MessagePipe| (see the explanatory comment in core.cc). It is
|
| @@ -48,6 +49,14 @@ class MOJO_SYSTEM_IMPL_EXPORT DataPipe
|
| UserPointer<const MojoCreateDataPipeOptions> in_options,
|
| MojoCreateDataPipeOptions* out_options);
|
|
|
| + // Creates a local (both producer and consumer) data pipe (using
|
| + // |LocalDataPipeImpl|. |validated_options| should be the output of
|
| + // |ValidateOptions()|. In particular: |struct_size| is ignored (so
|
| + // |validated_options| must be the current version of the struct) and
|
| + // |capacity_num_bytes| must be nonzero.
|
| + static DataPipe* CreateLocal(
|
| + const MojoCreateDataPipeOptions& validated_options);
|
| +
|
| // These are called by the producer dispatcher to implement its methods of
|
| // corresponding names.
|
| void ProducerCancelAllAwakables();
|
| @@ -108,75 +117,11 @@ class MOJO_SYSTEM_IMPL_EXPORT DataPipe
|
| embedder::PlatformHandleVector* platform_handles);
|
| bool ConsumerIsBusy() const;
|
|
|
| - protected:
|
| - DataPipe(bool has_local_producer,
|
| - bool has_local_consumer,
|
| - const MojoCreateDataPipeOptions& validated_options);
|
| -
|
| - friend class base::RefCountedThreadSafe<DataPipe>;
|
| - virtual ~DataPipe();
|
| + // The following are only to be used by |DataPipeImpl| (and its subclasses):
|
|
|
| void ProducerCloseNoLock();
|
| void ConsumerCloseNoLock();
|
|
|
| - virtual void ProducerCloseImplNoLock() = 0;
|
| - // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes_|.
|
| - virtual MojoResult ProducerWriteDataImplNoLock(
|
| - UserPointer<const void> elements,
|
| - UserPointer<uint32_t> num_bytes,
|
| - uint32_t max_num_bytes_to_write,
|
| - uint32_t min_num_bytes_to_write) = 0;
|
| - virtual MojoResult ProducerBeginWriteDataImplNoLock(
|
| - UserPointer<void*> buffer,
|
| - UserPointer<uint32_t> buffer_num_bytes,
|
| - uint32_t min_num_bytes_to_write) = 0;
|
| - virtual MojoResult ProducerEndWriteDataImplNoLock(
|
| - uint32_t num_bytes_written) = 0;
|
| - // Note: A producer should not be writable during a two-phase write.
|
| - virtual HandleSignalsState ProducerGetHandleSignalsStateImplNoLock()
|
| - const = 0;
|
| - virtual void ProducerStartSerializeImplNoLock(
|
| - Channel* channel,
|
| - size_t* max_size,
|
| - size_t* max_platform_handles) = 0;
|
| - virtual bool ProducerEndSerializeImplNoLock(
|
| - Channel* channel,
|
| - void* destination,
|
| - size_t* actual_size,
|
| - embedder::PlatformHandleVector* platform_handles) = 0;
|
| -
|
| - virtual void ConsumerCloseImplNoLock() = 0;
|
| - // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|.
|
| - virtual MojoResult ConsumerReadDataImplNoLock(UserPointer<void> elements,
|
| - UserPointer<uint32_t> num_bytes,
|
| - uint32_t max_num_bytes_to_read,
|
| - uint32_t min_num_bytes_to_read,
|
| - bool peek) = 0;
|
| - virtual MojoResult ConsumerDiscardDataImplNoLock(
|
| - UserPointer<uint32_t> num_bytes,
|
| - uint32_t max_num_bytes_to_discard,
|
| - uint32_t min_num_bytes_to_discard) = 0;
|
| - // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|.
|
| - virtual MojoResult ConsumerQueryDataImplNoLock(
|
| - UserPointer<uint32_t> num_bytes) = 0;
|
| - virtual MojoResult ConsumerBeginReadDataImplNoLock(
|
| - UserPointer<const void*> buffer,
|
| - UserPointer<uint32_t> buffer_num_bytes,
|
| - uint32_t min_num_bytes_to_read) = 0;
|
| - virtual MojoResult ConsumerEndReadDataImplNoLock(uint32_t num_bytes_read) = 0;
|
| - // Note: A consumer should not be writable during a two-phase read.
|
| - virtual HandleSignalsState ConsumerGetHandleSignalsStateImplNoLock()
|
| - const = 0;
|
| - virtual void ConsumerStartSerializeImplNoLock(
|
| - Channel* channel,
|
| - size_t* max_size,
|
| - size_t* max_platform_handles) = 0;
|
| - virtual bool ConsumerEndSerializeImplNoLock(
|
| - Channel* channel,
|
| - void* destination,
|
| - size_t* actual_size,
|
| - embedder::PlatformHandleVector* platform_handles) = 0;
|
| -
|
| // Thread-safe and fast (they don't take the lock):
|
| bool may_discard() const { return may_discard_; }
|
| size_t element_num_bytes() const { return element_num_bytes_; }
|
| @@ -218,6 +163,22 @@ class MOJO_SYSTEM_IMPL_EXPORT DataPipe
|
| }
|
|
|
| private:
|
| + friend class base::RefCountedThreadSafe<DataPipe>;
|
| +
|
| + // |validated_options| should be the output of |ValidateOptions()|. In
|
| + // particular: |struct_size| is ignored (so |validated_options| must be the
|
| + // current version of the struct) and |capacity_num_bytes| must be nonzero.
|
| + // TODO(vtl): |has_local_producer|/|has_local_consumer| shouldn't really be
|
| + // arguments here. Instead, they should be determined from the |impl| ... but
|
| + // the |impl|'s typically figures these out by examining the owner, i.e., the
|
| + // |DataPipe| object. Probably, this indicates that more stuff should be moved
|
| + // to |DataPipeImpl|, but for now we'll live with this.
|
| + DataPipe(bool has_local_producer,
|
| + bool has_local_consumer,
|
| + const MojoCreateDataPipeOptions& validated_options,
|
| + scoped_ptr<DataPipeImpl> impl);
|
| + virtual ~DataPipe();
|
| +
|
| void AwakeProducerAwakablesForStateChangeNoLock(
|
| const HandleSignalsState& new_producer_state);
|
| void AwakeConsumerAwakablesForStateChangeNoLock(
|
| @@ -246,6 +207,7 @@ class MOJO_SYSTEM_IMPL_EXPORT DataPipe
|
| // These are nonzero if and only if a two-phase write/read is in progress.
|
| uint32_t producer_two_phase_max_num_bytes_written_;
|
| uint32_t consumer_two_phase_max_num_bytes_read_;
|
| + scoped_ptr<DataPipeImpl> impl_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DataPipe);
|
| };
|
|
|