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

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

Issue 2135113002: [mojo-edk] Close pending merges if the parent channel dies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert stuff for merge. Created 4 years, 5 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/edk/system/node_channel.h ('k') | mojo/edk/system/node_controller.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/node_channel.h" 5 #include "mojo/edk/system/node_channel.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (handles && !relay) { 496 if (handles && !relay) {
497 if (!MachPortRelay::ReceivePorts(handles.get())) { 497 if (!MachPortRelay::ReceivePorts(handles.get())) {
498 LOG(ERROR) << "Error receiving mach ports."; 498 LOG(ERROR) << "Error receiving mach ports.";
499 } 499 }
500 } 500 }
501 } 501 }
502 #endif // defined(OS_WIN) 502 #endif // defined(OS_WIN)
503 503
504 504
505 if (payload_size <= sizeof(Header)) { 505 if (payload_size <= sizeof(Header)) {
506 delegate_->OnChannelError(remote_node_name_); 506 delegate_->OnChannelError(remote_node_name_, this);
507 return; 507 return;
508 } 508 }
509 509
510 const Header* header = static_cast<const Header*>(payload); 510 const Header* header = static_cast<const Header*>(payload);
511 switch (header->type) { 511 switch (header->type) {
512 case MessageType::ACCEPT_CHILD: { 512 case MessageType::ACCEPT_CHILD: {
513 const AcceptChildData* data; 513 const AcceptChildData* data;
514 if (GetMessagePayload(payload, payload_size, &data)) { 514 if (GetMessagePayload(payload, payload_size, &data)) {
515 delegate_->OnAcceptChild(remote_node_name_, data->parent_name, 515 delegate_->OnAcceptChild(remote_node_name_, data->parent_name,
516 data->token); 516 data->token);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 726 }
727 break; 727 break;
728 728
729 #endif // defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) 729 #endif // defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
730 730
731 default: 731 default:
732 break; 732 break;
733 } 733 }
734 734
735 DLOG(ERROR) << "Received invalid message. Closing channel."; 735 DLOG(ERROR) << "Received invalid message. Closing channel.";
736 delegate_->OnChannelError(remote_node_name_); 736 delegate_->OnChannelError(remote_node_name_, this);
737 } 737 }
738 738
739 void NodeChannel::OnChannelError() { 739 void NodeChannel::OnChannelError() {
740 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 740 DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
741 741
742 RequestContext request_context(RequestContext::Source::SYSTEM); 742 RequestContext request_context(RequestContext::Source::SYSTEM);
743 743
744 ShutDown(); 744 ShutDown();
745 // |OnChannelError()| may cause |this| to be destroyed, but still need access 745 // |OnChannelError()| may cause |this| to be destroyed, but still need access
746 // to the name name after that destruction. So may a copy of 746 // to the name name after that destruction. So may a copy of
747 // |remote_node_name_| so it can be used if |this| becomes destroyed. 747 // |remote_node_name_| so it can be used if |this| becomes destroyed.
748 ports::NodeName node_name = remote_node_name_; 748 ports::NodeName node_name = remote_node_name_;
749 delegate_->OnChannelError(node_name); 749 delegate_->OnChannelError(node_name, this);
750 } 750 }
751 751
752 #if defined(OS_MACOSX) && !defined(OS_IOS) 752 #if defined(OS_MACOSX) && !defined(OS_IOS)
753 void NodeChannel::OnProcessReady(base::ProcessHandle process) { 753 void NodeChannel::OnProcessReady(base::ProcessHandle process) {
754 io_task_runner_->PostTask(FROM_HERE, base::Bind( 754 io_task_runner_->PostTask(FROM_HERE, base::Bind(
755 &NodeChannel::ProcessPendingMessagesWithMachPorts, this)); 755 &NodeChannel::ProcessPendingMessagesWithMachPorts, this));
756 } 756 }
757 757
758 void NodeChannel::ProcessPendingMessagesWithMachPorts() { 758 void NodeChannel::ProcessPendingMessagesWithMachPorts() {
759 MachPortRelay* relay = delegate_->GetMachPortRelay(); 759 MachPortRelay* relay = delegate_->GetMachPortRelay();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 base::AutoLock lock(channel_lock_); 868 base::AutoLock lock(channel_lock_);
869 if (!channel_) 869 if (!channel_)
870 DLOG(ERROR) << "Dropping message on closed channel."; 870 DLOG(ERROR) << "Dropping message on closed channel.";
871 else 871 else
872 channel_->Write(std::move(message)); 872 channel_->Write(std::move(message));
873 } 873 }
874 874
875 } // namespace edk 875 } // namespace edk
876 } // namespace mojo 876 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/node_channel.h ('k') | mojo/edk/system/node_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698