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

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

Issue 1058143002: Fix Android for positive MojoResults. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 5 years, 8 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 jint flags) { 231 jint flags) {
232 void* buffer_start = 0; 232 void* buffer_start = 0;
233 uint32_t buffer_size = elements_capacity; 233 uint32_t buffer_size = elements_capacity;
234 if (elements) { 234 if (elements) {
235 buffer_start = env->GetDirectBufferAddress(elements); 235 buffer_start = env->GetDirectBufferAddress(elements);
236 DCHECK(buffer_start); 236 DCHECK(buffer_start);
237 DCHECK(elements_capacity <= env->GetDirectBufferCapacity(elements)); 237 DCHECK(elements_capacity <= env->GetDirectBufferCapacity(elements));
238 } 238 }
239 MojoResult result = 239 MojoResult result =
240 MojoReadData(mojo_handle, buffer_start, &buffer_size, flags); 240 MojoReadData(mojo_handle, buffer_start, &buffer_size, flags);
241 if (result < 0) { 241 if (result != MOJO_RESULT_OK) {
242 return result; 242 return result;
243 } 243 }
244 return buffer_size; 244 return buffer_size;
viettrungluu 2015/04/02 23:02:42 This is very wrong.
245 } 245 }
246 246
247 static jobject BeginReadData(JNIEnv* env, 247 static jobject BeginReadData(JNIEnv* env,
248 jobject jcaller, 248 jobject jcaller,
249 jint mojo_handle, 249 jint mojo_handle,
250 jint num_bytes, 250 jint num_bytes,
251 jint flags) { 251 jint flags) {
252 void const* buffer = 0; 252 void const* buffer = 0;
253 uint32_t buffer_size = num_bytes; 253 uint32_t buffer_size = num_bytes;
254 MojoResult result = 254 MojoResult result =
(...skipping 19 matching lines...) Expand all
274 jint mojo_handle, 274 jint mojo_handle,
275 jobject elements, 275 jobject elements,
276 jint limit, 276 jint limit,
277 jint flags) { 277 jint flags) {
278 void* buffer_start = env->GetDirectBufferAddress(elements); 278 void* buffer_start = env->GetDirectBufferAddress(elements);
279 DCHECK(buffer_start); 279 DCHECK(buffer_start);
280 DCHECK(limit <= env->GetDirectBufferCapacity(elements)); 280 DCHECK(limit <= env->GetDirectBufferCapacity(elements));
281 uint32_t buffer_size = limit; 281 uint32_t buffer_size = limit;
282 MojoResult result = 282 MojoResult result =
283 MojoWriteData(mojo_handle, buffer_start, &buffer_size, flags); 283 MojoWriteData(mojo_handle, buffer_start, &buffer_size, flags);
284 if (result < 0) { 284 if (result != MOJO_RESULT_OK) {
285 return result; 285 return result;
286 } 286 }
287 return buffer_size; 287 return buffer_size;
viettrungluu 2015/04/02 23:02:42 "
288 } 288 }
289 289
290 static jobject BeginWriteData(JNIEnv* env, 290 static jobject BeginWriteData(JNIEnv* env,
291 jobject jcaller, 291 jobject jcaller,
292 jint mojo_handle, 292 jint mojo_handle,
293 jint num_bytes, 293 jint num_bytes,
294 jint flags) { 294 jint flags) {
295 void* buffer = 0; 295 void* buffer = 0;
296 uint32_t buffer_size = num_bytes; 296 uint32_t buffer_size = num_bytes;
297 MojoResult result = 297 MojoResult result =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698