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_consumer_dispatcher.h" | 5 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 Dispatcher::Type DataPipeConsumerDispatcher::GetType() const { | 79 Dispatcher::Type DataPipeConsumerDispatcher::GetType() const { |
80 return Type::DATA_PIPE_CONSUMER; | 80 return Type::DATA_PIPE_CONSUMER; |
81 } | 81 } |
82 | 82 |
83 MojoResult DataPipeConsumerDispatcher::Close() { | 83 MojoResult DataPipeConsumerDispatcher::Close() { |
84 base::AutoLock lock(lock_); | 84 base::AutoLock lock(lock_); |
85 DVLOG(1) << "Closing data pipe consumer " << pipe_id_; | 85 DVLOG(1) << "Closing data pipe consumer " << pipe_id_; |
86 return CloseNoLock(); | 86 return CloseNoLock(); |
87 } | 87 } |
88 | 88 |
| 89 |
| 90 MojoResult DataPipeConsumerDispatcher::Watch( |
| 91 MojoHandleSignals signals, |
| 92 const Watcher::WatchCallback& callback, |
| 93 uintptr_t context) { |
| 94 base::AutoLock lock(lock_); |
| 95 |
| 96 if (is_closed_ || in_transit_) |
| 97 return MOJO_RESULT_INVALID_ARGUMENT; |
| 98 |
| 99 return awakable_list_.AddWatcher( |
| 100 signals, callback, context, GetHandleSignalsStateNoLock()); |
| 101 } |
| 102 |
| 103 MojoResult DataPipeConsumerDispatcher::CancelWatch(uintptr_t context) { |
| 104 base::AutoLock lock(lock_); |
| 105 |
| 106 if (is_closed_ || in_transit_) |
| 107 return MOJO_RESULT_INVALID_ARGUMENT; |
| 108 |
| 109 return awakable_list_.RemoveWatcher(context); |
| 110 } |
| 111 |
89 MojoResult DataPipeConsumerDispatcher::ReadData(void* elements, | 112 MojoResult DataPipeConsumerDispatcher::ReadData(void* elements, |
90 uint32_t* num_bytes, | 113 uint32_t* num_bytes, |
91 MojoReadDataFlags flags) { | 114 MojoReadDataFlags flags) { |
92 base::AutoLock lock(lock_); | 115 base::AutoLock lock(lock_); |
93 if (!shared_ring_buffer_ || in_transit_) | 116 if (!shared_ring_buffer_ || in_transit_) |
94 return MOJO_RESULT_INVALID_ARGUMENT; | 117 return MOJO_RESULT_INVALID_ARGUMENT; |
95 | 118 |
96 if (in_two_phase_read_) | 119 if (in_two_phase_read_) |
97 return MOJO_RESULT_BUSY; | 120 return MOJO_RESULT_BUSY; |
98 | 121 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 547 } |
525 | 548 |
526 if (peer_closed_ != was_peer_closed || | 549 if (peer_closed_ != was_peer_closed || |
527 bytes_available_ != previous_bytes_available) { | 550 bytes_available_ != previous_bytes_available) { |
528 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | 551 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); |
529 } | 552 } |
530 } | 553 } |
531 | 554 |
532 } // namespace edk | 555 } // namespace edk |
533 } // namespace mojo | 556 } // namespace mojo |
OLD | NEW |