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

Unified Diff: mojo/edk/system/handle_transport.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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/handle_table.cc ('k') | mojo/edk/system/handle_transport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/handle_transport.h
diff --git a/mojo/edk/system/handle_transport.h b/mojo/edk/system/handle_transport.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb60001a455ae6ceaf01036d6583c1918fc14383
--- /dev/null
+++ b/mojo/edk/system/handle_transport.h
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
+#define MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
+
+#include "mojo/edk/system/dispatcher.h"
+#include "mojo/edk/util/ref_ptr.h"
+#include "mojo/edk/util/thread_annotations.h"
+
+namespace mojo {
+namespace system {
+
+class MessagePipe;
+
+// Wrapper around a |Dispatcher| pointer, while it's being processed to be
+// passed in a message pipe. See the comment about
+// |Dispatcher::HandleTableAccess| for more details.
+//
+// Note: This class is deliberately "thin" -- no more expensive than a
+// |Dispatcher*|.
+//
+// TODO(vtl): Add handle rights to this, and rename it to HandleTransport.
+class DispatcherTransport final {
+ public:
+ DispatcherTransport() : dispatcher_(nullptr) {}
+
+ void End() MOJO_NOT_THREAD_SAFE;
+
+ Dispatcher::Type GetType() const { return dispatcher_->GetType(); }
+ bool IsBusy() const MOJO_NOT_THREAD_SAFE {
+ return dispatcher_->IsBusyNoLock();
+ }
+ void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); }
+ util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndClose(
+ MessagePipe* message_pipe,
+ unsigned port) MOJO_NOT_THREAD_SAFE {
+ return dispatcher_->CreateEquivalentDispatcherAndCloseNoLock(message_pipe,
+ port);
+ }
+
+ bool is_valid() const { return !!dispatcher_; }
+
+ private:
+ friend class Dispatcher::HandleTableAccess;
+
+ explicit DispatcherTransport(Dispatcher* dispatcher)
+ : dispatcher_(dispatcher) {}
+
+ Dispatcher* dispatcher_;
+
+ // Copy and assign allowed.
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
« no previous file with comments | « mojo/edk/system/handle_table.cc ('k') | mojo/edk/system/handle_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698