Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "mojo/public/system/core_private.h" | |
| 6 | |
| 7 #include <assert.h> | |
| 8 | |
| 9 static mojo::Core* g_core = 0; | |
|
viettrungluu
2013/12/09 22:04:25
Nit: We usually use NULL (which may necessitate in
abarth-chromium
2013/12/09 22:48:34
Done.
| |
| 10 | |
| 11 extern "C" { | |
| 12 | |
| 13 MojoResult MojoClose(MojoHandle handle) { | |
|
viettrungluu
2013/12/09 19:25:59
Can't we just replace these with function pointers
abarth-chromium
2013/12/09 21:19:34
We could do that. What would we gain by doing tha
| |
| 14 assert(g_core); | |
| 15 return g_core->Close(handle); | |
| 16 } | |
| 17 | |
| 18 MojoResult MojoWait(MojoHandle handle, | |
| 19 MojoWaitFlags flags, | |
| 20 MojoDeadline deadline) { | |
| 21 assert(g_core); | |
| 22 return g_core->Wait(handle, flags, deadline); | |
| 23 } | |
| 24 | |
| 25 MojoResult MojoWaitMany(const MojoHandle* handles, | |
| 26 const MojoWaitFlags* flags, | |
| 27 uint32_t num_handles, | |
| 28 MojoDeadline deadline) { | |
| 29 assert(g_core); | |
| 30 return g_core->WaitMany(handles, flags, num_handles, deadline); | |
| 31 } | |
| 32 | |
| 33 MojoResult MojoCreateMessagePipe(MojoHandle* handle_0, MojoHandle* handle_1) { | |
| 34 assert(g_core); | |
| 35 return g_core->CreateMessagePipe(handle_0, handle_1); | |
| 36 } | |
| 37 | |
| 38 MojoResult MojoWriteMessage(MojoHandle handle, | |
| 39 const void* bytes, uint32_t num_bytes, | |
| 40 const MojoHandle* handles, uint32_t num_handles, | |
| 41 MojoWriteMessageFlags flags) { | |
| 42 assert(g_core); | |
| 43 return g_core->WriteMessage(handle, | |
| 44 bytes, num_bytes, | |
| 45 handles, num_handles, | |
| 46 flags); | |
| 47 } | |
| 48 | |
| 49 MojoResult MojoReadMessage(MojoHandle handle, | |
| 50 void* bytes, uint32_t* num_bytes, | |
| 51 MojoHandle* handles, uint32_t* num_handles, | |
| 52 MojoReadMessageFlags flags) { | |
| 53 assert(g_core); | |
| 54 return g_core->ReadMessage(handle, | |
| 55 bytes, num_bytes, | |
| 56 handles, num_handles, | |
| 57 flags); | |
| 58 } | |
| 59 | |
| 60 MojoTimeTicks MojoGetTimeTicksNow() { | |
| 61 assert(g_core); | |
| 62 return g_core->GetTimeTicksNow(); | |
| 63 } | |
| 64 | |
| 65 } // extern "C" | |
| 66 | |
| 67 namespace mojo { | |
| 68 | |
| 69 Core::~Core() { | |
| 70 } | |
| 71 | |
| 72 void Core::Init(Core* core) { | |
| 73 assert(!g_core); | |
| 74 g_core = core; | |
| 75 } | |
| 76 | |
| 77 } // namespace mojo | |
| OLD | NEW |