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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 int message_port_id) { | 143 int message_port_id) { |
144 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
145 BrowserThread::PostTask( | 145 BrowserThread::PostTask( |
146 BrowserThread::IO, | 146 BrowserThread::IO, |
147 FROM_HERE, | 147 FROM_HERE, |
148 base::Bind(&AwMessagePortServiceImpl::PostClosePortMessage, | 148 base::Bind(&AwMessagePortServiceImpl::PostClosePortMessage, |
149 base::Unretained(this), | 149 base::Unretained(this), |
150 message_port_id)); | 150 message_port_id)); |
151 } | 151 } |
152 | 152 |
153 void AwMessagePortServiceImpl::ReleaseMessages(JNIEnv* env, jobject obj, | |
154 int message_port_id) { | |
hush (inactive)
2015/03/06 22:32:37
int --> jint
| |
155 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
156 BrowserThread::PostTask( | |
157 BrowserThread::IO, | |
158 FROM_HERE, | |
159 base::Bind(&MessagePortProvider::ReleaseMessages, message_port_id)); | |
160 } | |
161 | |
153 void AwMessagePortServiceImpl::RemoveSentPorts( | 162 void AwMessagePortServiceImpl::RemoveSentPorts( |
154 const std::vector<int>& sent_ports) { | 163 const std::vector<int>& sent_ports) { |
155 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 164 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
156 // Remove the filters that are associated with the transferred ports | 165 // Remove the filters that are associated with the transferred ports |
157 for (const auto& iter : sent_ports) | 166 for (const auto& iter : sent_ports) |
158 ports_.erase(iter); | 167 ports_.erase(iter); |
159 } | 168 } |
160 | 169 |
161 void AwMessagePortServiceImpl::PostAppToWebMessageOnIOThread( | 170 void AwMessagePortServiceImpl::PostAppToWebMessageOnIOThread( |
162 int sender_id, | 171 int sender_id, |
(...skipping 11 matching lines...) Expand all Loading... | |
174 void AwMessagePortServiceImpl::CleanupPort(int message_port_id) { | 183 void AwMessagePortServiceImpl::CleanupPort(int message_port_id) { |
175 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 184 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
176 ports_.erase(message_port_id); | 185 ports_.erase(message_port_id); |
177 } | 186 } |
178 | 187 |
179 void AwMessagePortServiceImpl::CreateMessageChannelOnIOThread( | 188 void AwMessagePortServiceImpl::CreateMessageChannelOnIOThread( |
180 scoped_refptr<AwMessagePortMessageFilter> filter, | 189 scoped_refptr<AwMessagePortMessageFilter> filter, |
181 int* portId1, | 190 int* portId1, |
182 int* portId2) { | 191 int* portId2) { |
183 MessagePortProvider::CreateMessageChannel(filter.get(), portId1, portId2); | 192 MessagePortProvider::CreateMessageChannel(filter.get(), portId1, portId2); |
193 MessagePortProvider::HoldMessages(*portId1); | |
194 MessagePortProvider::HoldMessages(*portId2); | |
184 AddPort(*portId1, filter.get()); | 195 AddPort(*portId1, filter.get()); |
185 AddPort(*portId2, filter.get()); | 196 AddPort(*portId2, filter.get()); |
186 } | 197 } |
187 | 198 |
188 void AwMessagePortServiceImpl::OnMessageChannelCreated( | 199 void AwMessagePortServiceImpl::OnMessageChannelCreated( |
189 ScopedJavaGlobalRef<jobjectArray>* ports, | 200 ScopedJavaGlobalRef<jobjectArray>* ports, |
190 int* port1, | 201 int* port1, |
191 int* port2) { | 202 int* port2) { |
192 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 203 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
193 JNIEnv* env = AttachCurrentThread(); | 204 JNIEnv* env = AttachCurrentThread(); |
(...skipping 19 matching lines...) Expand all Loading... | |
213 } | 224 } |
214 | 225 |
215 // static | 226 // static |
216 jlong InitAwMessagePortService(JNIEnv* env, jobject obj) { | 227 jlong InitAwMessagePortService(JNIEnv* env, jobject obj) { |
217 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); | 228 AwMessagePortServiceImpl* service = AwMessagePortServiceImpl::GetInstance(); |
218 service->Init(env, obj); | 229 service->Init(env, obj); |
219 return reinterpret_cast<intptr_t>(service); | 230 return reinterpret_cast<intptr_t>(service); |
220 } | 231 } |
221 | 232 |
222 } // namespace android_webview | 233 } // namespace android_webview |
OLD | NEW |