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

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

Issue 1942423002: EDK: Move DispatcherTransport to handle_transport.*. (Closed) Base URL: https://github.com/domokit/mojo.git@work789_edk_handle_9
Patch Set: rebased Created 4 years, 7 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/data_pipe_impl_unittest.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
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 platform_handles) MOJO_NOT_THREAD_SAFE; 437 platform_handles) MOJO_NOT_THREAD_SAFE;
438 438
439 // This protects the following members as well as any state added by 439 // This protects the following members as well as any state added by
440 // subclasses. 440 // subclasses.
441 mutable util::Mutex mutex_; 441 mutable util::Mutex mutex_;
442 bool is_closed_ MOJO_GUARDED_BY(mutex_); 442 bool is_closed_ MOJO_GUARDED_BY(mutex_);
443 443
444 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher); 444 MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher);
445 }; 445 };
446 446
447 // Wrapper around a |Dispatcher| pointer, while it's being processed to be
448 // passed in a message pipe. See the comment about
449 // |Dispatcher::HandleTableAccess| for more details.
450 //
451 // Note: This class is deliberately "thin" -- no more expensive than a
452 // |Dispatcher*|.
453 class DispatcherTransport final {
454 public:
455 DispatcherTransport() : dispatcher_(nullptr) {}
456
457 void End() MOJO_NOT_THREAD_SAFE;
458
459 Dispatcher::Type GetType() const { return dispatcher_->GetType(); }
460 bool IsBusy() const MOJO_NOT_THREAD_SAFE {
461 return dispatcher_->IsBusyNoLock();
462 }
463 void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); }
464 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndClose(
465 MessagePipe* message_pipe,
466 unsigned port) MOJO_NOT_THREAD_SAFE {
467 return dispatcher_->CreateEquivalentDispatcherAndCloseNoLock(message_pipe,
468 port);
469 }
470
471 bool is_valid() const { return !!dispatcher_; }
472
473 private:
474 friend class Dispatcher::HandleTableAccess;
475
476 explicit DispatcherTransport(Dispatcher* dispatcher)
477 : dispatcher_(dispatcher) {}
478
479 Dispatcher* dispatcher_;
480
481 // Copy and assign allowed.
482 };
483
484 // So logging macros and |DCHECK_EQ()|, etc. work. 447 // So logging macros and |DCHECK_EQ()|, etc. work.
485 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { 448 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) {
486 return out << static_cast<int>(type); 449 return out << static_cast<int>(type);
487 } 450 }
488 451
489 } // namespace system 452 } // namespace system
490 } // namespace mojo 453 } // namespace mojo
491 454
492 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ 455 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe_impl_unittest.cc ('k') | mojo/edk/system/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698