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

Side by Side Diff: mojo/edk/system/dispatcher.h

Issue 1478503003: EDK: Convert most uses of PlatformHandleVector to std::vector<ScopedPlatformHandle>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.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 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 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <ostream> 12 #include <ostream>
13 #include <vector> 13 #include <vector>
14 14
15 #include "mojo/edk/embedder/platform_handle_vector.h" 15 #include "mojo/edk/embedder/scoped_platform_handle.h"
16 #include "mojo/edk/system/handle_signals_state.h" 16 #include "mojo/edk/system/handle_signals_state.h"
17 #include "mojo/edk/system/memory.h" 17 #include "mojo/edk/system/memory.h"
18 #include "mojo/edk/util/mutex.h" 18 #include "mojo/edk/util/mutex.h"
19 #include "mojo/edk/util/ref_counted.h" 19 #include "mojo/edk/util/ref_counted.h"
20 #include "mojo/edk/util/ref_ptr.h" 20 #include "mojo/edk/util/ref_ptr.h"
21 #include "mojo/edk/util/thread_annotations.h" 21 #include "mojo/edk/util/thread_annotations.h"
22 #include "mojo/public/c/system/buffer.h" 22 #include "mojo/public/c/system/buffer.h"
23 #include "mojo/public/c/system/data_pipe.h" 23 #include "mojo/public/c/system/data_pipe.h"
24 #include "mojo/public/c/system/message_pipe.h" 24 #include "mojo/public/c/system/message_pipe.h"
25 #include "mojo/public/c/system/types.h" 25 #include "mojo/public/c/system/types.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // details. 193 // details.
194 static void StartSerialize(Dispatcher* dispatcher, 194 static void StartSerialize(Dispatcher* dispatcher,
195 Channel* channel, 195 Channel* channel,
196 size_t* max_size, 196 size_t* max_size,
197 size_t* max_platform_handles); 197 size_t* max_platform_handles);
198 static bool EndSerializeAndClose( 198 static bool EndSerializeAndClose(
199 Dispatcher* dispatcher, 199 Dispatcher* dispatcher,
200 Channel* channel, 200 Channel* channel,
201 void* destination, 201 void* destination,
202 size_t* actual_size, 202 size_t* actual_size,
203 embedder::PlatformHandleVector* platform_handles); 203 std::vector<embedder::ScopedPlatformHandle>* platform_handles);
204 204
205 // Deserialization API. 205 // Deserialization API.
206 // Note: This "clears" (i.e., reset to the invalid handle) any platform 206 // Note: This "clears" (i.e., reset to the invalid handle) any platform
207 // handles that it takes ownership of. 207 // handles that it takes ownership of.
208 static util::RefPtr<Dispatcher> Deserialize( 208 static util::RefPtr<Dispatcher> Deserialize(
209 Channel* channel, 209 Channel* channel,
210 int32_t type, 210 int32_t type,
211 const void* source, 211 const void* source,
212 size_t size, 212 size_t size,
213 embedder::PlatformHandleVector* platform_handles); 213 std::vector<embedder::ScopedPlatformHandle>* platform_handles);
214 }; 214 };
215 215
216 protected: 216 protected:
217 Dispatcher(); 217 Dispatcher();
218 virtual ~Dispatcher(); 218 virtual ~Dispatcher();
219 219
220 // These are to be overridden by subclasses (if necessary). They are called 220 // These are to be overridden by subclasses (if necessary). They are called
221 // exactly once (first |CancelAllAwakablesNoLock()|, then |CloseImplNoLock()|) 221 // exactly once (first |CancelAllAwakablesNoLock()|, then |CloseImplNoLock()|)
222 // when the dispatcher is being closed. 222 // when the dispatcher is being closed.
223 virtual void CancelAllAwakablesNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 223 virtual void CancelAllAwakablesNoLock() MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // TODO(vtl): Consider making these pure virtual once most things support 297 // TODO(vtl): Consider making these pure virtual once most things support
298 // being passed over a message pipe. 298 // being passed over a message pipe.
299 virtual void StartSerializeImplNoLock(Channel* channel, 299 virtual void StartSerializeImplNoLock(Channel* channel,
300 size_t* max_size, 300 size_t* max_size,
301 size_t* max_platform_handles) 301 size_t* max_platform_handles)
302 MOJO_NOT_THREAD_SAFE; 302 MOJO_NOT_THREAD_SAFE;
303 virtual bool EndSerializeAndCloseImplNoLock( 303 virtual bool EndSerializeAndCloseImplNoLock(
304 Channel* channel, 304 Channel* channel,
305 void* destination, 305 void* destination,
306 size_t* actual_size, 306 size_t* actual_size,
307 embedder::PlatformHandleVector* platform_handles) MOJO_NOT_THREAD_SAFE; 307 std::vector<embedder::ScopedPlatformHandle>* platform_handles)
308 MOJO_NOT_THREAD_SAFE;
308 309
309 // This should be overridden to return true if/when there's an ongoing 310 // This should be overridden to return true if/when there's an ongoing
310 // operation (e.g., two-phase read/writes on data pipes) that should prevent a 311 // operation (e.g., two-phase read/writes on data pipes) that should prevent a
311 // handle from being sent over a message pipe (with status "busy"). 312 // handle from being sent over a message pipe (with status "busy").
312 virtual bool IsBusyNoLock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_); 313 virtual bool IsBusyNoLock() const MOJO_SHARED_LOCKS_REQUIRED(mutex_);
313 314
314 util::Mutex& mutex() const MOJO_LOCK_RETURNED(mutex_) { return mutex_; } 315 util::Mutex& mutex() const MOJO_LOCK_RETURNED(mutex_) { return mutex_; }
315 316
316 private: 317 private:
317 FRIEND_REF_COUNTED_THREAD_SAFE(Dispatcher); 318 FRIEND_REF_COUNTED_THREAD_SAFE(Dispatcher);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // |platform_handles| (which may be null if no platform handles were indicated 365 // |platform_handles| (which may be null if no platform handles were indicated
365 // to be required to |StartSerialize()|). This may write no more than the 366 // to be required to |StartSerialize()|). This may write no more than the
366 // amount indicated by |StartSerialize()|. (WARNING: Beware of races, e.g., if 367 // amount indicated by |StartSerialize()|. (WARNING: Beware of races, e.g., if
367 // something can be mutated between the two calls!) Returns true on success, 368 // something can be mutated between the two calls!) Returns true on success,
368 // in which case |*actual_size| is set to the amount it actually wrote to 369 // in which case |*actual_size| is set to the amount it actually wrote to
369 // |destination|. On failure, |*actual_size| should not be modified; however, 370 // |destination|. On failure, |*actual_size| should not be modified; however,
370 // the dispatcher will still be closed. 371 // the dispatcher will still be closed.
371 bool EndSerializeAndClose(Channel* channel, 372 bool EndSerializeAndClose(Channel* channel,
372 void* destination, 373 void* destination,
373 size_t* actual_size, 374 size_t* actual_size,
374 embedder::PlatformHandleVector* platform_handles) 375 std::vector<embedder::ScopedPlatformHandle>*
375 MOJO_NOT_THREAD_SAFE; 376 platform_handles) MOJO_NOT_THREAD_SAFE;
376 377
377 // This protects the following members as well as any state added by 378 // This protects the following members as well as any state added by
378 // subclasses. 379 // subclasses.
379 mutable util::Mutex mutex_; 380 mutable util::Mutex mutex_;
380 bool is_closed_ MOJO_GUARDED_BY(mutex_); 381 bool is_closed_ MOJO_GUARDED_BY(mutex_);
381 382
382 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher); 383 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher);
383 }; 384 };
384 385
385 // Wrapper around a |Dispatcher| pointer, while it's being processed to be 386 // Wrapper around a |Dispatcher| pointer, while it's being processed to be
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 423
423 // So logging macros and |DCHECK_EQ()|, etc. work. 424 // So logging macros and |DCHECK_EQ()|, etc. work.
424 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { 425 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) {
425 return out << static_cast<int>(type); 426 return out << static_cast<int>(type);
426 } 427 }
427 428
428 } // namespace system 429 } // namespace system
429 } // namespace mojo 430 } // namespace mojo
430 431
431 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ 432 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698