Revert 257022 "Implement wallpaper policy"
[chromium-blink-merge.git] / mojo / public / system / core_private.cc
blob1af11d3a0fc64b0232c4b8a5605b62732dbe5eb4
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.
5 #include "mojo/public/system/core_private.h"
7 #include <assert.h>
8 #include <stddef.h>
10 static mojo::Core* g_core = NULL;
12 extern "C" {
14 MojoTimeTicks MojoGetTimeTicksNow() {
15 assert(g_core);
16 return g_core->GetTimeTicksNow();
19 MojoResult MojoClose(MojoHandle handle) {
20 assert(g_core);
21 return g_core->Close(handle);
24 MojoResult MojoWait(MojoHandle handle,
25 MojoWaitFlags flags,
26 MojoDeadline deadline) {
27 assert(g_core);
28 return g_core->Wait(handle, flags, deadline);
31 MojoResult MojoWaitMany(const MojoHandle* handles,
32 const MojoWaitFlags* flags,
33 uint32_t num_handles,
34 MojoDeadline deadline) {
35 assert(g_core);
36 return g_core->WaitMany(handles, flags, num_handles, deadline);
39 MojoResult MojoCreateMessagePipe(MojoHandle* message_pipe_handle0,
40 MojoHandle* message_pipe_handle1) {
41 assert(g_core);
42 return g_core->CreateMessagePipe(message_pipe_handle0, message_pipe_handle1);
45 MojoResult MojoWriteMessage(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 assert(g_core);
52 return g_core->WriteMessage(message_pipe_handle, bytes, num_bytes, handles,
53 num_handles, flags);
56 MojoResult MojoReadMessage(MojoHandle message_pipe_handle,
57 void* bytes,
58 uint32_t* num_bytes,
59 MojoHandle* handles,
60 uint32_t* num_handles,
61 MojoReadMessageFlags flags) {
62 assert(g_core);
63 return g_core->ReadMessage(message_pipe_handle, bytes, num_bytes, handles,
64 num_handles, flags);
67 MojoResult MojoCreateDataPipe(const MojoCreateDataPipeOptions* options,
68 MojoHandle* data_pipe_producer_handle,
69 MojoHandle* data_pipe_consumer_handle) {
70 assert(g_core);
71 return g_core->CreateDataPipe(options, data_pipe_producer_handle,
72 data_pipe_consumer_handle);
75 MojoResult MojoWriteData(MojoHandle data_pipe_producer_handle,
76 const void* elements,
77 uint32_t* num_elements,
78 MojoWriteDataFlags flags) {
79 assert(g_core);
80 return g_core->WriteData(data_pipe_producer_handle, elements, num_elements,
81 flags);
84 MojoResult MojoBeginWriteData(MojoHandle data_pipe_producer_handle,
85 void** buffer,
86 uint32_t* buffer_num_elements,
87 MojoWriteDataFlags flags) {
88 assert(g_core);
89 return g_core->BeginWriteData(data_pipe_producer_handle, buffer,
90 buffer_num_elements, flags);
93 MojoResult MojoEndWriteData(MojoHandle data_pipe_producer_handle,
94 uint32_t num_elements_written) {
95 assert(g_core);
96 return g_core->EndWriteData(data_pipe_producer_handle, num_elements_written);
99 MojoResult MojoReadData(MojoHandle data_pipe_consumer_handle,
100 void* elements,
101 uint32_t* num_elements,
102 MojoReadDataFlags flags) {
103 assert(g_core);
104 return g_core->ReadData(data_pipe_consumer_handle, elements, num_elements,
105 flags);
108 MojoResult MojoBeginReadData(MojoHandle data_pipe_consumer_handle,
109 const void** buffer,
110 uint32_t* buffer_num_elements,
111 MojoReadDataFlags flags) {
112 assert(g_core);
113 return g_core->BeginReadData(data_pipe_consumer_handle, buffer,
114 buffer_num_elements, flags);
117 MojoResult MojoEndReadData(MojoHandle data_pipe_consumer_handle,
118 uint32_t num_elements_read) {
119 assert(g_core);
120 return g_core->EndReadData(data_pipe_consumer_handle, num_elements_read);
123 MojoResult MojoCreateSharedBuffer(
124 const struct MojoCreateSharedBufferOptions* options,
125 uint64_t* num_bytes,
126 MojoHandle* shared_buffer_handle) {
127 assert(g_core);
128 return g_core->CreateSharedBuffer(options, num_bytes, shared_buffer_handle);
131 MojoResult MojoDuplicateBufferHandle(
132 MojoHandle buffer_handle,
133 const struct MojoDuplicateBufferHandleOptions* options,
134 MojoHandle* new_buffer_handle) {
135 assert(g_core);
136 return g_core->DuplicateBufferHandle(buffer_handle, options,
137 new_buffer_handle);
140 MojoResult MojoMapBuffer(MojoHandle buffer_handle,
141 uint64_t offset,
142 uint64_t num_bytes,
143 void** buffer,
144 MojoMapBufferFlags flags) {
145 assert(g_core);
146 return g_core->MapBuffer(buffer_handle, offset, num_bytes, buffer, flags);
149 MojoResult MojoUnmapBuffer(void* buffer) {
150 assert(g_core);
151 return g_core->UnmapBuffer(buffer);
154 } // extern "C"
156 namespace mojo {
158 Core::~Core() {
161 // static
162 void Core::Init(Core* core) {
163 assert(!g_core);
164 g_core = core;
167 // static
168 Core* Core::Get() {
169 return g_core;
172 // static
173 void Core::Reset() {
174 g_core = NULL;
177 } // namespace mojo