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

Side by Side Diff: mojo/edk/system/remote_consumer_data_pipe_impl.cc

Issue 1478503003: EDK: Convert most uses of PlatformHandleVector to std::vector<ScopedPlatformHandle>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "mojo/edk/system/channel.h" 14 #include "mojo/edk/system/channel.h"
15 #include "mojo/edk/system/channel_endpoint.h" 15 #include "mojo/edk/system/channel_endpoint.h"
16 #include "mojo/edk/system/configuration.h" 16 #include "mojo/edk/system/configuration.h"
17 #include "mojo/edk/system/data_pipe.h" 17 #include "mojo/edk/system/data_pipe.h"
18 #include "mojo/edk/system/message_in_transit.h" 18 #include "mojo/edk/system/message_in_transit.h"
19 #include "mojo/edk/system/remote_data_pipe_ack.h" 19 #include "mojo/edk/system/remote_data_pipe_ack.h"
20 20
21 using mojo::embedder::ScopedPlatformHandle;
21 using mojo::util::RefPtr; 22 using mojo::util::RefPtr;
22 23
23 namespace mojo { 24 namespace mojo {
24 namespace system { 25 namespace system {
25 26
26 namespace { 27 namespace {
27 28
28 bool ValidateIncomingMessage(size_t element_num_bytes, 29 bool ValidateIncomingMessage(size_t element_num_bytes,
29 size_t capacity_num_bytes, 30 size_t capacity_num_bytes,
30 size_t consumer_num_bytes, 31 size_t consumer_num_bytes,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 size_t* max_platform_handles) { 272 size_t* max_platform_handles) {
272 *max_size = sizeof(SerializedDataPipeProducerDispatcher) + 273 *max_size = sizeof(SerializedDataPipeProducerDispatcher) +
273 channel->GetSerializedEndpointSize(); 274 channel->GetSerializedEndpointSize();
274 *max_platform_handles = 0; 275 *max_platform_handles = 0;
275 } 276 }
276 277
277 bool RemoteConsumerDataPipeImpl::ProducerEndSerialize( 278 bool RemoteConsumerDataPipeImpl::ProducerEndSerialize(
278 Channel* channel, 279 Channel* channel,
279 void* destination, 280 void* destination,
280 size_t* actual_size, 281 size_t* actual_size,
281 embedder::PlatformHandleVector* platform_handles) { 282 std::vector<ScopedPlatformHandle>* /*platform_handles*/) {
282 SerializedDataPipeProducerDispatcher* s = 283 SerializedDataPipeProducerDispatcher* s =
283 static_cast<SerializedDataPipeProducerDispatcher*>(destination); 284 static_cast<SerializedDataPipeProducerDispatcher*>(destination);
284 s->validated_options = validated_options(); 285 s->validated_options = validated_options();
285 void* destination_for_endpoint = static_cast<char*>(destination) + 286 void* destination_for_endpoint = static_cast<char*>(destination) +
286 sizeof(SerializedDataPipeProducerDispatcher); 287 sizeof(SerializedDataPipeProducerDispatcher);
287 288
288 if (!consumer_open()) { 289 if (!consumer_open()) {
289 // Case 1: The consumer is closed. 290 // Case 1: The consumer is closed.
290 s->consumer_num_bytes = static_cast<size_t>(-1); 291 s->consumer_num_bytes = static_cast<size_t>(-1);
291 *actual_size = sizeof(SerializedDataPipeProducerDispatcher); 292 *actual_size = sizeof(SerializedDataPipeProducerDispatcher);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 Channel* /*channel*/, 359 Channel* /*channel*/,
359 size_t* /*max_size*/, 360 size_t* /*max_size*/,
360 size_t* /*max_platform_handles*/) { 361 size_t* /*max_platform_handles*/) {
361 NOTREACHED(); 362 NOTREACHED();
362 } 363 }
363 364
364 bool RemoteConsumerDataPipeImpl::ConsumerEndSerialize( 365 bool RemoteConsumerDataPipeImpl::ConsumerEndSerialize(
365 Channel* /*channel*/, 366 Channel* /*channel*/,
366 void* /*destination*/, 367 void* /*destination*/,
367 size_t* /*actual_size*/, 368 size_t* /*actual_size*/,
368 embedder::PlatformHandleVector* /*platform_handles*/) { 369 std::vector<ScopedPlatformHandle>* /*platform_handles*/) {
369 NOTREACHED(); 370 NOTREACHED();
370 return false; 371 return false;
371 } 372 }
372 373
373 bool RemoteConsumerDataPipeImpl::OnReadMessage(unsigned /*port*/, 374 bool RemoteConsumerDataPipeImpl::OnReadMessage(unsigned /*port*/,
374 MessageInTransit* message) { 375 MessageInTransit* message) {
375 // Always take ownership of the message. (This means that we should always 376 // Always take ownership of the message. (This means that we should always
376 // return true.) 377 // return true.)
377 std::unique_ptr<MessageInTransit> msg(message); 378 std::unique_ptr<MessageInTransit> msg(message);
378 379
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 DCHECK(channel_endpoint_); 423 DCHECK(channel_endpoint_);
423 SetConsumerClosed(); 424 SetConsumerClosed();
424 channel_endpoint_->DetachFromClient(); 425 channel_endpoint_->DetachFromClient();
425 channel_endpoint_ = nullptr; 426 channel_endpoint_ = nullptr;
426 if (!producer_in_two_phase_write()) 427 if (!producer_in_two_phase_write())
427 DestroyBuffer(); 428 DestroyBuffer();
428 } 429 }
429 430
430 } // namespace system 431 } // namespace system
431 } // namespace mojo 432 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/remote_consumer_data_pipe_impl.h ('k') | mojo/edk/system/remote_producer_data_pipe_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698