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

Side by Side Diff: android_webview/native/aw_message_port_service_impl.cc

Issue 986553004: Hold messages in message port service when a message port is (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address hush nit Created 5 years, 9 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 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
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) {
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
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
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
OLDNEW
« no previous file with comments | « android_webview/native/aw_message_port_service_impl.h ('k') | content/browser/message_port_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698