Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 Dispatcher::Type DataPipeProducerDispatcher::GetType() const { | 78 Dispatcher::Type DataPipeProducerDispatcher::GetType() const { |
| 79 return Type::DATA_PIPE_PRODUCER; | 79 return Type::DATA_PIPE_PRODUCER; |
| 80 } | 80 } |
| 81 | 81 |
| 82 MojoResult DataPipeProducerDispatcher::Close() { | 82 MojoResult DataPipeProducerDispatcher::Close() { |
| 83 base::AutoLock lock(lock_); | 83 base::AutoLock lock(lock_); |
| 84 DVLOG(1) << "Closing data pipe producer " << pipe_id_; | 84 DVLOG(1) << "Closing data pipe producer " << pipe_id_; |
| 85 return CloseNoLock(); | 85 return CloseNoLock(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 MojoResult DataPipeProducerDispatcher::Watch( | |
| 89 MojoHandleSignals signals, | |
| 90 const Watcher::WatchCallback& callback, | |
| 91 uintptr_t context) { | |
| 92 base::AutoLock lock(lock_); | |
| 93 | |
| 94 if (is_closed_ || in_transit_) | |
| 95 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 96 | |
| 97 return awakable_list_.AddWatcher( | |
| 98 signals, callback, context, GetHandleSignalsStateNoLock()); | |
| 99 } | |
| 100 | |
| 101 MojoResult DataPipeProducerDispatcher::CancelWatch(uintptr_t context) { | |
| 102 base::AutoLock lock(lock_); | |
| 103 | |
| 104 if (is_closed_ || in_transit_) | |
| 105 return MOJO_RESULT_INVALID_ARGUMENT; | |
| 106 | |
| 107 return awakable_list_.RemoveWatcher(context); | |
| 108 } | |
| 109 | |
| 88 MojoResult DataPipeProducerDispatcher::WriteData(const void* elements, | 110 MojoResult DataPipeProducerDispatcher::WriteData(const void* elements, |
| 89 uint32_t* num_bytes, | 111 uint32_t* num_bytes, |
| 90 MojoWriteDataFlags flags) { | 112 MojoWriteDataFlags flags) { |
| 91 base::AutoLock lock(lock_); | 113 base::AutoLock lock(lock_); |
| 92 if (!shared_ring_buffer_ || in_transit_) | 114 if (!shared_ring_buffer_ || in_transit_) |
| 93 return MOJO_RESULT_INVALID_ARGUMENT; | 115 return MOJO_RESULT_INVALID_ARGUMENT; |
| 94 | 116 |
| 95 if (in_two_phase_write_) | 117 if (in_two_phase_write_) |
| 96 return MOJO_RESULT_BUSY; | 118 return MOJO_RESULT_BUSY; |
| 97 | 119 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 | 452 |
| 431 void DataPipeProducerDispatcher::NotifyWrite(uint32_t num_bytes) { | 453 void DataPipeProducerDispatcher::NotifyWrite(uint32_t num_bytes) { |
| 432 DVLOG(1) << "Data pipe producer " << pipe_id_ << " notifying peer: " | 454 DVLOG(1) << "Data pipe producer " << pipe_id_ << " notifying peer: " |
| 433 << num_bytes << " bytes written. [control_port=" | 455 << num_bytes << " bytes written. [control_port=" |
| 434 << control_port_.name() << "]"; | 456 << control_port_.name() << "]"; |
| 435 | 457 |
| 436 SendDataPipeControlMessage(node_controller_, control_port_, | 458 SendDataPipeControlMessage(node_controller_, control_port_, |
| 437 DataPipeCommand::DATA_WAS_WRITTEN, num_bytes); | 459 DataPipeCommand::DATA_WAS_WRITTEN, num_bytes); |
| 438 } | 460 } |
| 439 | 461 |
| 440 void DataPipeProducerDispatcher::OnPortStatusChanged() { | 462 void DataPipeProducerDispatcher::OnPortStatusChanged() { |
|
Anand Mistry (off Chromium)
2016/03/01 07:30:40
Don't you need a RequestContext here as well? Same
Ken Rockot(use gerrit already)
2016/03/01 08:17:44
Oops, done and done
| |
| 441 base::AutoLock lock(lock_); | 463 base::AutoLock lock(lock_); |
| 442 | 464 |
| 443 // We stop observing the control port as soon it's transferred, but this can | 465 // We stop observing the control port as soon it's transferred, but this can |
| 444 // race with events which are raised right before that happens. This is fine | 466 // race with events which are raised right before that happens. This is fine |
| 445 // to ignore. | 467 // to ignore. |
| 446 if (transferred_) | 468 if (transferred_) |
| 447 return; | 469 return; |
| 448 | 470 |
| 449 DVLOG(1) << "Control port status changed for data pipe producer " << pipe_id_; | 471 DVLOG(1) << "Control port status changed for data pipe producer " << pipe_id_; |
| 450 | 472 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 } | 524 } |
| 503 | 525 |
| 504 if (peer_closed_ != was_peer_closed || | 526 if (peer_closed_ != was_peer_closed || |
| 505 available_capacity_ != previous_capacity) { | 527 available_capacity_ != previous_capacity) { |
| 506 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); | 528 awakable_list_.AwakeForStateChange(GetHandleSignalsStateNoLock()); |
| 507 } | 529 } |
| 508 } | 530 } |
| 509 | 531 |
| 510 } // namespace edk | 532 } // namespace edk |
| 511 } // namespace mojo | 533 } // namespace mojo |
| OLD | NEW |