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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const size_t buffer_size = env->GetDirectBufferCapacity(buffer); | 68 const size_t buffer_size = env->GetDirectBufferCapacity(buffer); |
69 DCHECK_EQ(buffer_size % record_size, 0u); | 69 DCHECK_EQ(buffer_size % record_size, 0u); |
70 | 70 |
71 const size_t nb_handles = buffer_size / record_size; | 71 const size_t nb_handles = buffer_size / record_size; |
72 const MojoHandle* handle_start = static_cast<const MojoHandle*>(buffer_start); | 72 const MojoHandle* handle_start = static_cast<const MojoHandle*>(buffer_start); |
73 const MojoHandleSignals* signals_start = | 73 const MojoHandleSignals* signals_start = |
74 static_cast<const MojoHandleSignals*>(handle_start + nb_handles); | 74 static_cast<const MojoHandleSignals*>(handle_start + nb_handles); |
75 return MojoWaitMany(handle_start, signals_start, nb_handles, deadline); | 75 return MojoWaitMany(handle_start, signals_start, nb_handles, deadline); |
76 } | 76 } |
77 | 77 |
78 static jobject CreateMessagePipe(JNIEnv* env, jobject jcaller) { | 78 static jobject CreateMessagePipe(JNIEnv* env, |
| 79 jobject jcaller, |
| 80 jobject options_buffer) { |
| 81 const MojoCreateMessagePipeOptions* options = NULL; |
| 82 if (options_buffer) { |
| 83 const void* buffer_start = env->GetDirectBufferAddress(options_buffer); |
| 84 DCHECK(buffer_start); |
| 85 const size_t buffer_size = env->GetDirectBufferCapacity(options_buffer); |
| 86 DCHECK_EQ(buffer_size, sizeof(MojoCreateMessagePipeOptions)); |
| 87 options = static_cast<const MojoCreateMessagePipeOptions*>(buffer_start); |
| 88 DCHECK_EQ(options->struct_size, buffer_size); |
| 89 } |
79 MojoHandle handle1; | 90 MojoHandle handle1; |
80 MojoHandle handle2; | 91 MojoHandle handle2; |
81 // TODO(vtl): Add support for the options struct. | 92 MojoResult result = MojoCreateMessagePipe(options, &handle1, &handle2); |
82 MojoResult result = MojoCreateMessagePipe(NULL, &handle1, &handle2); | |
83 return Java_CoreImpl_newNativeCreationResult(env, result, handle1, handle2) | 93 return Java_CoreImpl_newNativeCreationResult(env, result, handle1, handle2) |
84 .Release(); | 94 .Release(); |
85 } | 95 } |
86 | 96 |
87 static jobject CreateDataPipe(JNIEnv* env, | 97 static jobject CreateDataPipe(JNIEnv* env, |
88 jobject jcaller, | 98 jobject jcaller, |
89 jobject options_buffer) { | 99 jobject options_buffer) { |
90 const MojoCreateDataPipeOptions* options = NULL; | 100 const MojoCreateDataPipeOptions* options = NULL; |
91 if (options_buffer) { | 101 if (options_buffer) { |
92 const void* buffer_start = env->GetDirectBufferAddress(options_buffer); | 102 const void* buffer_start = env->GetDirectBufferAddress(options_buffer); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); | 369 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); |
360 mojo::Environment::GetDefaultAsyncWaiter()->CancelWait(id); | 370 mojo::Environment::GetDefaultAsyncWaiter()->CancelWait(id); |
361 } | 371 } |
362 | 372 |
363 bool RegisterCoreImpl(JNIEnv* env) { | 373 bool RegisterCoreImpl(JNIEnv* env) { |
364 return RegisterNativesImpl(env); | 374 return RegisterNativesImpl(env); |
365 } | 375 } |
366 | 376 |
367 } // namespace android | 377 } // namespace android |
368 } // namespace mojo | 378 } // namespace mojo |
OLD | NEW |