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

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

Issue 2191033002: Split ServiceRegistryAndroid into InterfaceRegistryAndroid and InterfaceProviderAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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::ScopedJavaGlobalRef;
21
22 namespace content {
23
24 // static
25 std::unique_ptr<InterfaceProviderAndroid> InterfaceProviderAndroid::Create(
26 shell::InterfaceProvider* remote_interfaces) {
27 return base::WrapUnique(new InterfaceProviderAndroidImpl(remote_interfaces));
28 }
29
30 // static
31 bool InterfaceProviderAndroidImpl::Register(JNIEnv* env) {
32 return RegisterNativesImpl(env);
33 }
34
35 InterfaceProviderAndroidImpl::~InterfaceProviderAndroidImpl() {
36 Java_InterfaceProvider_destroy(AttachCurrentThread(), obj_.obj());
37 }
38
39 // Constructor and destructor call into Java.
40 InterfaceProviderAndroidImpl::InterfaceProviderAndroidImpl(
41 shell::InterfaceProvider* remote_interfaces)
42 : remote_interfaces_(remote_interfaces) {
43 JNIEnv* env = AttachCurrentThread();
44 obj_.Reset(
45 env,
46 Java_InterfaceProvider_create(
47 env, reinterpret_cast<intptr_t>(this)).obj());
48 }
49
50 const base::android::ScopedJavaGlobalRef<jobject>&
51 InterfaceProviderAndroidImpl::GetObj() {
52 return obj_;
53 }
54
55 // Methods called from Java.
56 void InterfaceProviderAndroidImpl::GetInterface(
57 JNIEnv* env,
58 const JavaParamRef<jobject>& j_interface_provider,
59 const JavaParamRef<jstring>& j_name,
60 jint j_handle) {
61 std::string name(ConvertJavaStringToUTF8(env, j_name));
62 mojo::ScopedMessagePipeHandle handle((mojo::MessagePipeHandle(j_handle)));
63 remote_interfaces_->GetInterface(name, std::move(handle));
64 }
65
66 } // 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