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

Side by Side Diff: mojo/system/channel.cc

Issue 597413002: Mojo: NULL -> nullptr in mojo/system and mojo/embedder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPECT_TRUE Created 6 years, 3 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 | « mojo/embedder/test_embedder.cc ('k') | mojo/system/channel_endpoint.cc » ('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 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/system/channel.h" 5 #include "mojo/system/channel.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 base::AutoLock locker_(lock_); 239 base::AutoLock locker_(lock_);
240 if (!is_running_) 240 if (!is_running_)
241 return; 241 return;
242 242
243 IdToEndpointMap::iterator it = local_id_to_endpoint_map_.find(local_id); 243 IdToEndpointMap::iterator it = local_id_to_endpoint_map_.find(local_id);
244 DCHECK(it != local_id_to_endpoint_map_.end()); 244 DCHECK(it != local_id_to_endpoint_map_.end());
245 245
246 switch (it->second->state_) { 246 switch (it->second->state_) {
247 case ChannelEndpoint::STATE_NORMAL: 247 case ChannelEndpoint::STATE_NORMAL:
248 it->second->state_ = ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK; 248 it->second->state_ = ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK;
249 it->second->message_pipe_ = NULL; 249 it->second->message_pipe_ = nullptr;
250 if (remote_id == MessageInTransit::kInvalidEndpointId) 250 if (remote_id == MessageInTransit::kInvalidEndpointId)
251 return; 251 return;
252 // We have to send a remove message (outside the lock). 252 // We have to send a remove message (outside the lock).
253 break; 253 break;
254 case ChannelEndpoint::STATE_WAIT_LOCAL_DETACH: 254 case ChannelEndpoint::STATE_WAIT_LOCAL_DETACH:
255 endpoint_to_detach = it->second; 255 endpoint_to_detach = it->second;
256 local_id_to_endpoint_map_.erase(it); 256 local_id_to_endpoint_map_.erase(it);
257 // We have to detach (outside the lock). 257 // We have to detach (outside the lock).
258 break; 258 break;
259 case ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK: 259 case ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK:
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (it == local_id_to_endpoint_map_.end()) { 488 if (it == local_id_to_endpoint_map_.end()) {
489 DVLOG(2) << "Remove message pipe error: not found"; 489 DVLOG(2) << "Remove message pipe error: not found";
490 return false; 490 return false;
491 } 491 }
492 492
493 switch (it->second->state_) { 493 switch (it->second->state_) {
494 case ChannelEndpoint::STATE_NORMAL: 494 case ChannelEndpoint::STATE_NORMAL:
495 it->second->state_ = ChannelEndpoint::STATE_WAIT_LOCAL_DETACH; 495 it->second->state_ = ChannelEndpoint::STATE_WAIT_LOCAL_DETACH;
496 message_pipe = it->second->message_pipe_; 496 message_pipe = it->second->message_pipe_;
497 port = it->second->port_; 497 port = it->second->port_;
498 it->second->message_pipe_ = NULL; 498 it->second->message_pipe_ = nullptr;
499 // We have to send a remove ack message (outside the lock). 499 // We have to send a remove ack message (outside the lock).
500 break; 500 break;
501 case ChannelEndpoint::STATE_WAIT_LOCAL_DETACH: 501 case ChannelEndpoint::STATE_WAIT_LOCAL_DETACH:
502 DVLOG(2) << "Remove message pipe error: wrong state"; 502 DVLOG(2) << "Remove message pipe error: wrong state";
503 return false; 503 return false;
504 case ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK: 504 case ChannelEndpoint::STATE_WAIT_REMOTE_REMOVE_ACK:
505 endpoint_to_detach = it->second; 505 endpoint_to_detach = it->second;
506 local_id_to_endpoint_map_.erase(it); 506 local_id_to_endpoint_map_.erase(it);
507 // We have to detach (outside the lock). 507 // We have to detach (outside the lock).
508 break; 508 break;
(...skipping 18 matching lines...) Expand all
527 message_pipe->OnRemove(port); 527 message_pipe->OnRemove(port);
528 528
529 return true; 529 return true;
530 } 530 }
531 531
532 bool Channel::SendControlMessage(MessageInTransit::Subtype subtype, 532 bool Channel::SendControlMessage(MessageInTransit::Subtype subtype,
533 MessageInTransit::EndpointId local_id, 533 MessageInTransit::EndpointId local_id,
534 MessageInTransit::EndpointId remote_id) { 534 MessageInTransit::EndpointId remote_id) {
535 DVLOG(2) << "Sending channel control message: subtype " << subtype 535 DVLOG(2) << "Sending channel control message: subtype " << subtype
536 << ", local ID " << local_id << ", remote ID " << remote_id; 536 << ", local ID " << local_id << ", remote ID " << remote_id;
537 scoped_ptr<MessageInTransit> message( 537 scoped_ptr<MessageInTransit> message(new MessageInTransit(
538 new MessageInTransit(MessageInTransit::kTypeChannel, subtype, 0, NULL)); 538 MessageInTransit::kTypeChannel, subtype, 0, nullptr));
539 message->set_source_id(local_id); 539 message->set_source_id(local_id);
540 message->set_destination_id(remote_id); 540 message->set_destination_id(remote_id);
541 return WriteMessage(message.Pass()); 541 return WriteMessage(message.Pass());
542 } 542 }
543 543
544 void Channel::HandleRemoteError(const base::StringPiece& error_message) { 544 void Channel::HandleRemoteError(const base::StringPiece& error_message) {
545 // TODO(vtl): Is this how we really want to handle this? Probably we want to 545 // TODO(vtl): Is this how we really want to handle this? Probably we want to
546 // terminate the connection, since it's spewing invalid stuff. 546 // terminate the connection, since it's spewing invalid stuff.
547 LOG(WARNING) << error_message; 547 LOG(WARNING) << error_message;
548 } 548 }
549 549
550 void Channel::HandleLocalError(const base::StringPiece& error_message) { 550 void Channel::HandleLocalError(const base::StringPiece& error_message) {
551 // TODO(vtl): Is this how we really want to handle this? 551 // TODO(vtl): Is this how we really want to handle this?
552 // Sometimes we'll want to propagate the error back to the message pipe 552 // Sometimes we'll want to propagate the error back to the message pipe
553 // (endpoint), and notify it that the remote is (effectively) closed. 553 // (endpoint), and notify it that the remote is (effectively) closed.
554 // Sometimes we'll want to kill the channel (and notify all the endpoints that 554 // Sometimes we'll want to kill the channel (and notify all the endpoints that
555 // their remotes are dead. 555 // their remotes are dead.
556 LOG(WARNING) << error_message; 556 LOG(WARNING) << error_message;
557 } 557 }
558 558
559 } // namespace system 559 } // namespace system
560 } // namespace mojo 560 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/embedder/test_embedder.cc ('k') | mojo/system/channel_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698