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

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

Issue 2888053002: Rename TaskRunner::RunsTasksOnCurrentThread() in //extensions, //headless, //mojo (Closed)
Patch Set: rebase Created 3 years, 7 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/channel_win.cc ('k') | mojo/edk/system/node_controller.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 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 channel_->LeakHandle(); 215 channel_->LeakHandle();
216 } 216 }
217 } 217 }
218 218
219 void NodeChannel::NotifyBadMessage(const std::string& error) { 219 void NodeChannel::NotifyBadMessage(const std::string& error) {
220 if (!process_error_callback_.is_null()) 220 if (!process_error_callback_.is_null())
221 process_error_callback_.Run("Received bad user message: " + error); 221 process_error_callback_.Run("Received bad user message: " + error);
222 } 222 }
223 223
224 void NodeChannel::SetRemoteProcessHandle(base::ProcessHandle process_handle) { 224 void NodeChannel::SetRemoteProcessHandle(base::ProcessHandle process_handle) {
225 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 225 DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
226 base::AutoLock lock(remote_process_handle_lock_); 226 base::AutoLock lock(remote_process_handle_lock_);
227 DCHECK_EQ(base::kNullProcessHandle, remote_process_handle_); 227 DCHECK_EQ(base::kNullProcessHandle, remote_process_handle_);
228 CHECK_NE(remote_process_handle_, base::GetCurrentProcessHandle()); 228 CHECK_NE(remote_process_handle_, base::GetCurrentProcessHandle());
229 remote_process_handle_ = process_handle; 229 remote_process_handle_ = process_handle;
230 #if defined(OS_WIN) 230 #if defined(OS_WIN)
231 DCHECK(!scoped_remote_process_handle_.is_valid()); 231 DCHECK(!scoped_remote_process_handle_.is_valid());
232 scoped_remote_process_handle_.reset(PlatformHandle(process_handle)); 232 scoped_remote_process_handle_.reset(PlatformHandle(process_handle));
233 #endif 233 #endif
234 } 234 }
235 235
(...skipping 16 matching lines...) Expand all
252 DPCHECK(result); 252 DPCHECK(result);
253 return handle; 253 return handle;
254 } 254 }
255 return base::kNullProcessHandle; 255 return base::kNullProcessHandle;
256 #else 256 #else
257 return remote_process_handle_; 257 return remote_process_handle_;
258 #endif 258 #endif
259 } 259 }
260 260
261 void NodeChannel::SetRemoteNodeName(const ports::NodeName& name) { 261 void NodeChannel::SetRemoteNodeName(const ports::NodeName& name) {
262 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 262 DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
263 remote_node_name_ = name; 263 remote_node_name_ = name;
264 } 264 }
265 265
266 void NodeChannel::AcceptChild(const ports::NodeName& parent_name, 266 void NodeChannel::AcceptChild(const ports::NodeName& parent_name,
267 const ports::NodeName& token) { 267 const ports::NodeName& token) {
268 AcceptChildData* data; 268 AcceptChildData* data;
269 Channel::MessagePtr message = CreateMessage( 269 Channel::MessagePtr message = CreateMessage(
270 MessageType::ACCEPT_CHILD, sizeof(AcceptChildData), 0, &data); 270 MessageType::ACCEPT_CHILD, sizeof(AcceptChildData), 0, &data);
271 data->parent_name = parent_name; 271 data->parent_name = parent_name;
272 data->token = token; 272 data->token = token;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 { 462 {
463 } 463 }
464 464
465 NodeChannel::~NodeChannel() { 465 NodeChannel::~NodeChannel() {
466 ShutDown(); 466 ShutDown();
467 } 467 }
468 468
469 void NodeChannel::OnChannelMessage(const void* payload, 469 void NodeChannel::OnChannelMessage(const void* payload,
470 size_t payload_size, 470 size_t payload_size,
471 ScopedPlatformHandleVectorPtr handles) { 471 ScopedPlatformHandleVectorPtr handles) {
472 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 472 DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
473 473
474 RequestContext request_context(RequestContext::Source::SYSTEM); 474 RequestContext request_context(RequestContext::Source::SYSTEM);
475 475
476 // Ensure this NodeChannel stays alive through the extent of this method. The 476 // Ensure this NodeChannel stays alive through the extent of this method. The
477 // delegate may have the only other reference to this object and it may choose 477 // delegate may have the only other reference to this object and it may choose
478 // to drop it here in response to, e.g., a malformed message. 478 // to drop it here in response to, e.g., a malformed message.
479 scoped_refptr<NodeChannel> keepalive = this; 479 scoped_refptr<NodeChannel> keepalive = this;
480 480
481 #if defined(OS_WIN) 481 #if defined(OS_WIN)
482 // If we receive handles from a known process, rewrite them to our own 482 // If we receive handles from a known process, rewrite them to our own
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 default: 755 default:
756 break; 756 break;
757 } 757 }
758 758
759 DLOG(ERROR) << "Received invalid message. Closing channel."; 759 DLOG(ERROR) << "Received invalid message. Closing channel.";
760 delegate_->OnChannelError(remote_node_name_, this); 760 delegate_->OnChannelError(remote_node_name_, this);
761 } 761 }
762 762
763 void NodeChannel::OnChannelError() { 763 void NodeChannel::OnChannelError() {
764 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); 764 DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
765 765
766 RequestContext request_context(RequestContext::Source::SYSTEM); 766 RequestContext request_context(RequestContext::Source::SYSTEM);
767 767
768 ShutDown(); 768 ShutDown();
769 // |OnChannelError()| may cause |this| to be destroyed, but still need access 769 // |OnChannelError()| may cause |this| to be destroyed, but still need access
770 // to the name name after that destruction. So may a copy of 770 // to the name name after that destruction. So may a copy of
771 // |remote_node_name_| so it can be used if |this| becomes destroyed. 771 // |remote_node_name_| so it can be used if |this| becomes destroyed.
772 ports::NodeName node_name = remote_node_name_; 772 ports::NodeName node_name = remote_node_name_;
773 delegate_->OnChannelError(node_name, this); 773 delegate_->OnChannelError(node_name, this);
774 } 774 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 base::AutoLock lock(channel_lock_); 891 base::AutoLock lock(channel_lock_);
892 if (!channel_) 892 if (!channel_)
893 DLOG(ERROR) << "Dropping message on closed channel."; 893 DLOG(ERROR) << "Dropping message on closed channel.";
894 else 894 else
895 channel_->Write(std::move(message)); 895 channel_->Write(std::move(message));
896 } 896 }
897 897
898 } // namespace edk 898 } // namespace edk
899 } // namespace mojo 899 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_win.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698