OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "android_webview/native/aw_message_port_service_impl.h" | 5 #include "android_webview/native/aw_message_port_service_impl.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_message_port_message_filter.h" | 8 #include "android_webview/browser/aw_message_port_message_filter.h" |
9 #include "android_webview/native/aw_contents.h" | 9 #include "android_webview/native/aw_contents.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void AwMessagePortServiceImpl::OnMessageChannelCreated( | 208 void AwMessagePortServiceImpl::OnMessageChannelCreated( |
209 ScopedJavaGlobalRef<jobjectArray>* ports, | 209 ScopedJavaGlobalRef<jobjectArray>* ports, |
210 int* port1, | 210 int* port1, |
211 int* port2) { | 211 int* port2) { |
212 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 212 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
213 JNIEnv* env = AttachCurrentThread(); | 213 JNIEnv* env = AttachCurrentThread(); |
214 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 214 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
215 if (obj.is_null()) | 215 if (obj.is_null()) |
216 return; | 216 return; |
217 Java_AwMessagePortService_onMessageChannelCreated(env, obj, *port1, *port2, | 217 Java_AwMessagePortService_onMessageChannelCreated(env, obj, *port1, *port2, |
218 ports->obj()); | 218 *ports); |
219 } | 219 } |
220 | 220 |
221 // Adds a new port to the message port service. | 221 // Adds a new port to the message port service. |
222 void AwMessagePortServiceImpl::AddPort(int message_port_id, | 222 void AwMessagePortServiceImpl::AddPort(int message_port_id, |
223 AwMessagePortMessageFilter* filter) { | 223 AwMessagePortMessageFilter* filter) { |
224 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 224 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
225 if (ports_.count(message_port_id)) { | 225 if (ports_.count(message_port_id)) { |
226 NOTREACHED(); | 226 NOTREACHED(); |
227 return; | 227 return; |
228 } | 228 } |
229 ports_[message_port_id] = filter; | 229 ports_[message_port_id] = filter; |
230 } | 230 } |
231 | 231 |
232 bool RegisterAwMessagePortService(JNIEnv* env) { | 232 bool RegisterAwMessagePortService(JNIEnv* env) { |
233 return RegisterNativesImpl(env); | 233 return RegisterNativesImpl(env); |
234 } | 234 } |
235 | 235 |
236 // static | 236 // static |
237 jlong InitAwMessagePortService(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 237 jlong InitAwMessagePortService(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
238 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); | 238 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); |
239 service->Init(env, obj); | 239 service->Init(env, obj); |
240 return reinterpret_cast<intptr_t>(service); | 240 return reinterpret_cast<intptr_t>(service); |
241 } | 241 } |
242 | 242 |
243 } // namespace android_webview | 243 } // namespace android_webview |
OLD | NEW |