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

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

Issue 779503003: Extract Awakable from Waiter (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Review Update Created 6 years 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 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/edk/system/message_pipe.h" 5 #include "mojo/edk/system/message_pipe.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/channel.h" 8 #include "mojo/edk/system/channel.h"
9 #include "mojo/edk/system/channel_endpoint.h" 9 #include "mojo/edk/system/channel_endpoint.h"
10 #include "mojo/edk/system/channel_endpoint_id.h" 10 #include "mojo/edk/system/channel_endpoint_id.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 MessagePipeEndpoint::Type MessagePipe::GetType(unsigned port) { 99 MessagePipeEndpoint::Type MessagePipe::GetType(unsigned port) {
100 DCHECK(port == 0 || port == 1); 100 DCHECK(port == 0 || port == 1);
101 base::AutoLock locker(lock_); 101 base::AutoLock locker(lock_);
102 DCHECK(endpoints_[port]); 102 DCHECK(endpoints_[port]);
103 103
104 return endpoints_[port]->GetType(); 104 return endpoints_[port]->GetType();
105 } 105 }
106 106
107 void MessagePipe::CancelAllWaiters(unsigned port) { 107 void MessagePipe::CancelAllAwakables(unsigned port) {
108 DCHECK(port == 0 || port == 1); 108 DCHECK(port == 0 || port == 1);
109 109
110 base::AutoLock locker(lock_); 110 base::AutoLock locker(lock_);
111 DCHECK(endpoints_[port]); 111 DCHECK(endpoints_[port]);
112 endpoints_[port]->CancelAllWaiters(); 112 endpoints_[port]->CancelAllAwakables();
113 } 113 }
114 114
115 void MessagePipe::Close(unsigned port) { 115 void MessagePipe::Close(unsigned port) {
116 DCHECK(port == 0 || port == 1); 116 DCHECK(port == 0 || port == 1);
117 117
118 unsigned destination_port = GetPeerPort(port); 118 unsigned destination_port = GetPeerPort(port);
119 119
120 base::AutoLock locker(lock_); 120 base::AutoLock locker(lock_);
121 // The endpoint's |OnPeerClose()| may have been called first and returned 121 // The endpoint's |OnPeerClose()| may have been called first and returned
122 // false, which would have resulted in its destruction. 122 // false, which would have resulted in its destruction.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 HandleSignalsState MessagePipe::GetHandleSignalsState(unsigned port) const { 165 HandleSignalsState MessagePipe::GetHandleSignalsState(unsigned port) const {
166 DCHECK(port == 0 || port == 1); 166 DCHECK(port == 0 || port == 1);
167 167
168 base::AutoLock locker(const_cast<base::Lock&>(lock_)); 168 base::AutoLock locker(const_cast<base::Lock&>(lock_));
169 DCHECK(endpoints_[port]); 169 DCHECK(endpoints_[port]);
170 170
171 return endpoints_[port]->GetHandleSignalsState(); 171 return endpoints_[port]->GetHandleSignalsState();
172 } 172 }
173 173
174 MojoResult MessagePipe::AddWaiter(unsigned port, 174 MojoResult MessagePipe::AddAwakable(unsigned port,
175 Waiter* waiter, 175 Awakable* awakable,
176 MojoHandleSignals signals, 176 MojoHandleSignals signals,
177 uint32_t context, 177 uint32_t context,
178 HandleSignalsState* signals_state) { 178 HandleSignalsState* signals_state) {
179 DCHECK(port == 0 || port == 1); 179 DCHECK(port == 0 || port == 1);
180 180
181 base::AutoLock locker(lock_); 181 base::AutoLock locker(lock_);
182 DCHECK(endpoints_[port]); 182 DCHECK(endpoints_[port]);
183 183
184 return endpoints_[port]->AddWaiter(waiter, signals, context, signals_state); 184 return endpoints_[port]->AddAwakable(awakable, signals, context,
185 signals_state);
185 } 186 }
186 187
187 void MessagePipe::RemoveWaiter(unsigned port, 188 void MessagePipe::RemoveAwakable(unsigned port,
188 Waiter* waiter, 189 Awakable* awakable,
189 HandleSignalsState* signals_state) { 190 HandleSignalsState* signals_state) {
190 DCHECK(port == 0 || port == 1); 191 DCHECK(port == 0 || port == 1);
191 192
192 base::AutoLock locker(lock_); 193 base::AutoLock locker(lock_);
193 DCHECK(endpoints_[port]); 194 DCHECK(endpoints_[port]);
194 195
195 endpoints_[port]->RemoveWaiter(waiter, signals_state); 196 endpoints_[port]->RemoveAwakable(awakable, signals_state);
196 } 197 }
197 198
198 void MessagePipe::StartSerialize(unsigned /*port*/, 199 void MessagePipe::StartSerialize(unsigned /*port*/,
199 Channel* /*channel*/, 200 Channel* /*channel*/,
200 size_t* max_size, 201 size_t* max_size,
201 size_t* max_platform_handles) { 202 size_t* max_platform_handles) {
202 *max_size = sizeof(SerializedMessagePipe); 203 *max_size = sizeof(SerializedMessagePipe);
203 *max_platform_handles = 0; 204 *max_platform_handles = 0;
204 } 205 }
205 206
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 LOG(WARNING) << "Enqueueing null dispatcher"; 381 LOG(WARNING) << "Enqueueing null dispatcher";
381 dispatchers->push_back(nullptr); 382 dispatchers->push_back(nullptr);
382 } 383 }
383 } 384 }
384 message->SetDispatchers(dispatchers.Pass()); 385 message->SetDispatchers(dispatchers.Pass());
385 return MOJO_RESULT_OK; 386 return MOJO_RESULT_OK;
386 } 387 }
387 388
388 } // namespace system 389 } // namespace system
389 } // namespace mojo 390 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698