OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
| 6 #define MOJO_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "mojo/system/dispatcher.h" |
| 12 #include "mojo/system/system_impl_export.h" |
| 13 |
| 14 namespace mojo { |
| 15 namespace system { |
| 16 |
| 17 class DataPipe; |
| 18 |
| 19 // This is the |Dispatcher| implementation for the producer handle for data |
| 20 // pipes (created by the Mojo primitive |MojoCreateDataPipe()|). This class is |
| 21 // thread-safe. |
| 22 class MOJO_SYSTEM_IMPL_EXPORT DataPipeProducerDispatcher : public Dispatcher { |
| 23 public: |
| 24 DataPipeProducerDispatcher(); |
| 25 |
| 26 // Must be called before any other methods. |
| 27 void Init(scoped_refptr<DataPipe> data_pipe); |
| 28 |
| 29 private: |
| 30 friend class base::RefCountedThreadSafe<DataPipeProducerDispatcher>; |
| 31 virtual ~DataPipeProducerDispatcher(); |
| 32 |
| 33 // |Dispatcher| implementation/overrides: |
| 34 virtual void CancelAllWaitersNoLock() OVERRIDE; |
| 35 virtual MojoResult CloseImplNoLock() OVERRIDE; |
| 36 virtual MojoResult WriteDataImplNoLock(const void* elements, |
| 37 uint32_t* num_elements, |
| 38 MojoWriteDataFlags flags) OVERRIDE; |
| 39 virtual MojoResult BeginWriteDataImplNoLock( |
| 40 void** buffer, |
| 41 uint32_t* buffer_num_elements, |
| 42 MojoWriteDataFlags flags) OVERRIDE; |
| 43 virtual MojoResult EndWriteDataImplNoLock( |
| 44 uint32_t num_elements_written) OVERRIDE; |
| 45 virtual MojoResult AddWaiterImplNoLock(Waiter* waiter, |
| 46 MojoWaitFlags flags, |
| 47 MojoResult wake_result) OVERRIDE; |
| 48 virtual void RemoveWaiterImplNoLock(Waiter* waiter) OVERRIDE; |
| 49 virtual scoped_refptr<Dispatcher> |
| 50 CreateEquivalentDispatcherAndCloseImplNoLock() OVERRIDE; |
| 51 |
| 52 // Protected by |lock()|: |
| 53 scoped_refptr<DataPipe> data_pipe_; // This will be null if closed. |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(DataPipeProducerDispatcher); |
| 56 }; |
| 57 |
| 58 } // namespace system |
| 59 } // namespace mojo |
| 60 |
| 61 #endif // MOJO_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
OLD | NEW |