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

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

Issue 2069663002: Some scoped_ptr -> std::unique_ptr conversion, especially under //mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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
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 <memory>
8
7 #include "base/android/base_jni_registrar.h" 9 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
9 #include "base/android/jni_registrar.h" 11 #include "base/android/jni_registrar.h"
10 #include "base/android/library_loader/library_loader_hooks.h" 12 #include "base/android/library_loader/library_loader_hooks.h"
11 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "jni/CoreImpl_jni.h" 16 #include "jni/CoreImpl_jni.h"
16 #include "mojo/public/c/environment/async_waiter.h" 17 #include "mojo/public/c/environment/async_waiter.h"
17 #include "mojo/public/c/system/buffer.h" 18 #include "mojo/public/c/system/buffer.h"
18 #include "mojo/public/c/system/data_pipe.h" 19 #include "mojo/public/c/system/data_pipe.h"
19 #include "mojo/public/c/system/handle.h" 20 #include "mojo/public/c/system/handle.h"
20 #include "mojo/public/c/system/message_pipe.h" 21 #include "mojo/public/c/system/message_pipe.h"
21 #include "mojo/public/c/system/result.h" 22 #include "mojo/public/c/system/result.h"
22 #include "mojo/public/c/system/time.h" 23 #include "mojo/public/c/system/time.h"
23 #include "mojo/public/c/system/wait.h" 24 #include "mojo/public/c/system/wait.h"
24 #include "mojo/public/cpp/environment/environment.h" 25 #include "mojo/public/cpp/environment/environment.h"
25 26
26 namespace { 27 namespace {
27 28
28 // |AsyncWait| is guaranteed never to return 0. 29 // |AsyncWait| is guaranteed never to return 0.
29 const MojoAsyncWaitID kInvalidHandleCancelID = 0; 30 const MojoAsyncWaitID kInvalidHandleCancelID = 0;
30 31
31 struct AsyncWaitCallbackData { 32 struct AsyncWaitCallbackData {
32 base::android::ScopedJavaGlobalRef<jobject> core_impl; 33 base::android::ScopedJavaGlobalRef<jobject> core_impl;
33 base::android::ScopedJavaGlobalRef<jobject> callback; 34 base::android::ScopedJavaGlobalRef<jobject> callback;
34 base::android::ScopedJavaGlobalRef<jobject> cancellable; 35 base::android::ScopedJavaGlobalRef<jobject> cancellable;
35 36
36 AsyncWaitCallbackData(JNIEnv* env, jobject core_impl, jobject callback) { 37 AsyncWaitCallbackData(JNIEnv* env, jobject core_impl, jobject callback) {
37 this->core_impl.Reset(env, core_impl); 38 this->core_impl.Reset(env, core_impl);
38 this->callback.Reset(env, callback); 39 this->callback.Reset(env, callback);
39 } 40 }
40 }; 41 };
41 42
42 void AsyncWaitCallback(void* data, MojoResult result) { 43 void AsyncWaitCallback(void* data, MojoResult result) {
43 scoped_ptr<AsyncWaitCallbackData> callback_data( 44 std::unique_ptr<AsyncWaitCallbackData> callback_data(
44 static_cast<AsyncWaitCallbackData*>(data)); 45 static_cast<AsyncWaitCallbackData*>(data));
45 mojo::android::Java_CoreImpl_onAsyncWaitResult( 46 mojo::android::Java_CoreImpl_onAsyncWaitResult(
46 base::android::AttachCurrentThread(), 47 base::android::AttachCurrentThread(),
47 callback_data->core_impl.obj(), 48 callback_data->core_impl.obj(),
48 result, 49 result,
49 callback_data->callback.obj(), 50 callback_data->callback.obj(),
50 callback_data->cancellable.obj()); 51 callback_data->cancellable.obj());
51 } 52 }
52 53
53 } // namespace 54 } // namespace
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 static void CancelAsyncWait(JNIEnv* env, 394 static void CancelAsyncWait(JNIEnv* env,
394 const JavaParamRef<jobject>& jcaller, 395 const JavaParamRef<jobject>& jcaller,
395 jlong id, 396 jlong id,
396 jlong data_ptr) { 397 jlong data_ptr) {
397 if (id == 0) { 398 if (id == 0) {
398 // If |id| is |kInvalidHandleCancelID|, the async wait was done on an 399 // If |id| is |kInvalidHandleCancelID|, the async wait was done on an
399 // invalid handle, so the AsyncWaitCallback will be called and will clear 400 // invalid handle, so the AsyncWaitCallback will be called and will clear
400 // the data_ptr. 401 // the data_ptr.
401 return; 402 return;
402 } 403 }
403 scoped_ptr<AsyncWaitCallbackData> deleter( 404 std::unique_ptr<AsyncWaitCallbackData> deleter(
404 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); 405 reinterpret_cast<AsyncWaitCallbackData*>(data_ptr));
405 Environment::GetDefaultAsyncWaiter()->CancelWait(id); 406 Environment::GetDefaultAsyncWaiter()->CancelWait(id);
406 } 407 }
407 408
408 static jint GetNativeBufferOffset(JNIEnv* env, 409 static jint GetNativeBufferOffset(JNIEnv* env,
409 const JavaParamRef<jobject>& jcaller, 410 const JavaParamRef<jobject>& jcaller,
410 const JavaParamRef<jobject>& buffer, 411 const JavaParamRef<jobject>& buffer,
411 jint alignment) { 412 jint alignment) {
412 jint offset = 413 jint offset =
413 reinterpret_cast<uintptr_t>(env->GetDirectBufferAddress(buffer)) % 414 reinterpret_cast<uintptr_t>(env->GetDirectBufferAddress(buffer)) %
(...skipping 14 matching lines...) Expand all
428 return Java_CoreImpl_newResultAndBufferInformation( 429 return Java_CoreImpl_newResultAndBufferInformation(
429 env, result, buffer_information.flags, buffer_information.num_bytes); 430 env, result, buffer_information.flags, buffer_information.num_bytes);
430 } 431 }
431 432
432 bool RegisterCoreImpl(JNIEnv* env) { 433 bool RegisterCoreImpl(JNIEnv* env) {
433 return RegisterNativesImpl(env); 434 return RegisterNativesImpl(env);
434 } 435 }
435 436
436 } // namespace android 437 } // namespace android
437 } // namespace mojo 438 } // namespace mojo
OLDNEW
« no previous file with comments | « examples/recursive_content_handler/recursive_content_handler.cc ('k') | mojo/application/content_handler_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698