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

Unified Diff: mojo/public/platform/native/core_system_thunks.h

Issue 1052723003: NaCl: create a separate namespace for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/platform/native/core_system_thunks.h
diff --git a/mojo/public/platform/native/core_system_thunks.h b/mojo/public/platform/native/core_system_thunks.h
new file mode 100644
index 0000000000000000000000000000000000000000..9e6ae5ab8788c125b7d19e420a314364d3c98ed8
--- /dev/null
+++ b/mojo/public/platform/native/core_system_thunks.h
@@ -0,0 +1,154 @@
+// Copyright 2015 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.
+
+// Note: This header should be compilable as C.
+
+#ifndef MOJO_PUBLIC_PLATFORM_NATIVE_CORE_SYSTEM_THUNKS_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_CORE_SYSTEM_THUNKS_H_
+
+#include <stddef.h>
+
+#include "mojo/public/c/system/core.h"
+#include "mojo/public/platform/native/core_system_api.h"
+
+// Structure used to bind the basic Mojo Core functions of a DSO to those of
+// the embedder.
+// This is the ABI between the embedder and the DSO. It can only have new
+// functions added to the end. No other changes are supported.
+#pragma pack(push, 8)
+struct MojoCoreSystemThunks {
viettrungluu 2015/04/01 23:36:19 Maybe something like "MojoSystemImplPrivateThunks"
Nick Bray (chromium) 2015/04/04 00:09:09 Done.
+ size_t size; // Should be set to sizeof(MojoCoreSystemThunks).
+ // MojoCoreHandle (*GetDefaultCore)();
viettrungluu 2015/04/01 23:36:19 ?
Nick Bray (chromium) 2015/04/04 00:09:09 Done.
+ GetDefaultCoreFn* GetDefaultCore;
+ MojoCoreHandle (*CreateCore)();
+ MojoResult (*TransferHandle)(MojoCoreHandle from_core,
+ MojoHandle handle,
+ MojoCoreHandle to_core,
+ MojoHandle* result_handle);
+ MojoResult (*CloseCore)(MojoCoreHandle core);
+ MojoTimeTicks (*GetTimeTicksNow)(MojoCoreHandle core);
+ MojoResult (*Close)(MojoCoreHandle core, MojoHandle handle);
+ MojoResult (*Wait)(MojoCoreHandle core,
+ MojoHandle handle,
+ MojoHandleSignals signals,
+ MojoDeadline deadline,
+ struct MojoHandleSignalsState* signals_state);
+ MojoResult (*WaitMany)(MojoCoreHandle core,
+ const MojoHandle* handles,
+ const MojoHandleSignals* signals,
+ uint32_t num_handles,
+ MojoDeadline deadline,
+ uint32_t* result_index,
+ struct MojoHandleSignalsState* signals_states);
+ MojoResult (*CreateMessagePipe)(
+ MojoCoreHandle core,
+ const struct MojoCreateMessagePipeOptions* options,
+ MojoHandle* message_pipe_handle0,
+ MojoHandle* message_pipe_handle1);
+ MojoResult (*WriteMessage)(MojoCoreHandle core,
+ MojoHandle message_pipe_handle,
+ const void* bytes,
+ uint32_t num_bytes,
+ const MojoHandle* handles,
+ uint32_t num_handles,
+ MojoWriteMessageFlags flags);
+ MojoResult (*ReadMessage)(MojoCoreHandle core,
+ MojoHandle message_pipe_handle,
+ void* bytes,
+ uint32_t* num_bytes,
+ MojoHandle* handles,
+ uint32_t* num_handles,
+ MojoReadMessageFlags flags);
+ MojoResult (*CreateDataPipe)(MojoCoreHandle core,
+ const struct MojoCreateDataPipeOptions* options,
+ MojoHandle* data_pipe_producer_handle,
+ MojoHandle* data_pipe_consumer_handle);
+ MojoResult (*WriteData)(MojoCoreHandle core,
+ MojoHandle data_pipe_producer_handle,
+ const void* elements,
+ uint32_t* num_elements,
+ MojoWriteDataFlags flags);
+ MojoResult (*BeginWriteData)(MojoCoreHandle core,
+ MojoHandle data_pipe_producer_handle,
+ void** buffer,
+ uint32_t* buffer_num_elements,
+ MojoWriteDataFlags flags);
+ MojoResult (*EndWriteData)(MojoCoreHandle core,
+ MojoHandle data_pipe_producer_handle,
+ uint32_t num_elements_written);
+ MojoResult (*ReadData)(MojoCoreHandle core,
+ MojoHandle data_pipe_consumer_handle,
+ void* elements,
+ uint32_t* num_elements,
+ MojoReadDataFlags flags);
+ MojoResult (*BeginReadData)(MojoCoreHandle core,
+ MojoHandle data_pipe_consumer_handle,
+ const void** buffer,
+ uint32_t* buffer_num_elements,
+ MojoReadDataFlags flags);
+ MojoResult (*EndReadData)(MojoCoreHandle core,
+ MojoHandle data_pipe_consumer_handle,
+ uint32_t num_elements_read);
+ MojoResult (*CreateSharedBuffer)(
+ MojoCoreHandle core,
+ const struct MojoCreateSharedBufferOptions* options,
+ uint64_t num_bytes,
+ MojoHandle* shared_buffer_handle);
+ MojoResult (*DuplicateBufferHandle)(
+ MojoCoreHandle core,
+ MojoHandle buffer_handle,
+ const struct MojoDuplicateBufferHandleOptions* options,
+ MojoHandle* new_buffer_handle);
+ MojoResult (*MapBuffer)(MojoCoreHandle core,
+ MojoHandle buffer_handle,
+ uint64_t offset,
+ uint64_t num_bytes,
+ void** buffer,
+ MojoMapBufferFlags flags);
+ MojoResult (*UnmapBuffer)(MojoCoreHandle core, void* buffer);
+};
+#pragma pack(pop)
+
+#ifdef __cplusplus
+// Intended to be called from the embedder. Returns a |MojoCore| initialized
+// to contain pointers to each of the embedder's MojoCore functions.
+inline MojoCoreSystemThunks MojoMakeCoreSystemThunks() {
+ MojoCoreSystemThunks system_thunks = {sizeof(MojoCoreSystemThunks),
+ MojoCoreGetDefaultCore,
+ MojoCoreCreateCore,
+ MojoCoreTransferHandle,
+ MojoCoreCloseCore,
+ MojoCoreGetTimeTicksNow,
+ MojoCoreClose,
+ MojoCoreWait,
+ MojoCoreWaitMany,
+ MojoCoreCreateMessagePipe,
+ MojoCoreWriteMessage,
+ MojoCoreReadMessage,
+ MojoCoreCreateDataPipe,
+ MojoCoreWriteData,
+ MojoCoreBeginWriteData,
+ MojoCoreEndWriteData,
+ MojoCoreReadData,
+ MojoCoreBeginReadData,
+ MojoCoreEndReadData,
+ MojoCoreCreateSharedBuffer,
+ MojoCoreDuplicateBufferHandle,
+ MojoCoreMapBuffer,
+ MojoCoreUnmapBuffer};
+ return system_thunks;
+}
+#endif
+
+// Use this type for the function found by dynamically discovering it in
+// a DSO linked with mojo_system. For example:
+// MojoSetCoreSystemThunksFn mojo_set_core_system_thunks_fn =
+// reinterpret_cast<MojoSetCoreSystemThunksFn>(app_library.GetFunctionPointer(
+// "MojoSetCoreSystemThunks"));
+// The expected size of |system_thunks} is returned.
+// The contents of |system_thunks| are copied.
+typedef size_t (*MojoSetCoreSystemThunksFn)(
+ const struct MojoCoreSystemThunks* system_thunks);
+
+#endif // MOJO_PUBLIC_PLATFORM_NATIVE_CORE_SYSTEM_THUNKS_H_

Powered by Google App Engine
This is Rietveld 408576698