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

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

Issue 1748503002: [mojo-edk] Add MojoWatch and MojoCancelWatch APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: there can be only one RequestContext! 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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return Type::MESSAGE_PIPE; 90 return Type::MESSAGE_PIPE;
91 } 91 }
92 92
93 MojoResult MessagePipeDispatcher::Close() { 93 MojoResult MessagePipeDispatcher::Close() {
94 base::AutoLock lock(signal_lock_); 94 base::AutoLock lock(signal_lock_);
95 DVLOG(1) << "Closing message pipe " << pipe_id_ << " endpoint " << endpoint_ 95 DVLOG(1) << "Closing message pipe " << pipe_id_ << " endpoint " << endpoint_
96 << " [port=" << port_.name() << "]"; 96 << " [port=" << port_.name() << "]";
97 return CloseNoLock(); 97 return CloseNoLock();
98 } 98 }
99 99
100 MojoResult MessagePipeDispatcher::Watch(MojoHandleSignals signals,
101 const Watcher::WatchCallback& callback,
102 uintptr_t context) {
103 base::AutoLock lock(signal_lock_);
104
105 if (port_closed_ || in_transit_)
106 return MOJO_RESULT_INVALID_ARGUMENT;
107
108 return awakables_.AddWatcher(
109 signals, callback, context, GetHandleSignalsStateNoLock());
110 }
111
112 MojoResult MessagePipeDispatcher::CancelWatch(uintptr_t context) {
113 base::AutoLock lock(signal_lock_);
114
115 if (port_closed_ || in_transit_)
116 return MOJO_RESULT_INVALID_ARGUMENT;
117
118 return awakables_.RemoveWatcher(context);
119 }
120
100 MojoResult MessagePipeDispatcher::WriteMessage( 121 MojoResult MessagePipeDispatcher::WriteMessage(
101 const void* bytes, 122 const void* bytes,
102 uint32_t num_bytes, 123 uint32_t num_bytes,
103 const DispatcherInTransit* dispatchers, 124 const DispatcherInTransit* dispatchers,
104 uint32_t num_dispatchers, 125 uint32_t num_dispatchers,
105 MojoWriteMessageFlags flags) { 126 MojoWriteMessageFlags flags) {
106 127
107 { 128 {
108 base::AutoLock lock(signal_lock_); 129 base::AutoLock lock(signal_lock_);
109 if (port_closed_ || in_transit_) 130 if (port_closed_ || in_transit_)
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_ 627 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_
607 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; 628 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]";
608 } 629 }
609 #endif 630 #endif
610 631
611 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); 632 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock());
612 } 633 }
613 634
614 } // namespace edk 635 } // namespace edk
615 } // namespace mojo 636 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698