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

Unified Diff: mojo/edk/system/dispatcher.h

Issue 1915153002: EDK: Add Dispatcher::SupportsEntrypointClass(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/message_pipe_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/dispatcher.h
diff --git a/mojo/edk/system/dispatcher.h b/mojo/edk/system/dispatcher.h
index 2206848c22e9daa7c9aff33cb1bf5d000225e943..e21a6509a500868b8013b3365cbf716d4f045025 100644
--- a/mojo/edk/system/dispatcher.h
+++ b/mojo/edk/system/dispatcher.h
@@ -60,6 +60,9 @@ DispatcherTransport DispatcherTryStartTransport(Dispatcher* dispatcher);
// |mutex()| method).
class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
public:
+ // Types of dispatchers. Note that these are not necessarily a one-to-one with
+ // implementations of |Dispatcher|: multiple implementations may share the
+ // same type.
enum class Type {
UNKNOWN = 0,
MESSAGE_PIPE,
@@ -70,8 +73,41 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
// "Private" types (not exposed via the public interface):
PLATFORM_HANDLE = -1
};
+
+ // Classes of "entrypoints"/"syscalls": Each dispatcher should support entire
+ // classes of methods (and if they don't support a given class, they should
+ // return |MOJO_RESULT_INVALID_ARGUMENT| for all the methods in that class).
+ // Warning: A method may be called even if |SupportsEntrypointClass()|
+ // indicates that the method's class is not supported (see below).
+ enum class EntrypointClass {
+ // |ReadMessage()|, |WriteMessage()|:
+ MESSAGE_PIPE,
+
+ // |SetDataPipeProducerOptions()|, |GetDataPipeProducerOptions()|,
+ // |WriteData()|, |BeginWriteData()|, |EndWriteData()|:
+ DATA_PIPE_PRODUCER,
+
+ // |SetDataPipeConsumerOptions()|, |GetDataPipeConsumerOptions()|,
+ // |ReadData()|, |BeginReadData()|, |EndReadData()|:
+ DATA_PIPE_CONSUMER,
+
+ // |DuplicateBufferHandle()|, |GetBufferInformation()|, |MapBuffer()|:
+ BUFFER,
+ };
+
+ // Gets the type of the dispatcher; see |Type| above.
virtual Type GetType() const = 0;
+ // Gets whether the given entrypoint class is supported; see |EntrypointClass|
+ // above. This is ONLY called when a rights check has failed, to determine
+ // whether |MOJO_RESULT_PERMISSION_DENIED| (if the entrypoint class is
+ // supported) or |MOJO_RESULT_INVALID_ARGUMENT| (if not) should be returned.
+ // In the case that the rights check passes, |Core| will proceed immediately
+ // to call the method (so if the method is not supported, it must still return
+ // |MOJO_RESULT_INVALID_ARGUMENT|).
+ virtual bool SupportsEntrypointClass(
+ EntrypointClass entrypoint_class) const = 0;
+
// These methods implement the various primitives named |Mojo...()|. These
// take |mutex_| and handle races with |Close()|. Then they call out to
// subclasses' |...ImplNoLock()| methods (still under |mutex_|), which
@@ -81,6 +117,7 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
// possible. If this becomes an issue, we can rethink this.
MojoResult Close();
+ // |EntrypointClass::MESSAGE_PIPE|:
// |transports| may be non-null if and only if there are handles to be
// written; not that |this| must not be in |transports|. On success, all the
// dispatchers in |transports| must have been moved to a closed state; on
@@ -98,6 +135,7 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
uint32_t* num_dispatchers,
MojoReadMessageFlags flags);
+ // |EntrypointClass::DATA_PIPE_PRODUCER|:
MojoResult SetDataPipeProducerOptions(
UserPointer<const MojoDataPipeProducerOptions> options);
MojoResult GetDataPipeProducerOptions(
@@ -110,6 +148,8 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
UserPointer<uint32_t> buffer_num_bytes,
MojoWriteDataFlags flags);
MojoResult EndWriteData(uint32_t num_bytes_written);
+
+ // |EntrypointClass::DATA_PIPE_CONSUMER|:
MojoResult SetDataPipeConsumerOptions(
UserPointer<const MojoDataPipeConsumerOptions> options);
MojoResult GetDataPipeConsumerOptions(
@@ -123,6 +163,7 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
MojoReadDataFlags flags);
MojoResult EndReadData(uint32_t num_bytes_read);
+ // |EntrypointClass::BUFFER|:
// |options| may be null. |new_dispatcher| must not be null, but
// |*new_dispatcher| should be null (and will contain the dispatcher for the
// new handle on success).
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/message_pipe_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698