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

Side by Side Diff: mojo/android/system/core_impl.cc

Issue 345463003: Mojo: MojoWaitFlags -> MojoHandleSignals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/bindings/js/core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 jlong deadline) { 63 jlong deadline) {
64 // Buffer contains first the list of handles, then the list of flags. 64 // Buffer contains first the list of handles, then the list of flags.
65 const void* buffer_start = env->GetDirectBufferAddress(buffer); 65 const void* buffer_start = env->GetDirectBufferAddress(buffer);
66 DCHECK(buffer_start); 66 DCHECK(buffer_start);
67 const size_t record_size = 8; 67 const size_t record_size = 8;
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 MojoWaitFlags* flags_start = 73 const MojoHandleSignals* signals_start =
74 static_cast<const MojoWaitFlags*>(handle_start + nb_handles); 74 static_cast<const MojoHandleSignals*>(handle_start + nb_handles);
75 return MojoWaitMany(handle_start, flags_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, jobject jcaller) {
79 MojoHandle handle1; 79 MojoHandle handle1;
80 MojoHandle handle2; 80 MojoHandle handle2;
81 // TODO(vtl): Add support for the options struct. 81 // TODO(vtl): Add support for the options struct.
82 MojoResult result = MojoCreateMessagePipe(NULL, &handle1, &handle2); 82 MojoResult result = MojoCreateMessagePipe(NULL, &handle1, &handle2);
83 return Java_CoreImpl_newNativeCreationResult(env, result, handle1, handle2) 83 return Java_CoreImpl_newNativeCreationResult(env, result, handle1, handle2)
84 .Release(); 84 .Release();
85 } 85 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 .Release(); 122 .Release();
123 } 123 }
124 124
125 static jint Close(JNIEnv* env, jobject jcaller, jint mojo_handle) { 125 static jint Close(JNIEnv* env, jobject jcaller, jint mojo_handle) {
126 return MojoClose(mojo_handle); 126 return MojoClose(mojo_handle);
127 } 127 }
128 128
129 static jint Wait(JNIEnv* env, 129 static jint Wait(JNIEnv* env,
130 jobject jcaller, 130 jobject jcaller,
131 jint mojo_handle, 131 jint mojo_handle,
132 jint flags, 132 jint signals,
133 jlong deadline) { 133 jlong deadline) {
134 return MojoWait(mojo_handle, flags, deadline); 134 return MojoWait(mojo_handle, signals, deadline);
135 } 135 }
136 136
137 static jint WriteMessage(JNIEnv* env, 137 static jint WriteMessage(JNIEnv* env,
138 jobject jcaller, 138 jobject jcaller,
139 jint mojo_handle, 139 jint mojo_handle,
140 jobject bytes, 140 jobject bytes,
141 jint num_bytes, 141 jint num_bytes,
142 jobject handles_buffer, 142 jobject handles_buffer,
143 jint flags) { 143 jint flags) {
144 const void* buffer_start = 0; 144 const void* buffer_start = 0;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 static int Unmap(JNIEnv* env, jobject jcaller, jobject buffer) { 316 static int Unmap(JNIEnv* env, jobject jcaller, jobject buffer) {
317 void* buffer_start = env->GetDirectBufferAddress(buffer); 317 void* buffer_start = env->GetDirectBufferAddress(buffer);
318 DCHECK(buffer_start); 318 DCHECK(buffer_start);
319 return MojoUnmapBuffer(buffer_start); 319 return MojoUnmapBuffer(buffer_start);
320 } 320 }
321 321
322 static jobject AsyncWait(JNIEnv* env, 322 static jobject AsyncWait(JNIEnv* env,
323 jobject jcaller, 323 jobject jcaller,
324 jint mojo_handle, 324 jint mojo_handle,
325 jint flags, 325 jint signals,
326 jlong deadline, 326 jlong deadline,
327 jobject callback) { 327 jobject callback) {
328 AsyncWaitCallbackData* callback_data = 328 AsyncWaitCallbackData* callback_data =
329 new AsyncWaitCallbackData(env, jcaller, callback); 329 new AsyncWaitCallbackData(env, jcaller, callback);
330 MojoAsyncWaitID cancel_id; 330 MojoAsyncWaitID cancel_id;
331 if (static_cast<MojoHandle>(mojo_handle) != MOJO_HANDLE_INVALID) { 331 if (static_cast<MojoHandle>(mojo_handle) != MOJO_HANDLE_INVALID) {
332 cancel_id = mojo::GetDefaultAsyncWaiter()->AsyncWait(mojo_handle, 332 cancel_id = mojo::GetDefaultAsyncWaiter()->AsyncWait(mojo_handle,
333 flags, 333 signals,
334 deadline, 334 deadline,
335 AsyncWaitCallback, 335 AsyncWaitCallback,
336 callback_data); 336 callback_data);
337 } else { 337 } else {
338 cancel_id = kInvalidHandleCancelID; 338 cancel_id = kInvalidHandleCancelID;
339 base::MessageLoop::current()->PostTask( 339 base::MessageLoop::current()->PostTask(
340 FROM_HERE, 340 FROM_HERE,
341 base::Bind( 341 base::Bind(
342 &AsyncWaitCallback, callback_data, MOJO_RESULT_INVALID_ARGUMENT)); 342 &AsyncWaitCallback, callback_data, MOJO_RESULT_INVALID_ARGUMENT));
343 } 343 }
(...skipping 18 matching lines...) Expand all
362 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); 362 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr));
363 mojo::GetDefaultAsyncWaiter()->CancelWait(id); 363 mojo::GetDefaultAsyncWaiter()->CancelWait(id);
364 } 364 }
365 365
366 bool RegisterCoreImpl(JNIEnv* env) { 366 bool RegisterCoreImpl(JNIEnv* env) {
367 return RegisterNativesImpl(env); 367 return RegisterNativesImpl(env);
368 } 368 }
369 369
370 } // namespace android 370 } // namespace android
371 } // namespace mojo 371 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/bindings/js/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698