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

Side by Side Diff: mojo/public/platform/native/system_thunks.h

Issue 231353002: Make mojo_system static and mojo_system_impl a component, never use both (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix accidental change to .gitmodules Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
6 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
7
viettrungluu 2014/04/09 23:06:44 nit: Should also include <stddef.h> for size_t.
DaveMoore 2014/04/10 18:58:58 Done.
8 #include "mojo/public/c/system/core.h"
9
10 // The embedder needs to bind the basic Mojo Core functions of a DSO to those of
11 // the embedder when loading a DSO that is dependent on mojo_system.
12 // The typical usage would look like:
13 // base::ScopedNativeLibrary app_library(
14 // base::LoadNativeLibrary(app_path_, &error));
15 // typedef MojoResult (*MojoSetSystemThunksFn)(MojoSystemThunks*);
16 // MojoSetSystemThunksFn mojo_set_system_thunks_fn =
17 // reinterpret_cast<MojoSetSystemThunksFn>(app_library.GetFunctionPointer(
18 // "MojoSetSystemThunks"));
19 // MojoSystemThunks system_thunks = MojoMakeSystemThunks();
20 // MojoResult set_result = mojo_set_system_thunks_fn(&system_thunks);
21 // if (set_result != MOJO_RESULT_OK) {
22 // LOG(ERROR)
23 // << "Invalid DSO. Expected MojoSystemThunks size: "
24 // << system_thunks.size;
25 // }
26
27 // Structure used to bind the basic Mojo Core functions of a DSO to those of
28 // the embedder.
29 // This is the ABI between the embedder and the DSO. It can only have new
30 // functions added to the end. No other changes are supported.
31 #pragma pack(push, 8)
32 struct MojoSystemThunks {
33 size_t size; // Should be set to sizeof(MojoSystemThunks).
34 MojoTimeTicks (*GetTimeTicksNow)();
35 MojoResult (*Close)(MojoHandle handle);
viettrungluu 2014/04/09 23:06:44 Comment: It's unnecessary to include the parameter
36 MojoResult (*Wait)(MojoHandle handle,
37 MojoWaitFlags flags,
38 MojoDeadline deadline);
39 MojoResult (*WaitMany)(const MojoHandle* handles,
40 const MojoWaitFlags* flags,
41 uint32_t num_handles,
42 MojoDeadline deadline);
43 MojoResult (*CreateMessagePipe)(MojoHandle* message_pipe_handle0,
44 MojoHandle* message_pipe_handle1);
45 MojoResult (*WriteMessage)(MojoHandle message_pipe_handle,
46 const void* bytes,
47 uint32_t num_bytes,
48 const MojoHandle* handles,
49 uint32_t num_handles,
50 MojoWriteMessageFlags flags);
51 MojoResult (*ReadMessage)(MojoHandle message_pipe_handle,
52 void* bytes,
53 uint32_t* num_bytes,
54 MojoHandle* handles,
55 uint32_t* num_handles,
56 MojoReadMessageFlags flags);
57 MojoResult (*CreateDataPipe)(const MojoCreateDataPipeOptions* options,
58 MojoHandle* data_pipe_producer_handle,
59 MojoHandle* data_pipe_consumer_handle);
60 MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle,
61 const void* elements,
62 uint32_t* num_elements,
63 MojoWriteDataFlags flags);
64 MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle,
65 void** buffer,
66 uint32_t* buffer_num_elements,
67 MojoWriteDataFlags flags);
68 MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle,
69 uint32_t num_elements_written);
70 MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle,
71 void* elements,
72 uint32_t* num_elements,
73 MojoReadDataFlags flags);
74 MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle,
75 const void** buffer,
76 uint32_t* buffer_num_elements,
77 MojoReadDataFlags flags);
78 MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle,
79 uint32_t num_elements_read);
80 MojoResult (*CreateSharedBuffer)(
81 const MojoCreateSharedBufferOptions* options,
82 uint64_t num_bytes,
83 MojoHandle* shared_buffer_handle);
84 MojoResult (*DuplicateBufferHandle)(
85 MojoHandle buffer_handle,
86 const MojoDuplicateBufferHandleOptions* options,
87 MojoHandle* new_buffer_handle);
88 MojoResult (*MapBuffer)(MojoHandle buffer_handle,
89 uint64_t offset,
90 uint64_t num_bytes,
91 void** buffer,
92 MojoMapBufferFlags flags);
93 MojoResult (*UnmapBuffer)(void* buffer);
94 };
95 #pragma pack(pop)
96
97 // Intended to be called from the embedder. Returns a |MojoCore| initialized
viettrungluu 2014/04/09 23:06:44 MojoCore -> MojoSystemThunks
98 // to contain pointers to each of the embedder's MojoCore functions.
viettrungluu 2014/04/09 23:06:44 "
99 static inline const MojoSystemThunks MojoMakeSystemThunks() {
viettrungluu 2014/04/09 23:06:44 const is unnecessary
100 MojoSystemThunks system_thunks {
101 sizeof(MojoSystemThunks),
102 MojoGetTimeTicksNow,
103 MojoClose,
104 MojoWait,
105 MojoWaitMany,
106 MojoCreateMessagePipe,
107 MojoWriteMessage,
108 MojoReadMessage,
109 MojoCreateDataPipe,
110 MojoWriteData,
111 MojoBeginWriteData,
112 MojoEndWriteData,
113 MojoReadData,
114 MojoBeginReadData,
115 MojoEndReadData,
116 MojoCreateSharedBuffer,
117 MojoDuplicateBufferHandle,
118 MojoMapBuffer,
119 MojoUnmapBuffer
120 };
121 return system_thunks;
122 }
123
124 typedef size_t (*MojoSetSystemThunksFn)(const MojoSystemThunks* mojo_core);
125
126 // Called to set the MojoCore functionality of a DSO. Returns the expected size.
viettrungluu 2014/04/09 23:06:44 MojoCore
127 extern "C" MOJO_SYSTEM_EXPORT size_t MojoSetSystemThunks(
viettrungluu 2014/04/09 23:06:44 Shouldn't be in this header, per my 2nd batch of c
128 const MojoSystemThunks* mojo_core);
129
130 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_THUNKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698