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

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

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| 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_dispatcher.h" 5 #include "mojo/edk/system/message_pipe_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/configuration.h" 8 #include "mojo/edk/system/configuration.h"
9 #include "mojo/edk/system/local_message_pipe_endpoint.h" 9 #include "mojo/edk/system/local_message_pipe_endpoint.h"
10 #include "mojo/edk/system/memory.h" 10 #include "mojo/edk/system/memory.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Checks for fields beyond |flags|: 54 // Checks for fields beyond |flags|:
55 55
56 // (Nothing here yet.) 56 // (Nothing here yet.)
57 57
58 return MOJO_RESULT_OK; 58 return MOJO_RESULT_OK;
59 } 59 }
60 60
61 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe, 61 void MessagePipeDispatcher::Init(scoped_refptr<MessagePipe> message_pipe,
62 unsigned port) { 62 unsigned port) {
63 DCHECK(message_pipe.get()); 63 DCHECK(message_pipe);
64 DCHECK(port == 0 || port == 1); 64 DCHECK(port == 0 || port == 1);
65 65
66 message_pipe_ = message_pipe; 66 message_pipe_ = message_pipe;
67 port_ = port; 67 port_ = port;
68 } 68 }
69 69
70 Dispatcher::Type MessagePipeDispatcher::GetType() const { 70 Dispatcher::Type MessagePipeDispatcher::GetType() const {
71 return kTypeMessagePipe; 71 return kTypeMessagePipe;
72 } 72 }
73 73
(...skipping 11 matching lines...) Expand all
85 85
86 // static 86 // static
87 scoped_refptr<MessagePipeDispatcher> MessagePipeDispatcher::Deserialize( 87 scoped_refptr<MessagePipeDispatcher> MessagePipeDispatcher::Deserialize(
88 Channel* channel, 88 Channel* channel,
89 const void* source, 89 const void* source,
90 size_t size) { 90 size_t size) {
91 unsigned port = kInvalidPort; 91 unsigned port = kInvalidPort;
92 scoped_refptr<MessagePipe> message_pipe; 92 scoped_refptr<MessagePipe> message_pipe;
93 if (!MessagePipe::Deserialize(channel, source, size, &message_pipe, &port)) 93 if (!MessagePipe::Deserialize(channel, source, size, &message_pipe, &port))
94 return nullptr; 94 return nullptr;
95 DCHECK(message_pipe.get()); 95 DCHECK(message_pipe);
96 DCHECK(port == 0 || port == 1); 96 DCHECK(port == 0 || port == 1);
97 97
98 scoped_refptr<MessagePipeDispatcher> dispatcher( 98 scoped_refptr<MessagePipeDispatcher> dispatcher(
99 new MessagePipeDispatcher(MessagePipeDispatcher::kDefaultCreateOptions)); 99 new MessagePipeDispatcher(MessagePipeDispatcher::kDefaultCreateOptions));
100 dispatcher->Init(message_pipe, port); 100 dispatcher->Init(message_pipe, port);
101 return dispatcher; 101 return dispatcher;
102 } 102 }
103 103
104 MessagePipeDispatcher::~MessagePipeDispatcher() { 104 MessagePipeDispatcher::~MessagePipeDispatcher() {
105 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe. 105 // |Close()|/|CloseImplNoLock()| should have taken care of the pipe.
106 DCHECK(!message_pipe_.get()); 106 DCHECK(!message_pipe_);
107 } 107 }
108 108
109 MessagePipe* MessagePipeDispatcher::GetMessagePipeNoLock() const { 109 MessagePipe* MessagePipeDispatcher::GetMessagePipeNoLock() const {
110 lock().AssertAcquired(); 110 lock().AssertAcquired();
111 return message_pipe_.get(); 111 return message_pipe_.get();
112 } 112 }
113 113
114 unsigned MessagePipeDispatcher::GetPortNoLock() const { 114 unsigned MessagePipeDispatcher::GetPortNoLock() const {
115 lock().AssertAcquired(); 115 lock().AssertAcquired();
116 return port_; 116 return port_;
117 } 117 }
118 118
119 void MessagePipeDispatcher::CancelAllWaitersNoLock() { 119 void MessagePipeDispatcher::CancelAllAwakablesNoLock() {
120 lock().AssertAcquired(); 120 lock().AssertAcquired();
121 message_pipe_->CancelAllWaiters(port_); 121 message_pipe_->CancelAllAwakables(port_);
122 } 122 }
123 123
124 void MessagePipeDispatcher::CloseImplNoLock() { 124 void MessagePipeDispatcher::CloseImplNoLock() {
125 lock().AssertAcquired(); 125 lock().AssertAcquired();
126 message_pipe_->Close(port_); 126 message_pipe_->Close(port_);
127 message_pipe_ = nullptr; 127 message_pipe_ = nullptr;
128 port_ = kInvalidPort; 128 port_ = kInvalidPort;
129 } 129 }
130 130
131 scoped_refptr<Dispatcher> 131 scoped_refptr<Dispatcher>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers, 171 return message_pipe_->ReadMessage(port_, bytes, num_bytes, dispatchers,
172 num_dispatchers, flags); 172 num_dispatchers, flags);
173 } 173 }
174 174
175 HandleSignalsState MessagePipeDispatcher::GetHandleSignalsStateImplNoLock() 175 HandleSignalsState MessagePipeDispatcher::GetHandleSignalsStateImplNoLock()
176 const { 176 const {
177 lock().AssertAcquired(); 177 lock().AssertAcquired();
178 return message_pipe_->GetHandleSignalsState(port_); 178 return message_pipe_->GetHandleSignalsState(port_);
179 } 179 }
180 180
181 MojoResult MessagePipeDispatcher::AddWaiterImplNoLock( 181 MojoResult MessagePipeDispatcher::AddAwakableImplNoLock(
182 Waiter* waiter, 182 Awakable* awakable,
183 MojoHandleSignals signals, 183 MojoHandleSignals signals,
184 uint32_t context, 184 uint32_t context,
185 HandleSignalsState* signals_state) { 185 HandleSignalsState* signals_state) {
186 lock().AssertAcquired(); 186 lock().AssertAcquired();
187 return message_pipe_->AddWaiter(port_, waiter, signals, context, 187 return message_pipe_->AddAwakable(port_, awakable, signals, context,
188 signals_state); 188 signals_state);
189 } 189 }
190 190
191 void MessagePipeDispatcher::RemoveWaiterImplNoLock( 191 void MessagePipeDispatcher::RemoveAwakableImplNoLock(
192 Waiter* waiter, 192 Awakable* awakable,
193 HandleSignalsState* signals_state) { 193 HandleSignalsState* signals_state) {
194 lock().AssertAcquired(); 194 lock().AssertAcquired();
195 message_pipe_->RemoveWaiter(port_, waiter, signals_state); 195 message_pipe_->RemoveAwakable(port_, awakable, signals_state);
196 } 196 }
197 197
198 void MessagePipeDispatcher::StartSerializeImplNoLock( 198 void MessagePipeDispatcher::StartSerializeImplNoLock(
199 Channel* channel, 199 Channel* channel,
200 size_t* max_size, 200 size_t* max_size,
201 size_t* max_platform_handles) { 201 size_t* max_platform_handles) {
202 DCHECK(HasOneRef()); // Only one ref => no need to take the lock. 202 DCHECK(HasOneRef()); // Only one ref => no need to take the lock.
203 return message_pipe_->StartSerialize(port_, channel, max_size, 203 return message_pipe_->StartSerialize(port_, channel, max_size,
204 max_platform_handles); 204 max_platform_handles);
205 } 205 }
(...skipping 15 matching lines...) Expand all
221 // MessagePipeDispatcherTransport ---------------------------------------------- 221 // MessagePipeDispatcherTransport ----------------------------------------------
222 222
223 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( 223 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport(
224 DispatcherTransport transport) 224 DispatcherTransport transport)
225 : DispatcherTransport(transport) { 225 : DispatcherTransport(transport) {
226 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); 226 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe);
227 } 227 }
228 228
229 } // namespace system 229 } // namespace system
230 } // namespace mojo 230 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698