| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/android/interface_provider_android_impl.h" | 5 #include "content/browser/android/interface_provider_android_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 shell::InterfaceProvider* remote_interfaces) { | 27 shell::InterfaceProvider* remote_interfaces) { |
| 28 return base::WrapUnique(new InterfaceProviderAndroidImpl(remote_interfaces)); | 28 return base::WrapUnique(new InterfaceProviderAndroidImpl(remote_interfaces)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 bool InterfaceProviderAndroidImpl::Register(JNIEnv* env) { | 32 bool InterfaceProviderAndroidImpl::Register(JNIEnv* env) { |
| 33 return RegisterNativesImpl(env); | 33 return RegisterNativesImpl(env); |
| 34 } | 34 } |
| 35 | 35 |
| 36 InterfaceProviderAndroidImpl::~InterfaceProviderAndroidImpl() { | 36 InterfaceProviderAndroidImpl::~InterfaceProviderAndroidImpl() { |
| 37 Java_InterfaceProvider_destroy(AttachCurrentThread(), obj_.obj()); | 37 Java_InterfaceProvider_destroy(AttachCurrentThread(), obj_); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Constructor and destructor call into Java. | 40 // Constructor and destructor call into Java. |
| 41 InterfaceProviderAndroidImpl::InterfaceProviderAndroidImpl( | 41 InterfaceProviderAndroidImpl::InterfaceProviderAndroidImpl( |
| 42 shell::InterfaceProvider* remote_interfaces) | 42 shell::InterfaceProvider* remote_interfaces) |
| 43 : remote_interfaces_(remote_interfaces) { | 43 : remote_interfaces_(remote_interfaces) { |
| 44 JNIEnv* env = AttachCurrentThread(); | 44 JNIEnv* env = AttachCurrentThread(); |
| 45 obj_.Reset( | 45 obj_.Reset( |
| 46 env, | 46 env, |
| 47 Java_InterfaceProvider_create( | 47 Java_InterfaceProvider_create( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 JNIEnv* env, | 58 JNIEnv* env, |
| 59 const JavaParamRef<jobject>& j_interface_provider, | 59 const JavaParamRef<jobject>& j_interface_provider, |
| 60 const JavaParamRef<jstring>& j_name, | 60 const JavaParamRef<jstring>& j_name, |
| 61 jint j_handle) { | 61 jint j_handle) { |
| 62 std::string name(ConvertJavaStringToUTF8(env, j_name)); | 62 std::string name(ConvertJavaStringToUTF8(env, j_name)); |
| 63 mojo::ScopedMessagePipeHandle handle((mojo::MessagePipeHandle(j_handle))); | 63 mojo::ScopedMessagePipeHandle handle((mojo::MessagePipeHandle(j_handle))); |
| 64 remote_interfaces_->GetInterface(name, std::move(handle)); | 64 remote_interfaces_->GetInterface(name, std::move(handle)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace content | 67 } // namespace content |
| OLD | NEW |