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

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

Issue 976013002: Miscellaneous fixes for MSVC. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: TODO Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/binding.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_producer_data_pipe_impl.h" 5 #include "mojo/edk/system/remote_producer_data_pipe_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 start_index_ += num_bytes; 437 start_index_ += num_bytes;
438 start_index_ %= capacity_num_bytes(); 438 start_index_ %= capacity_num_bytes();
439 current_num_bytes_ -= num_bytes; 439 current_num_bytes_ -= num_bytes;
440 440
441 if (!producer_open()) { 441 if (!producer_open()) {
442 DCHECK(!channel_endpoint_); 442 DCHECK(!channel_endpoint_);
443 return; 443 return;
444 } 444 }
445 445
446 RemoteDataPipeAck ack_data = {}; 446 RemoteDataPipeAck ack_data = {};
447 ack_data.num_bytes_consumed = num_bytes; 447 ack_data.num_bytes_consumed = static_cast<uint32_t>(num_bytes);
448 scoped_ptr<MessageInTransit> message( 448 scoped_ptr<MessageInTransit> message(
449 new MessageInTransit(MessageInTransit::kTypeEndpoint, 449 new MessageInTransit(MessageInTransit::kTypeEndpoint,
450 MessageInTransit::kSubtypeEndpointDataPipeAck, 450 MessageInTransit::kSubtypeEndpointDataPipeAck,
451 static_cast<uint32_t>(sizeof(ack_data)), &ack_data)); 451 static_cast<uint32_t>(sizeof(ack_data)), &ack_data));
452 if (!channel_endpoint_->EnqueueMessage(message.Pass())) 452 if (!channel_endpoint_->EnqueueMessage(message.Pass()))
453 Disconnect(); 453 Disconnect();
454 } 454 }
455 455
456 void RemoteProducerDataPipeImpl::Disconnect() { 456 void RemoteProducerDataPipeImpl::Disconnect() {
457 DCHECK(producer_open()); 457 DCHECK(producer_open());
458 DCHECK(channel_endpoint_); 458 DCHECK(channel_endpoint_);
459 owner()->SetProducerClosedNoLock(); 459 owner()->SetProducerClosedNoLock();
460 channel_endpoint_->DetachFromClient(); 460 channel_endpoint_->DetachFromClient();
461 channel_endpoint_ = nullptr; 461 channel_endpoint_ = nullptr;
462 // If the consumer is still open and we still have data, we have to keep the 462 // If the consumer is still open and we still have data, we have to keep the
463 // buffer around. Currently, we won't free it even if it empties later. (We 463 // buffer around. Currently, we won't free it even if it empties later. (We
464 // could do this -- requiring a check on every read -- but that seems to be 464 // could do this -- requiring a check on every read -- but that seems to be
465 // optimizing for the uncommon case.) 465 // optimizing for the uncommon case.)
466 if (!consumer_open() || !current_num_bytes_) { 466 if (!consumer_open() || !current_num_bytes_) {
467 // Note: There can only be a two-phase *read* (by the consumer) if we still 467 // Note: There can only be a two-phase *read* (by the consumer) if we still
468 // have data. 468 // have data.
469 DCHECK(!consumer_in_two_phase_read()); 469 DCHECK(!consumer_in_two_phase_read());
470 DestroyBuffer(); 470 DestroyBuffer();
471 } 471 }
472 } 472 }
473 473
474 } // namespace system 474 } // namespace system
475 } // namespace mojo 475 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698