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

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

Issue 1412283002: Convert mojo::system::Dispatcher to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: no change Created 5 years, 2 months 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
« no previous file with comments | « mojo/edk/system/core_test_base.cc ('k') | mojo/edk/system/data_pipe_consumer_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CONSUMER_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_
7 7
8 #include "base/memory/ref_counted.h"
9 #include "mojo/edk/system/dispatcher.h" 8 #include "mojo/edk/system/dispatcher.h"
10 #include "mojo/edk/system/ref_ptr.h" 9 #include "mojo/edk/system/ref_ptr.h"
11 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
12 11
13 namespace mojo { 12 namespace mojo {
14 namespace system { 13 namespace system {
15 14
16 class DataPipe; 15 class DataPipe;
17 16
18 // This is the |Dispatcher| implementation for the consumer handle for data 17 // This is the |Dispatcher| implementation for the consumer handle for data
19 // pipes (created by the Mojo primitive |MojoCreateDataPipe()|). This class is 18 // pipes (created by the Mojo primitive |MojoCreateDataPipe()|). This class is
20 // thread-safe. 19 // thread-safe.
21 class DataPipeConsumerDispatcher final : public Dispatcher { 20 class DataPipeConsumerDispatcher final : public Dispatcher {
22 public: 21 public:
23 static scoped_refptr<DataPipeConsumerDispatcher> Create() { 22 static RefPtr<DataPipeConsumerDispatcher> Create() {
24 return make_scoped_refptr(new DataPipeConsumerDispatcher()); 23 return AdoptRef(new DataPipeConsumerDispatcher());
25 } 24 }
26 25
27 // Must be called before any other methods. 26 // Must be called before any other methods.
28 void Init(RefPtr<DataPipe>&& data_pipe) MOJO_NOT_THREAD_SAFE; 27 void Init(RefPtr<DataPipe>&& data_pipe) MOJO_NOT_THREAD_SAFE;
29 28
30 // |Dispatcher| public methods: 29 // |Dispatcher| public methods:
31 Type GetType() const override; 30 Type GetType() const override;
32 31
33 // The "opposite" of |SerializeAndClose()|. (Typically this is called by 32 // The "opposite" of |SerializeAndClose()|. (Typically this is called by
34 // |Dispatcher::Deserialize()|.) 33 // |Dispatcher::Deserialize()|.)
35 static scoped_refptr<DataPipeConsumerDispatcher> 34 static RefPtr<DataPipeConsumerDispatcher> Deserialize(Channel* channel,
36 Deserialize(Channel* channel, const void* source, size_t size); 35 const void* source,
36 size_t size);
37 37
38 // Get access to the |DataPipe| for testing. 38 // Get access to the |DataPipe| for testing.
39 DataPipe* GetDataPipeForTest(); 39 DataPipe* GetDataPipeForTest();
40 40
41 private: 41 private:
42 DataPipeConsumerDispatcher(); 42 DataPipeConsumerDispatcher();
43 ~DataPipeConsumerDispatcher() override; 43 ~DataPipeConsumerDispatcher() override;
44 44
45 // |Dispatcher| protected methods: 45 // |Dispatcher| protected methods:
46 void CancelAllAwakablesNoLock() override; 46 void CancelAllAwakablesNoLock() override;
47 void CloseImplNoLock() override; 47 void CloseImplNoLock() override;
48 scoped_refptr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() 48 RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() override;
49 override;
50 MojoResult ReadDataImplNoLock(UserPointer<void> elements, 49 MojoResult ReadDataImplNoLock(UserPointer<void> elements,
51 UserPointer<uint32_t> num_bytes, 50 UserPointer<uint32_t> num_bytes,
52 MojoReadDataFlags flags) override; 51 MojoReadDataFlags flags) override;
53 MojoResult BeginReadDataImplNoLock(UserPointer<const void*> buffer, 52 MojoResult BeginReadDataImplNoLock(UserPointer<const void*> buffer,
54 UserPointer<uint32_t> buffer_num_bytes, 53 UserPointer<uint32_t> buffer_num_bytes,
55 MojoReadDataFlags flags) override; 54 MojoReadDataFlags flags) override;
56 MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read) override; 55 MojoResult EndReadDataImplNoLock(uint32_t num_bytes_read) override;
57 HandleSignalsState GetHandleSignalsStateImplNoLock() const override; 56 HandleSignalsState GetHandleSignalsStateImplNoLock() const override;
58 MojoResult AddAwakableImplNoLock(Awakable* awakable, 57 MojoResult AddAwakableImplNoLock(Awakable* awakable,
59 MojoHandleSignals signals, 58 MojoHandleSignals signals,
(...skipping 16 matching lines...) Expand all
76 // This will be null if closed. 75 // This will be null if closed.
77 RefPtr<DataPipe> data_pipe_ MOJO_GUARDED_BY(mutex()); 76 RefPtr<DataPipe> data_pipe_ MOJO_GUARDED_BY(mutex());
78 77
79 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipeConsumerDispatcher); 78 MOJO_DISALLOW_COPY_AND_ASSIGN(DataPipeConsumerDispatcher);
80 }; 79 };
81 80
82 } // namespace system 81 } // namespace system
83 } // namespace mojo 82 } // namespace mojo
84 83
85 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_ 84 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/core_test_base.cc ('k') | mojo/edk/system/data_pipe_consumer_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698