Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1758)

Unified Diff: mojo/edk/system/remote_producer_data_pipe_impl.cc

Issue 973513004: Allow data pipe producer/consumer handles to be re-sent. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: review comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/remote_consumer_data_pipe_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/remote_producer_data_pipe_impl.cc
diff --git a/mojo/edk/system/remote_producer_data_pipe_impl.cc b/mojo/edk/system/remote_producer_data_pipe_impl.cc
index 4946e114eeb41eb549fd527aed1f71273eabb342..26ef410d7aad6a5f9c65e1fb736fade01d492c86 100644
--- a/mojo/edk/system/remote_producer_data_pipe_impl.cc
+++ b/mojo/edk/system/remote_producer_data_pipe_impl.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/channel_endpoint.h"
#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/data_pipe.h"
@@ -302,9 +303,8 @@ void RemoteProducerDataPipeImpl::ConsumerStartSerialize(
Channel* channel,
size_t* max_size,
size_t* max_platform_handles) {
- // TODO(vtl): Support serializing consumer data pipe handles.
- NOTIMPLEMENTED(); // FIXME
- *max_size = 0;
+ *max_size = sizeof(SerializedDataPipeConsumerDispatcher) +
+ channel->GetSerializedEndpointSize();
*max_platform_handles = 0;
}
@@ -313,10 +313,38 @@ bool RemoteProducerDataPipeImpl::ConsumerEndSerialize(
void* destination,
size_t* actual_size,
embedder::PlatformHandleVector* platform_handles) {
- // TODO(vtl): Support serializing consumer data pipe handles.
- NOTIMPLEMENTED(); // FIXME
- owner()->ConsumerCloseNoLock();
- return false;
+ SerializedDataPipeConsumerDispatcher* s =
+ static_cast<SerializedDataPipeConsumerDispatcher*>(destination);
+ s->validated_options = validated_options();
+ void* destination_for_endpoint = static_cast<char*>(destination) +
+ sizeof(SerializedDataPipeConsumerDispatcher);
+
+ MessageInTransitQueue message_queue;
+ ConvertDataToMessages(buffer_.get(), &start_index_, &current_num_bytes_,
+ &message_queue);
+
+ if (!producer_open()) {
+ // Case 1: The producer is closed.
+ channel->SerializeEndpointWithClosedPeer(destination_for_endpoint,
+ &message_queue);
+ *actual_size = sizeof(SerializedDataPipeConsumerDispatcher) +
+ channel->GetSerializedEndpointSize();
+ return true;
+ }
+
+ // Case 2: The producer isn't closed. We pass |channel_endpoint| back to the
+ // |Channel|. There's no reason for us to continue to exist afterwards.
+
+ // Note: We don't use |port|.
+ scoped_refptr<ChannelEndpoint> channel_endpoint;
+ channel_endpoint.swap(channel_endpoint_);
+ channel->SerializeEndpointWithRemotePeer(destination_for_endpoint,
+ &message_queue, channel_endpoint);
+ owner()->SetProducerClosedNoLock();
+
+ *actual_size = sizeof(SerializedDataPipeConsumerDispatcher) +
+ channel->GetSerializedEndpointSize();
+ return true;
}
bool RemoteProducerDataPipeImpl::OnReadMessage(unsigned /*port*/,
« no previous file with comments | « mojo/edk/system/remote_consumer_data_pipe_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698