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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 base::string16 value; | 92 base::string16 value; |
93 if (!message.GetString(0, &value)) { | 93 if (!message.GetString(0, &value)) { |
94 LOG(WARNING) << "Converting post message to a string failed for port " | 94 LOG(WARNING) << "Converting post message to a string failed for port " |
95 << message_port_id; | 95 << message_port_id; |
96 return; | 96 return; |
97 } | 97 } |
98 ScopedJavaLocalRef<jstring> jmsg = ConvertUTF16ToJavaString(env, value); | 98 ScopedJavaLocalRef<jstring> jmsg = ConvertUTF16ToJavaString(env, value); |
99 ScopedJavaLocalRef<jintArray> jports = | 99 ScopedJavaLocalRef<jintArray> jports = |
100 ToJavaIntArray(env, sent_message_port_ids); | 100 ToJavaIntArray(env, sent_message_port_ids); |
101 Java_AwMessagePortService_onPostMessage(env, | 101 Java_AwMessagePortService_onReceivedMessage(env, |
102 jobj.obj(), | 102 jobj.obj(), |
103 message_port_id, | 103 message_port_id, |
104 jmsg.obj(), | 104 jmsg.obj(), |
105 jports.obj()); | 105 jports.obj()); |
106 } | 106 } |
107 | 107 |
108 void AwMessagePortServiceImpl::OnMessagePortMessageFilterClosing( | 108 void AwMessagePortServiceImpl::OnMessagePortMessageFilterClosing( |
109 AwMessagePortMessageFilter* filter) { | 109 AwMessagePortMessageFilter* filter) { |
110 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 110 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
111 for (MessagePorts::iterator iter = ports_.begin(); | 111 for (MessagePorts::iterator iter = ports_.begin(); |
112 iter != ports_.end(); iter++) { | 112 iter != ports_.end(); iter++) { |
113 if (iter->second == filter) { | 113 if (iter->second == filter) { |
114 ports_.erase(iter); | 114 ports_.erase(iter); |
115 } | 115 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 | 214 |
215 // static | 215 // static |
216 jlong InitAwMessagePortService(JNIEnv* env, jobject obj) { | 216 jlong InitAwMessagePortService(JNIEnv* env, jobject obj) { |
217 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); | 217 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); |
218 service->Init(env, obj); | 218 service->Init(env, obj); |
219 return reinterpret_cast<intptr_t>(service); | 219 return reinterpret_cast<intptr_t>(service); |
220 } | 220 } |
221 | 221 |
222 } // namespace android_webview | 222 } // namespace android_webview |
OLD | NEW |