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

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

Issue 2183703005: Renderers should obtain browser InterfaceProvider by connecting to browser (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
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_registry_android_impl.h" 5 #include "content/browser/android/interface_registry_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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "content/public/browser/browser_thread.h"
13 #include "jni/InterfaceRegistry_jni.h" 14 #include "jni/InterfaceRegistry_jni.h"
14 #include "mojo/public/cpp/system/message_pipe.h" 15 #include "mojo/public/cpp/system/message_pipe.h"
15 #include "services/shell/public/cpp/interface_provider.h" 16 #include "services/shell/public/cpp/interface_provider.h"
16 #include "services/shell/public/cpp/interface_registry.h" 17 #include "services/shell/public/cpp/interface_registry.h"
17 18
18 using base::android::AttachCurrentThread; 19 using base::android::AttachCurrentThread;
19 using base::android::ConvertJavaStringToUTF8; 20 using base::android::ConvertJavaStringToUTF8;
20 using base::android::ScopedJavaGlobalRef; 21 using base::android::ScopedJavaGlobalRef;
21 22
22 namespace content { 23 namespace content {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 ScopedJavaGlobalRef<jobject> j_scoped_interface_registry; 82 ScopedJavaGlobalRef<jobject> j_scoped_interface_registry;
82 j_scoped_interface_registry.Reset(env, j_interface_registry); 83 j_scoped_interface_registry.Reset(env, j_interface_registry);
83 84
84 ScopedJavaGlobalRef<jobject> j_scoped_manager; 85 ScopedJavaGlobalRef<jobject> j_scoped_manager;
85 j_scoped_manager.Reset(env, j_manager); 86 j_scoped_manager.Reset(env, j_manager);
86 87
87 ScopedJavaGlobalRef<jobject> j_scoped_factory; 88 ScopedJavaGlobalRef<jobject> j_scoped_factory;
88 j_scoped_factory.Reset(env, j_factory); 89 j_scoped_factory.Reset(env, j_factory);
89 90
91 // All Java services must be bound on the main thread.
Ken Rockot(use gerrit already) 2016/07/29 17:09:45 nit: s/services/interfaces/
92 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
93 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
90 interface_registry_->AddInterface( 94 interface_registry_->AddInterface(
91 name, base::Bind(&CreateImplAndAttach, j_scoped_interface_registry, 95 name,
92 j_scoped_manager, j_scoped_factory), 96 base::Bind(&CreateImplAndAttach, j_scoped_interface_registry,
93 nullptr); 97 j_scoped_manager, j_scoped_factory),
98 ui_task_runner);
94 } 99 }
95 100
96 void InterfaceRegistryAndroidImpl::RemoveInterface( 101 void InterfaceRegistryAndroidImpl::RemoveInterface(
97 JNIEnv* env, 102 JNIEnv* env,
98 const JavaParamRef<jobject>& j_interface_registry, 103 const JavaParamRef<jobject>& j_interface_registry,
99 const JavaParamRef<jstring>& j_name) { 104 const JavaParamRef<jstring>& j_name) {
100 std::string name(ConvertJavaStringToUTF8(env, j_name)); 105 std::string name(ConvertJavaStringToUTF8(env, j_name));
101 interface_registry_->RemoveInterface(name); 106 interface_registry_->RemoveInterface(name);
102 } 107 }
103 108
104 } // namespace content 109 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698