Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: mojo/edk/system/data_pipe_producer_dispatcher.h

Issue 1423713009: EDK: Move ref counting classes to mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_DATA_PIPE_PRODUCER_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_
7 7
8 #include "mojo/edk/system/dispatcher.h" 8 #include "mojo/edk/system/dispatcher.h"
9 #include "mojo/edk/system/ref_ptr.h" 9 #include "mojo/edk/util/ref_ptr.h"
10 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace system { 13 namespace system {
14 14
15 class DataPipe; 15 class DataPipe;
16 16
17 // This is the |Dispatcher| implementation for the producer handle for data 17 // This is the |Dispatcher| implementation for the producer handle for data
18 // pipes (created by the Mojo primitive |MojoCreateDataPipe()|). This class is 18 // pipes (created by the Mojo primitive |MojoCreateDataPipe()|). This class is
19 // thread-safe. 19 // thread-safe.
20 class DataPipeProducerDispatcher final : public Dispatcher { 20 class DataPipeProducerDispatcher final : public Dispatcher {
21 public: 21 public:
22 static RefPtr<DataPipeProducerDispatcher> Create() { 22 static util::RefPtr<DataPipeProducerDispatcher> Create() {
23 return AdoptRef(new DataPipeProducerDispatcher()); 23 return AdoptRef(new DataPipeProducerDispatcher());
24 } 24 }
25 25
26 // Must be called before any other methods. 26 // Must be called before any other methods.
27 void Init(RefPtr<DataPipe>&& data_pipe) MOJO_NOT_THREAD_SAFE; 27 void Init(util::RefPtr<DataPipe>&& data_pipe) MOJO_NOT_THREAD_SAFE;
28 28
29 // |Dispatcher| public methods: 29 // |Dispatcher| public methods:
30 Type GetType() const override; 30 Type GetType() const override;
31 31
32 // The "opposite" of |SerializeAndClose()|. (Typically this is called by 32 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
33 // |Dispatcher::Deserialize()|.) 33 // |Dispatcher::Deserialize()|.)
34 static RefPtr<DataPipeProducerDispatcher> Deserialize(Channel* channel, 34 static util::RefPtr<DataPipeProducerDispatcher>
35 const void* source, 35 Deserialize(Channel* channel, const void* source, size_t size);
36 size_t size);
37 36
38 // Get access to the |DataPipe| for testing. 37 // Get access to the |DataPipe| for testing.
39 DataPipe* GetDataPipeForTest(); 38 DataPipe* GetDataPipeForTest();
40 39
41 private: 40 private:
42 DataPipeProducerDispatcher(); 41 DataPipeProducerDispatcher();
43 ~DataPipeProducerDispatcher() override; 42 ~DataPipeProducerDispatcher() override;
44 43
45 // |Dispatcher| protected methods: 44 // |Dispatcher| protected methods:
46 void CancelAllAwakablesNoLock() override; 45 void CancelAllAwakablesNoLock() override;
47 void CloseImplNoLock() override; 46 void CloseImplNoLock() override;
48 RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() override; 47 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock()
48 override;
49 MojoResult WriteDataImplNoLock(UserPointer<const void> elements, 49 MojoResult WriteDataImplNoLock(UserPointer<const void> elements,
50 UserPointer<uint32_t> num_bytes, 50 UserPointer<uint32_t> num_bytes,
51 MojoWriteDataFlags flags) override; 51 MojoWriteDataFlags flags) override;
52 MojoResult BeginWriteDataImplNoLock(UserPointer<void*> buffer, 52 MojoResult BeginWriteDataImplNoLock(UserPointer<void*> buffer,
53 UserPointer<uint32_t> buffer_num_bytes, 53 UserPointer<uint32_t> buffer_num_bytes,
54 MojoWriteDataFlags flags) override; 54 MojoWriteDataFlags flags) override;
55 MojoResult EndWriteDataImplNoLock(uint32_t num_bytes_written) override; 55 MojoResult EndWriteDataImplNoLock(uint32_t num_bytes_written) override;
56 HandleSignalsState GetHandleSignalsStateImplNoLock() const override; 56 HandleSignalsState GetHandleSignalsStateImplNoLock() const override;
57 MojoResult AddAwakableImplNoLock(Awakable* awakable, 57 MojoResult AddAwakableImplNoLock(Awakable* awakable,
58 MojoHandleSignals signals, 58 MojoHandleSignals signals,
59 uint32_t context, 59 uint32_t context,
60 HandleSignalsState* signals_state) override; 60 HandleSignalsState* signals_state) override;
61 void RemoveAwakableImplNoLock(Awakable* awakable, 61 void RemoveAwakableImplNoLock(Awakable* awakable,
62 HandleSignalsState* signals_state) override; 62 HandleSignalsState* signals_state) override;
63 void StartSerializeImplNoLock(Channel* channel, 63 void StartSerializeImplNoLock(Channel* channel,
64 size_t* max_size, 64 size_t* max_size,
65 size_t* max_platform_handles) override 65 size_t* max_platform_handles) override
66 MOJO_NOT_THREAD_SAFE; 66 MOJO_NOT_THREAD_SAFE;
67 bool EndSerializeAndCloseImplNoLock( 67 bool EndSerializeAndCloseImplNoLock(
68 Channel* channel, 68 Channel* channel,
69 void* destination, 69 void* destination,
70 size_t* actual_size, 70 size_t* actual_size,
71 embedder::PlatformHandleVector* platform_handles) override 71 embedder::PlatformHandleVector* platform_handles) override
72 MOJO_NOT_THREAD_SAFE; 72 MOJO_NOT_THREAD_SAFE;
73 bool IsBusyNoLock() const override; 73 bool IsBusyNoLock() const override;
74 74
75 // This will be null if closed. 75 // This will be null if closed.
76 RefPtr<DataPipe> data_pipe_ MOJO_GUARDED_BY(mutex()); 76 util::RefPtr<DataPipe> data_pipe_ MOJO_GUARDED_BY(mutex());
77 77
78 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipeProducerDispatcher); 78 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipeProducerDispatcher);
79 }; 79 };
80 80
81 } // namespace system 81 } // namespace system
82 } // namespace mojo 82 } // namespace mojo
83 83
84 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ 84 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_impl_unittest.cc ('k') | mojo/edk/system/data_pipe_producer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698