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

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

Issue 1785843002: [mojo] Implement pipe fusion API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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 | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/message_pipe_unittest.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 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/message_pipe_dispatcher.h" 5 #include "mojo/edk/system/message_pipe_dispatcher.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 pipe_id_(pipe_id), 92 pipe_id_(pipe_id),
93 endpoint_(endpoint) { 93 endpoint_(endpoint) {
94 DVLOG(2) << "Creating new MessagePipeDispatcher for port " << port.name() 94 DVLOG(2) << "Creating new MessagePipeDispatcher for port " << port.name()
95 << " [pipe_id=" << pipe_id << "; endpoint=" << endpoint << "]"; 95 << " [pipe_id=" << pipe_id << "; endpoint=" << endpoint << "]";
96 96
97 node_controller_->SetPortObserver( 97 node_controller_->SetPortObserver(
98 port_, 98 port_,
99 make_scoped_refptr(new PortObserverThunk(this))); 99 make_scoped_refptr(new PortObserverThunk(this)));
100 } 100 }
101 101
102 bool MessagePipeDispatcher::Fuse(MessagePipeDispatcher* other) {
103 node_controller_->SetPortObserver(port_, nullptr);
104 node_controller_->SetPortObserver(other->port_, nullptr);
105
106 ports::PortRef port0;
107 {
108 base::AutoLock lock(signal_lock_);
109 port0 = port_;
110 port_closed_ = true;
111 awakables_.CancelAll();
112 }
113
114 ports::PortRef port1;
115 {
116 base::AutoLock lock(other->signal_lock_);
117 port1 = other->port_;
118 other->port_closed_ = true;
119 other->awakables_.CancelAll();
120 }
121
122 // Both ports are always closed by this call.
123 int rv = node_controller_->MergeLocalPorts(port0, port1);
124 return rv == ports::OK;
125 }
126
102 Dispatcher::Type MessagePipeDispatcher::GetType() const { 127 Dispatcher::Type MessagePipeDispatcher::GetType() const {
103 return Type::MESSAGE_PIPE; 128 return Type::MESSAGE_PIPE;
104 } 129 }
105 130
106 MojoResult MessagePipeDispatcher::Close() { 131 MojoResult MessagePipeDispatcher::Close() {
107 base::AutoLock lock(signal_lock_); 132 base::AutoLock lock(signal_lock_);
108 DVLOG(1) << "Closing message pipe " << pipe_id_ << " endpoint " << endpoint_ 133 DVLOG(1) << "Closing message pipe " << pipe_id_ << " endpoint " << endpoint_
109 << " [port=" << port_.name() << "]"; 134 << " [port=" << port_.name() << "]";
110 return CloseNoLock(); 135 return CloseNoLock();
111 } 136 }
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_ 668 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_
644 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; 669 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]";
645 } 670 }
646 #endif 671 #endif
647 672
648 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); 673 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock());
649 } 674 }
650 675
651 } // namespace edk 676 } // namespace edk
652 } // namespace mojo 677 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.h ('k') | mojo/edk/system/message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698