| 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.h" | 5 #include "mojo/edk/system/data_pipe.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/aligned_memory.h" | 15 #include "base/memory/aligned_memory.h" |
| 16 #include "mojo/edk/system/awakable_list.h" | 16 #include "mojo/edk/system/awakable_list.h" |
| 17 #include "mojo/edk/system/channel.h" | 17 #include "mojo/edk/system/channel.h" |
| 18 #include "mojo/edk/system/configuration.h" | 18 #include "mojo/edk/system/configuration.h" |
| 19 #include "mojo/edk/system/data_pipe_impl.h" | 19 #include "mojo/edk/system/data_pipe_impl.h" |
| 20 #include "mojo/edk/system/incoming_endpoint.h" | 20 #include "mojo/edk/system/incoming_endpoint.h" |
| 21 #include "mojo/edk/system/local_data_pipe_impl.h" | 21 #include "mojo/edk/system/local_data_pipe_impl.h" |
| 22 #include "mojo/edk/system/memory.h" | 22 #include "mojo/edk/system/memory.h" |
| 23 #include "mojo/edk/system/options_validation.h" | 23 #include "mojo/edk/system/options_validation.h" |
| 24 #include "mojo/edk/system/remote_consumer_data_pipe_impl.h" | 24 #include "mojo/edk/system/remote_consumer_data_pipe_impl.h" |
| 25 #include "mojo/edk/system/remote_producer_data_pipe_impl.h" | 25 #include "mojo/edk/system/remote_producer_data_pipe_impl.h" |
| 26 #include "mojo/edk/util/make_unique.h" | 26 #include "mojo/edk/util/make_unique.h" |
| 27 | 27 |
| 28 using mojo::embedder::ScopedPlatformHandle; |
| 28 using mojo::util::MutexLocker; | 29 using mojo::util::MutexLocker; |
| 29 using mojo::util::RefPtr; | 30 using mojo::util::RefPtr; |
| 30 | 31 |
| 31 namespace mojo { | 32 namespace mojo { |
| 32 namespace system { | 33 namespace system { |
| 33 | 34 |
| 34 // static | 35 // static |
| 35 MojoCreateDataPipeOptions DataPipe::GetDefaultCreateOptions() { | 36 MojoCreateDataPipeOptions DataPipe::GetDefaultCreateOptions() { |
| 36 MojoCreateDataPipeOptions result = { | 37 MojoCreateDataPipeOptions result = { |
| 37 static_cast<uint32_t>(sizeof(MojoCreateDataPipeOptions)), | 38 static_cast<uint32_t>(sizeof(MojoCreateDataPipeOptions)), |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 size_t* max_platform_handles) { | 410 size_t* max_platform_handles) { |
| 410 MutexLocker locker(&mutex_); | 411 MutexLocker locker(&mutex_); |
| 411 DCHECK(has_local_producer_no_lock()); | 412 DCHECK(has_local_producer_no_lock()); |
| 412 impl_->ProducerStartSerialize(channel, max_size, max_platform_handles); | 413 impl_->ProducerStartSerialize(channel, max_size, max_platform_handles); |
| 413 } | 414 } |
| 414 | 415 |
| 415 bool DataPipe::ProducerEndSerialize( | 416 bool DataPipe::ProducerEndSerialize( |
| 416 Channel* channel, | 417 Channel* channel, |
| 417 void* destination, | 418 void* destination, |
| 418 size_t* actual_size, | 419 size_t* actual_size, |
| 419 embedder::PlatformHandleVector* platform_handles) { | 420 std::vector<ScopedPlatformHandle>* platform_handles) { |
| 420 MutexLocker locker(&mutex_); | 421 MutexLocker locker(&mutex_); |
| 421 DCHECK(has_local_producer_no_lock()); | 422 DCHECK(has_local_producer_no_lock()); |
| 422 // Warning: After |ProducerEndSerialize()|, quite probably |impl_| has | 423 // Warning: After |ProducerEndSerialize()|, quite probably |impl_| has |
| 423 // changed. | 424 // changed. |
| 424 bool rv = impl_->ProducerEndSerialize(channel, destination, actual_size, | 425 bool rv = impl_->ProducerEndSerialize(channel, destination, actual_size, |
| 425 platform_handles); | 426 platform_handles); |
| 426 | 427 |
| 427 // TODO(vtl): The code below is similar to, but not quite the same as, | 428 // TODO(vtl): The code below is similar to, but not quite the same as, |
| 428 // |ProducerCloseNoLock()|. | 429 // |ProducerCloseNoLock()|. |
| 429 DCHECK(has_local_producer_no_lock()); | 430 DCHECK(has_local_producer_no_lock()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 size_t* max_platform_handles) { | 619 size_t* max_platform_handles) { |
| 619 MutexLocker locker(&mutex_); | 620 MutexLocker locker(&mutex_); |
| 620 DCHECK(has_local_consumer_no_lock()); | 621 DCHECK(has_local_consumer_no_lock()); |
| 621 impl_->ConsumerStartSerialize(channel, max_size, max_platform_handles); | 622 impl_->ConsumerStartSerialize(channel, max_size, max_platform_handles); |
| 622 } | 623 } |
| 623 | 624 |
| 624 bool DataPipe::ConsumerEndSerialize( | 625 bool DataPipe::ConsumerEndSerialize( |
| 625 Channel* channel, | 626 Channel* channel, |
| 626 void* destination, | 627 void* destination, |
| 627 size_t* actual_size, | 628 size_t* actual_size, |
| 628 embedder::PlatformHandleVector* platform_handles) { | 629 std::vector<ScopedPlatformHandle>* platform_handles) { |
| 629 MutexLocker locker(&mutex_); | 630 MutexLocker locker(&mutex_); |
| 630 DCHECK(has_local_consumer_no_lock()); | 631 DCHECK(has_local_consumer_no_lock()); |
| 631 // Warning: After |ConsumerEndSerialize()|, quite probably |impl_| has | 632 // Warning: After |ConsumerEndSerialize()|, quite probably |impl_| has |
| 632 // changed. | 633 // changed. |
| 633 bool rv = impl_->ConsumerEndSerialize(channel, destination, actual_size, | 634 bool rv = impl_->ConsumerEndSerialize(channel, destination, actual_size, |
| 634 platform_handles); | 635 platform_handles); |
| 635 | 636 |
| 636 // TODO(vtl): The code below is similar to, but not quite the same as, | 637 // TODO(vtl): The code below is similar to, but not quite the same as, |
| 637 // |ConsumerCloseNoLock()|. | 638 // |ConsumerCloseNoLock()|. |
| 638 consumer_awakable_list_->CancelAll(); | 639 consumer_awakable_list_->CancelAll(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 SetProducerClosedNoLock(); | 808 SetProducerClosedNoLock(); |
| 808 } | 809 } |
| 809 | 810 |
| 810 void DataPipe::SetConsumerClosed() { | 811 void DataPipe::SetConsumerClosed() { |
| 811 MutexLocker locker(&mutex_); | 812 MutexLocker locker(&mutex_); |
| 812 SetConsumerClosedNoLock(); | 813 SetConsumerClosedNoLock(); |
| 813 } | 814 } |
| 814 | 815 |
| 815 } // namespace system | 816 } // namespace system |
| 816 } // namespace mojo | 817 } // namespace mojo |
| OLD | NEW |