| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/remote_consumer_data_pipe_impl.h" | 5 #include "mojo/edk/system/remote_consumer_data_pipe_impl.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // TODO(vtl): (End of mostly copied code.) | 250 // TODO(vtl): (End of mostly copied code.) |
| 251 | 251 |
| 252 set_producer_two_phase_max_num_bytes_written(0); | 252 set_producer_two_phase_max_num_bytes_written(0); |
| 253 return MOJO_RESULT_OK; | 253 return MOJO_RESULT_OK; |
| 254 } | 254 } |
| 255 | 255 |
| 256 HandleSignalsState RemoteConsumerDataPipeImpl::ProducerGetHandleSignalsState() | 256 HandleSignalsState RemoteConsumerDataPipeImpl::ProducerGetHandleSignalsState() |
| 257 const { | 257 const { |
| 258 HandleSignalsState rv; | 258 HandleSignalsState rv; |
| 259 if (consumer_open()) { | 259 if (consumer_open()) { |
| 260 if (consumer_num_bytes_ < capacity_num_bytes() && | 260 if (!producer_in_two_phase_write()) { |
| 261 !producer_in_two_phase_write()) | 261 // |producer_write_threshold_num_bytes()| is always at least 1. |
| 262 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_WRITABLE; | 262 if (capacity_num_bytes() - consumer_num_bytes_ >= |
| 263 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_WRITABLE; | 263 producer_write_threshold_num_bytes()) { |
| 264 rv.satisfied_signals |= |
| 265 MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD; |
| 266 } else if (consumer_num_bytes_ < capacity_num_bytes()) { |
| 267 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_WRITABLE; |
| 268 } |
| 269 } |
| 270 rv.satisfiable_signals |= |
| 271 MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_WRITE_THRESHOLD; |
| 264 } else { | 272 } else { |
| 265 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 273 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| 266 } | 274 } |
| 267 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 275 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| 268 return rv; | 276 return rv; |
| 269 } | 277 } |
| 270 | 278 |
| 271 void RemoteConsumerDataPipeImpl::ProducerStartSerialize( | 279 void RemoteConsumerDataPipeImpl::ProducerStartSerialize( |
| 272 Channel* channel, | 280 Channel* channel, |
| 273 size_t* max_size, | 281 size_t* max_size, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 DCHECK(channel_endpoint_); | 433 DCHECK(channel_endpoint_); |
| 426 SetConsumerClosed(); | 434 SetConsumerClosed(); |
| 427 channel_endpoint_->DetachFromClient(); | 435 channel_endpoint_->DetachFromClient(); |
| 428 channel_endpoint_ = nullptr; | 436 channel_endpoint_ = nullptr; |
| 429 if (!producer_in_two_phase_write()) | 437 if (!producer_in_two_phase_write()) |
| 430 DestroyBuffer(); | 438 DestroyBuffer(); |
| 431 } | 439 } |
| 432 | 440 |
| 433 } // namespace system | 441 } // namespace system |
| 434 } // namespace mojo | 442 } // namespace mojo |
| OLD | NEW |