OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/android/system/core_impl.h" | 5 #include "mojo/android/system/core_impl.h" |
6 | 6 |
7 #include "base/android/base_jni_registrar.h" | 7 #include "base/android/base_jni_registrar.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_registrar.h" | 9 #include "base/android/jni_registrar.h" |
10 #include "base/android/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const size_t nb_handles = (buffer_size - 4) / size_per_handle; | 77 const size_t nb_handles = (buffer_size - 4) / size_per_handle; |
78 const MojoHandle* handle_start = | 78 const MojoHandle* handle_start = |
79 reinterpret_cast<const MojoHandle*>(buffer_start); | 79 reinterpret_cast<const MojoHandle*>(buffer_start); |
80 const MojoHandleSignals* signals_start = | 80 const MojoHandleSignals* signals_start = |
81 reinterpret_cast<const MojoHandleSignals*>(buffer_start + 4 * nb_handles); | 81 reinterpret_cast<const MojoHandleSignals*>(buffer_start + 4 * nb_handles); |
82 MojoHandleSignalsState* states_start = | 82 MojoHandleSignalsState* states_start = |
83 reinterpret_cast<MojoHandleSignalsState*>(buffer_start + 8 * nb_handles); | 83 reinterpret_cast<MojoHandleSignalsState*>(buffer_start + 8 * nb_handles); |
84 uint32_t* result_index = | 84 uint32_t* result_index = |
85 reinterpret_cast<uint32_t*>(buffer_start + 16 * nb_handles); | 85 reinterpret_cast<uint32_t*>(buffer_start + 16 * nb_handles); |
86 *result_index = static_cast<uint32_t>(-1); | 86 *result_index = static_cast<uint32_t>(-1); |
87 return MojoNewWaitMany(handle_start, signals_start, nb_handles, deadline, | 87 return MojoWaitMany(handle_start, signals_start, nb_handles, deadline, |
88 result_index, states_start); | 88 result_index, states_start); |
89 } | 89 } |
90 | 90 |
91 static jobject CreateMessagePipe(JNIEnv* env, | 91 static jobject CreateMessagePipe(JNIEnv* env, |
92 jobject jcaller, | 92 jobject jcaller, |
93 jobject options_buffer) { | 93 jobject options_buffer) { |
94 const MojoCreateMessagePipeOptions* options = NULL; | 94 const MojoCreateMessagePipeOptions* options = NULL; |
95 if (options_buffer) { | 95 if (options_buffer) { |
96 const void* buffer_start = env->GetDirectBufferAddress(options_buffer); | 96 const void* buffer_start = env->GetDirectBufferAddress(options_buffer); |
97 DCHECK(buffer_start); | 97 DCHECK(buffer_start); |
98 DCHECK_EQ(reinterpret_cast<const uintptr_t>(buffer_start) % 8, 0u); | 98 DCHECK_EQ(reinterpret_cast<const uintptr_t>(buffer_start) % 8, 0u); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 jint signals, | 159 jint signals, |
160 jlong deadline) { | 160 jlong deadline) { |
161 // Buffer contains space for the MojoHandleSignalsState | 161 // Buffer contains space for the MojoHandleSignalsState |
162 void* buffer_start = env->GetDirectBufferAddress(buffer); | 162 void* buffer_start = env->GetDirectBufferAddress(buffer); |
163 DCHECK(buffer_start); | 163 DCHECK(buffer_start); |
164 DCHECK_EQ(reinterpret_cast<const uintptr_t>(buffer_start) % 8, 0u); | 164 DCHECK_EQ(reinterpret_cast<const uintptr_t>(buffer_start) % 8, 0u); |
165 DCHECK_EQ(sizeof(struct MojoHandleSignalsState), | 165 DCHECK_EQ(sizeof(struct MojoHandleSignalsState), |
166 static_cast<size_t>(env->GetDirectBufferCapacity(buffer))); | 166 static_cast<size_t>(env->GetDirectBufferCapacity(buffer))); |
167 struct MojoHandleSignalsState* signals_state = | 167 struct MojoHandleSignalsState* signals_state = |
168 static_cast<struct MojoHandleSignalsState*>(buffer_start); | 168 static_cast<struct MojoHandleSignalsState*>(buffer_start); |
169 return MojoNewWait(mojo_handle, signals, deadline, signals_state); | 169 return MojoWait(mojo_handle, signals, deadline, signals_state); |
170 } | 170 } |
171 | 171 |
172 static jint WriteMessage(JNIEnv* env, | 172 static jint WriteMessage(JNIEnv* env, |
173 jobject jcaller, | 173 jobject jcaller, |
174 jint mojo_handle, | 174 jint mojo_handle, |
175 jobject bytes, | 175 jobject bytes, |
176 jint num_bytes, | 176 jint num_bytes, |
177 jobject handles_buffer, | 177 jobject handles_buffer, |
178 jint flags) { | 178 jint flags) { |
179 const void* buffer_start = 0; | 179 const void* buffer_start = 0; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); | 394 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); |
395 Environment::GetDefaultAsyncWaiter()->CancelWait(id); | 395 Environment::GetDefaultAsyncWaiter()->CancelWait(id); |
396 } | 396 } |
397 | 397 |
398 bool RegisterCoreImpl(JNIEnv* env) { | 398 bool RegisterCoreImpl(JNIEnv* env) { |
399 return RegisterNativesImpl(env); | 399 return RegisterNativesImpl(env); |
400 } | 400 } |
401 | 401 |
402 } // namespace android | 402 } // namespace android |
403 } // namespace mojo | 403 } // namespace mojo |
OLD | NEW |