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

Side by Side Diff: mojo/public/platform/native/mojo_core.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: Cleanup 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_MOJO_CORE_H_
6 #define MOJO_PUBLIC_PLATFORM_NATIVE_MOJO_CORE_H_
7
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 (*SetMojoCoreFn)(MojoCore*);
16 // SetMojoCoreFn set_mojo_core_fn = reinterpret_cast<SetMojoCoreFn>(
17 // app_library.GetFunctionPointer("SetMojoCore"));
18 // MojoCore mojo_core_impl = GetMojoCoreImpl();
19 // MojoResult set_result = set_mojo_core_fn(&mojo_core_impl);
20 // if (set_result != MOJO_RESULT_OK) {
21 // LOG(ERROR)
22 // << "Invalid DSO. Expected MojoCore size: "
23 // << mojo_core_impl.size;
24 // }
25
26 // Structure used to bind the basic Mojo Core functions of a DSO to those of
27 // the embedder.
viettrungluu 2014/04/09 20:52:23 You should probably have a comment indicating that
DaveMoore 2014/04/09 22:49:08 Done.
28 struct MojoCore {
29 size_t size;
viettrungluu 2014/04/09 20:52:23 Comment indicating that this should be set to size
DaveMoore 2014/04/09 22:49:08 Done.
30 MojoTimeTicks (*GetTimeTicksNow)();
31 MojoResult (*Close)(MojoHandle handle);
32 MojoResult (*Wait)(MojoHandle handle,
33 MojoWaitFlags flags,
34 MojoDeadline deadline);
35 MojoResult (*WaitMany)(const MojoHandle* handles,
36 const MojoWaitFlags* flags,
37 uint32_t num_handles,
38 MojoDeadline deadline);
39 MojoResult (*CreateMessagePipe)(MojoHandle* message_pipe_handle0,
40 MojoHandle* message_pipe_handle1);
41 MojoResult (*WriteMessage)(MojoHandle message_pipe_handle,
42 const void* bytes,
43 uint32_t num_bytes,
44 const MojoHandle* handles,
45 uint32_t num_handles,
46 MojoWriteMessageFlags flags);
47 MojoResult (*ReadMessage)(MojoHandle message_pipe_handle,
48 void* bytes,
49 uint32_t* num_bytes,
50 MojoHandle* handles,
51 uint32_t* num_handles,
52 MojoReadMessageFlags flags);
53 MojoResult (*CreateDataPipe)(const MojoCreateDataPipeOptions* options,
54 MojoHandle* data_pipe_producer_handle,
55 MojoHandle* data_pipe_consumer_handle);
56 MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle,
57 const void* elements,
58 uint32_t* num_elements,
59 MojoWriteDataFlags flags);
60 MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle,
61 void** buffer,
62 uint32_t* buffer_num_elements,
63 MojoWriteDataFlags flags);
64 MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle,
65 uint32_t num_elements_written);
66 MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle,
67 void* elements,
68 uint32_t* num_elements,
69 MojoReadDataFlags flags);
70 MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle,
71 const void** buffer,
72 uint32_t* buffer_num_elements,
73 MojoReadDataFlags flags);
74 MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle,
75 uint32_t num_elements_read);
76 MojoResult (*CreateSharedBuffer)(
77 const MojoCreateSharedBufferOptions* options,
78 uint64_t num_bytes,
79 MojoHandle* shared_buffer_handle);
80 MojoResult (*DuplicateBufferHandle)(
81 MojoHandle buffer_handle,
82 const MojoDuplicateBufferHandleOptions* options,
83 MojoHandle* new_buffer_handle);
84 MojoResult (*MapBuffer)(MojoHandle buffer_handle,
85 uint64_t offset,
86 uint64_t num_bytes,
87 void** buffer,
88 MojoMapBufferFlags flags);
89 MojoResult (*UnmapBuffer)(void* buffer);
90 };
91
92 // Intended to be called from the embedder. Returns a |MojoCore| initialized
93 // to contain pointers to each of the embedder's MojoCore functions.
94 static inline const MojoCore GetMojoCoreImpl() {
95 MojoCore mojo_core_impl {
96 sizeof(MojoCore),
97 MojoGetTimeTicksNow,
98 MojoClose,
99 MojoWait,
100 MojoWaitMany,
101 MojoCreateMessagePipe,
102 MojoWriteMessage,
103 MojoReadMessage,
104 MojoCreateDataPipe,
105 MojoWriteData,
106 MojoBeginWriteData,
107 MojoEndWriteData,
108 MojoReadData,
109 MojoBeginReadData,
110 MojoEndReadData,
111 MojoCreateSharedBuffer,
112 MojoDuplicateBufferHandle,
113 MojoMapBuffer,
114 MojoUnmapBuffer
115 };
116 return mojo_core_impl;
117 }
118
119 // Called to set the MojoCore functionality of a DSO.
120 extern "C" MOJO_SYSTEM_EXPORT MojoResult SetMojoCore(MojoCore* mojo_core);
viettrungluu 2014/04/09 20:39:10 This probably shouldn't be in the header file. (It
121
122 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_MOJO_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698