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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/platform/native/mojo_core.h
diff --git a/mojo/public/platform/native/mojo_core.h b/mojo/public/platform/native/mojo_core.h
new file mode 100644
index 0000000000000000000000000000000000000000..24b4d6497b124ec6208efb32149852b741d2fabf
--- /dev/null
+++ b/mojo/public/platform/native/mojo_core.h
@@ -0,0 +1,122 @@
+// Copyright 2013 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.
+
+#ifndef MOJO_PUBLIC_PLATFORM_NATIVE_MOJO_CORE_H_
+#define MOJO_PUBLIC_PLATFORM_NATIVE_MOJO_CORE_H_
+
+#include "mojo/public/c/system/core.h"
+
+// The embedder needs to bind the basic Mojo Core functions of a DSO to those of
+// the embedder when loading a DSO that is dependent on mojo_system.
+// The typical usage would look like:
+// base::ScopedNativeLibrary app_library(
+// base::LoadNativeLibrary(app_path_, &error));
+// typedef MojoResult (*SetMojoCoreFn)(MojoCore*);
+// SetMojoCoreFn set_mojo_core_fn = reinterpret_cast<SetMojoCoreFn>(
+// app_library.GetFunctionPointer("SetMojoCore"));
+// MojoCore mojo_core_impl = GetMojoCoreImpl();
+// MojoResult set_result = set_mojo_core_fn(&mojo_core_impl);
+// if (set_result != MOJO_RESULT_OK) {
+// LOG(ERROR)
+// << "Invalid DSO. Expected MojoCore size: "
+// << mojo_core_impl.size;
+// }
+
+// Structure used to bind the basic Mojo Core functions of a DSO to those of
+// 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.
+struct MojoCore {
+ 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.
+ MojoTimeTicks (*GetTimeTicksNow)();
+ MojoResult (*Close)(MojoHandle handle);
+ MojoResult (*Wait)(MojoHandle handle,
+ MojoWaitFlags flags,
+ MojoDeadline deadline);
+ MojoResult (*WaitMany)(const MojoHandle* handles,
+ const MojoWaitFlags* flags,
+ uint32_t num_handles,
+ MojoDeadline deadline);
+ MojoResult (*CreateMessagePipe)(MojoHandle* message_pipe_handle0,
+ MojoHandle* message_pipe_handle1);
+ MojoResult (*WriteMessage)(MojoHandle message_pipe_handle,
+ const void* bytes,
+ uint32_t num_bytes,
+ const MojoHandle* handles,
+ uint32_t num_handles,
+ MojoWriteMessageFlags flags);
+ MojoResult (*ReadMessage)(MojoHandle message_pipe_handle,
+ void* bytes,
+ uint32_t* num_bytes,
+ MojoHandle* handles,
+ uint32_t* num_handles,
+ MojoReadMessageFlags flags);
+ MojoResult (*CreateDataPipe)(const MojoCreateDataPipeOptions* options,
+ MojoHandle* data_pipe_producer_handle,
+ MojoHandle* data_pipe_consumer_handle);
+ MojoResult (*WriteData)(MojoHandle data_pipe_producer_handle,
+ const void* elements,
+ uint32_t* num_elements,
+ MojoWriteDataFlags flags);
+ MojoResult (*BeginWriteData)(MojoHandle data_pipe_producer_handle,
+ void** buffer,
+ uint32_t* buffer_num_elements,
+ MojoWriteDataFlags flags);
+ MojoResult (*EndWriteData)(MojoHandle data_pipe_producer_handle,
+ uint32_t num_elements_written);
+ MojoResult (*ReadData)(MojoHandle data_pipe_consumer_handle,
+ void* elements,
+ uint32_t* num_elements,
+ MojoReadDataFlags flags);
+ MojoResult (*BeginReadData)(MojoHandle data_pipe_consumer_handle,
+ const void** buffer,
+ uint32_t* buffer_num_elements,
+ MojoReadDataFlags flags);
+ MojoResult (*EndReadData)(MojoHandle data_pipe_consumer_handle,
+ uint32_t num_elements_read);
+ MojoResult (*CreateSharedBuffer)(
+ const MojoCreateSharedBufferOptions* options,
+ uint64_t num_bytes,
+ MojoHandle* shared_buffer_handle);
+ MojoResult (*DuplicateBufferHandle)(
+ MojoHandle buffer_handle,
+ const MojoDuplicateBufferHandleOptions* options,
+ MojoHandle* new_buffer_handle);
+ MojoResult (*MapBuffer)(MojoHandle buffer_handle,
+ uint64_t offset,
+ uint64_t num_bytes,
+ void** buffer,
+ MojoMapBufferFlags flags);
+ MojoResult (*UnmapBuffer)(void* buffer);
+};
+
+// Intended to be called from the embedder. Returns a |MojoCore| initialized
+// to contain pointers to each of the embedder's MojoCore functions.
+static inline const MojoCore GetMojoCoreImpl() {
+ MojoCore mojo_core_impl {
+ sizeof(MojoCore),
+ MojoGetTimeTicksNow,
+ MojoClose,
+ MojoWait,
+ MojoWaitMany,
+ MojoCreateMessagePipe,
+ MojoWriteMessage,
+ MojoReadMessage,
+ MojoCreateDataPipe,
+ MojoWriteData,
+ MojoBeginWriteData,
+ MojoEndWriteData,
+ MojoReadData,
+ MojoBeginReadData,
+ MojoEndReadData,
+ MojoCreateSharedBuffer,
+ MojoDuplicateBufferHandle,
+ MojoMapBuffer,
+ MojoUnmapBuffer
+ };
+ return mojo_core_impl;
+}
+
+// Called to set the MojoCore functionality of a DSO.
+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
+
+#endif // MOJO_PUBLIC_PLATFORM_NATIVE_MOJO_CORE_H_

Powered by Google App Engine
This is Rietveld 408576698