OLD | NEW |
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 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 5 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/data_pipe.h" | 8 #include "mojo/edk/system/data_pipe.h" |
9 #include "mojo/edk/system/memory.h" | 9 #include "mojo/edk/system/memory.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 namespace system { | 12 namespace system { |
13 | 13 |
14 DataPipeProducerDispatcher::DataPipeProducerDispatcher() { | 14 DataPipeProducerDispatcher::DataPipeProducerDispatcher() { |
15 } | 15 } |
16 | 16 |
17 void DataPipeProducerDispatcher::Init(scoped_refptr<DataPipe> data_pipe) { | 17 void DataPipeProducerDispatcher::Init(scoped_refptr<DataPipe> data_pipe) { |
18 DCHECK(data_pipe.get()); | 18 DCHECK(data_pipe); |
19 data_pipe_ = data_pipe; | 19 data_pipe_ = data_pipe; |
20 } | 20 } |
21 | 21 |
22 Dispatcher::Type DataPipeProducerDispatcher::GetType() const { | 22 Dispatcher::Type DataPipeProducerDispatcher::GetType() const { |
23 return kTypeDataPipeProducer; | 23 return kTypeDataPipeProducer; |
24 } | 24 } |
25 | 25 |
26 DataPipeProducerDispatcher::~DataPipeProducerDispatcher() { | 26 DataPipeProducerDispatcher::~DataPipeProducerDispatcher() { |
27 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe. | 27 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe. |
28 DCHECK(!data_pipe_.get()); | 28 DCHECK(!data_pipe_); |
29 } | 29 } |
30 | 30 |
31 void DataPipeProducerDispatcher::CancelAllWaitersNoLock() { | 31 void DataPipeProducerDispatcher::CancelAllAwakablesNoLock() { |
32 lock().AssertAcquired(); | 32 lock().AssertAcquired(); |
33 data_pipe_->ProducerCancelAllWaiters(); | 33 data_pipe_->ProducerCancelAllAwakables(); |
34 } | 34 } |
35 | 35 |
36 void DataPipeProducerDispatcher::CloseImplNoLock() { | 36 void DataPipeProducerDispatcher::CloseImplNoLock() { |
37 lock().AssertAcquired(); | 37 lock().AssertAcquired(); |
38 data_pipe_->ProducerClose(); | 38 data_pipe_->ProducerClose(); |
39 data_pipe_ = nullptr; | 39 data_pipe_ = nullptr; |
40 } | 40 } |
41 | 41 |
42 scoped_refptr<Dispatcher> | 42 scoped_refptr<Dispatcher> |
43 DataPipeProducerDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { | 43 DataPipeProducerDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 return data_pipe_->ProducerEndWriteData(num_bytes_written); | 76 return data_pipe_->ProducerEndWriteData(num_bytes_written); |
77 } | 77 } |
78 | 78 |
79 HandleSignalsState DataPipeProducerDispatcher::GetHandleSignalsStateImplNoLock() | 79 HandleSignalsState DataPipeProducerDispatcher::GetHandleSignalsStateImplNoLock() |
80 const { | 80 const { |
81 lock().AssertAcquired(); | 81 lock().AssertAcquired(); |
82 return data_pipe_->ProducerGetHandleSignalsState(); | 82 return data_pipe_->ProducerGetHandleSignalsState(); |
83 } | 83 } |
84 | 84 |
85 MojoResult DataPipeProducerDispatcher::AddWaiterImplNoLock( | 85 MojoResult DataPipeProducerDispatcher::AddAwakableImplNoLock( |
86 Waiter* waiter, | 86 Awakable* awakable, |
87 MojoHandleSignals signals, | 87 MojoHandleSignals signals, |
88 uint32_t context, | 88 uint32_t context, |
89 HandleSignalsState* signals_state) { | 89 HandleSignalsState* signals_state) { |
90 lock().AssertAcquired(); | 90 lock().AssertAcquired(); |
91 return data_pipe_->ProducerAddWaiter(waiter, signals, context, signals_state); | 91 return data_pipe_->ProducerAddAwakable(awakable, signals, context, |
| 92 signals_state); |
92 } | 93 } |
93 | 94 |
94 void DataPipeProducerDispatcher::RemoveWaiterImplNoLock( | 95 void DataPipeProducerDispatcher::RemoveAwakableImplNoLock( |
95 Waiter* waiter, | 96 Awakable* awakable, |
96 HandleSignalsState* signals_state) { | 97 HandleSignalsState* signals_state) { |
97 lock().AssertAcquired(); | 98 lock().AssertAcquired(); |
98 data_pipe_->ProducerRemoveWaiter(waiter, signals_state); | 99 data_pipe_->ProducerRemoveAwakable(awakable, signals_state); |
99 } | 100 } |
100 | 101 |
101 bool DataPipeProducerDispatcher::IsBusyNoLock() const { | 102 bool DataPipeProducerDispatcher::IsBusyNoLock() const { |
102 lock().AssertAcquired(); | 103 lock().AssertAcquired(); |
103 return data_pipe_->ProducerIsBusy(); | 104 return data_pipe_->ProducerIsBusy(); |
104 } | 105 } |
105 | 106 |
106 } // namespace system | 107 } // namespace system |
107 } // namespace mojo | 108 } // namespace mojo |
OLD | NEW |