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

Side by Side Diff: mojo/public/c/system/thunks.h

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Note: This header should be compilable as C. 5 // Note: This header should be compilable as C.
6 6
7 #ifndef MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ 7 #ifndef MOJO_PUBLIC_C_SYSTEM_THUNKS_H_
8 #define MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ 8 #define MOJO_PUBLIC_C_SYSTEM_THUNKS_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include "mojo/public/c/system/core.h" 13 #include "mojo/public/c/system/core.h"
14 #include "mojo/public/c/system/system_export.h" 14 #include "mojo/public/c/system/system_export.h"
15 15
16 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of 16 // Structure used to bind the basic Mojo Core functions to an embedder
17 // the embedder when loading a DSO that is dependent on mojo_system. 17 // implementation. This is intended to eventually be used as a stable ABI
18 // The typical usage would look like: 18 // between a Mojo embedder and some loaded application code, but for now it is
19 // base::ScopedNativeLibrary app_library( 19 // still effectively safe to rearrange entries as needed.
20 // base::LoadNativeLibrary(app_path_, &error));
21 // typedef MojoResult (*MojoSetSystemThunksFn)(MojoSystemThunks*);
22 // MojoSetSystemThunksFn mojo_set_system_thunks_fn =
23 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
24 // "MojoSetSystemThunks"));
25 // MojoSystemThunks system_thunks = MojoMakeSystemThunks();
26 // size_t expected_size = mojo_set_system_thunks_fn(&system_thunks);
27 // if (expected_size > sizeof(MojoSystemThunks)) {
28 // LOG(ERROR)
29 // << "Invalid DSO. Expected MojoSystemThunks size: "
30 // << expected_size;
31 // break;
32 // }
33
34 // Structure used to bind the basic Mojo Core functions of a DSO to those of
35 // the embedder.
36 // This is the ABI between the embedder and the DSO. It can only have new
37 // functions added to the end. No other changes are supported.
38 #pragma pack(push, 8) 20 #pragma pack(push, 8)
39 struct MojoSystemThunks { 21 struct MojoSystemThunks {
40 size_t size; // Should be set to sizeof(MojoSystemThunks). 22 size_t size; // Should be set to sizeof(MojoSystemThunks).
41 MojoTimeTicks (*GetTimeTicksNow)(); 23 MojoTimeTicks (*GetTimeTicksNow)();
42 MojoResult (*Close)(MojoHandle handle); 24 MojoResult (*Close)(MojoHandle handle);
43 MojoResult (*Wait)(MojoHandle handle, 25 MojoResult (*Wait)(MojoHandle handle,
44 MojoHandleSignals signals, 26 MojoHandleSignals signals,
45 MojoDeadline deadline, 27 MojoDeadline deadline,
46 struct MojoHandleSignalsState* signals_state); 28 struct MojoHandleSignalsState* signals_state);
47 MojoResult (*WaitMany)(const MojoHandle* handles, 29 MojoResult (*WaitMany)(const MojoHandle* handles,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 MojoResult (*AddHandle)(MojoHandle wait_set, 90 MojoResult (*AddHandle)(MojoHandle wait_set,
109 MojoHandle handle, 91 MojoHandle handle,
110 MojoHandleSignals signals); 92 MojoHandleSignals signals);
111 MojoResult (*RemoveHandle)(MojoHandle wait_set, 93 MojoResult (*RemoveHandle)(MojoHandle wait_set,
112 MojoHandle handle); 94 MojoHandle handle);
113 MojoResult (*GetReadyHandles)(MojoHandle wait_set, 95 MojoResult (*GetReadyHandles)(MojoHandle wait_set,
114 uint32_t* count, 96 uint32_t* count,
115 MojoHandle* handles, 97 MojoHandle* handles,
116 MojoResult* results, 98 MojoResult* results,
117 struct MojoHandleSignalsState* signals_states); 99 struct MojoHandleSignalsState* signals_states);
118 MojoResult (*Watch)(MojoHandle handle, 100 MojoResult (*RegisterWatcher)(MojoHandle handle,
119 MojoHandleSignals signals, 101 MojoHandleSignals signals,
120 MojoWatchCallback callback, 102 MojoWatchCallback callback,
121 uintptr_t context); 103 uintptr_t context);
122 MojoResult (*CancelWatch)(MojoHandle handle, uintptr_t context); 104 MojoResult (*ArmWatcher)(MojoHandle handle, uintptr_t context);
105 MojoResult (*UnregisterWatcher)(MojoHandle handle, uintptr_t context);
123 MojoResult (*FuseMessagePipes)(MojoHandle handle0, MojoHandle handle1); 106 MojoResult (*FuseMessagePipes)(MojoHandle handle0, MojoHandle handle1);
124 MojoResult (*WriteMessageNew)(MojoHandle message_pipe_handle, 107 MojoResult (*WriteMessageNew)(MojoHandle message_pipe_handle,
125 MojoMessageHandle message, 108 MojoMessageHandle message,
126 MojoWriteMessageFlags flags); 109 MojoWriteMessageFlags flags);
127 MojoResult (*ReadMessageNew)(MojoHandle message_pipe_handle, 110 MojoResult (*ReadMessageNew)(MojoHandle message_pipe_handle,
128 MojoMessageHandle* message, 111 MojoMessageHandle* message,
129 uint32_t* num_bytes, 112 uint32_t* num_bytes,
130 MojoHandle* handles, 113 MojoHandle* handles,
131 uint32_t* num_handles, 114 uint32_t* num_handles,
132 MojoReadMessageFlags flags); 115 MojoReadMessageFlags flags);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // The contents of |system_thunks| are copied. 152 // The contents of |system_thunks| are copied.
170 typedef size_t (*MojoSetSystemThunksFn)( 153 typedef size_t (*MojoSetSystemThunksFn)(
171 const struct MojoSystemThunks* system_thunks); 154 const struct MojoSystemThunks* system_thunks);
172 155
173 // A function for setting up the embedder's own system thunks. This should only 156 // A function for setting up the embedder's own system thunks. This should only
174 // be called by Mojo embedder code. 157 // be called by Mojo embedder code.
175 MOJO_SYSTEM_EXPORT size_t MojoEmbedderSetSystemThunks( 158 MOJO_SYSTEM_EXPORT size_t MojoEmbedderSetSystemThunks(
176 const struct MojoSystemThunks* system_thunks); 159 const struct MojoSystemThunks* system_thunks);
177 160
178 #endif // MOJO_PUBLIC_C_SYSTEM_THUNKS_H_ 161 #endif // MOJO_PUBLIC_C_SYSTEM_THUNKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698