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

Side by Side Diff: content/browser/android/interface_provider_android_impl.cc

Issue 2217013002: Remove the JNI-based InterfaceRegistry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@java-interface-registry-migration
Patch Set: rebase Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/android/interface_provider_android_impl.h"
6
7 #include <utility>
8
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h"
11 #include "base/callback.h"
12 #include "base/memory/ptr_util.h"
13 #include "jni/InterfaceProvider_jni.h"
14 #include "mojo/public/cpp/system/message_pipe.h"
15 #include "services/shell/public/cpp/interface_provider.h"
16 #include "services/shell/public/cpp/interface_registry.h"
17
18 using base::android::AttachCurrentThread;
19 using base::android::ConvertJavaStringToUTF8;
20 using base::android::JavaParamRef;
21 using base::android::ScopedJavaGlobalRef;
22
23 namespace content {
24
25 // static
26 std::unique_ptr<InterfaceProviderAndroid> InterfaceProviderAndroid::Create(
27 shell::InterfaceProvider* remote_interfaces) {
28 return base::WrapUnique(new InterfaceProviderAndroidImpl(remote_interfaces));
29 }
30
31 // static
32 bool InterfaceProviderAndroidImpl::Register(JNIEnv* env) {
33 return RegisterNativesImpl(env);
34 }
35
36 InterfaceProviderAndroidImpl::~InterfaceProviderAndroidImpl() {
37 Java_InterfaceProvider_destroy(AttachCurrentThread(), obj_);
38 }
39
40 // Constructor and destructor call into Java.
41 InterfaceProviderAndroidImpl::InterfaceProviderAndroidImpl(
42 shell::InterfaceProvider* remote_interfaces)
43 : remote_interfaces_(remote_interfaces) {
44 JNIEnv* env = AttachCurrentThread();
45 obj_.Reset(
46 env,
47 Java_InterfaceProvider_create(
48 env, reinterpret_cast<intptr_t>(this)).obj());
49 }
50
51 const base::android::ScopedJavaGlobalRef<jobject>&
52 InterfaceProviderAndroidImpl::GetObj() {
53 return obj_;
54 }
55
56 // Methods called from Java.
57 void InterfaceProviderAndroidImpl::GetInterface(
58 JNIEnv* env,
59 const JavaParamRef<jobject>& j_interface_provider,
60 const JavaParamRef<jstring>& j_name,
61 jint j_handle) {
62 std::string name(ConvertJavaStringToUTF8(env, j_name));
63 mojo::ScopedMessagePipeHandle handle((mojo::MessagePipeHandle(j_handle)));
64 remote_interfaces_->GetInterface(name, std::move(handle));
65 }
66
67 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/interface_provider_android_impl.h ('k') | content/browser/android/interface_registry_android_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698