diff options
author | sgurun <sgurun@chromium.org> | 2015-02-13 10:11:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-13 18:12:50 +0000 |
commit | 2d72bc0ea342dd43b5ba9593efb585c3c8bf8473 (patch) | |
tree | c8282ce265ee559a6929684dfc0a9ecb7dd5c5ae /android_webview/native | |
parent | 6c690f1c2e035deda117ac13e6d5a23f4be6e3c6 (diff) | |
download | chromium_src-2d72bc0ea342dd43b5ba9593efb585c3c8bf8473.zip chromium_src-2d72bc0ea342dd43b5ba9593efb585c3c8bf8473.tar.gz chromium_src-2d72bc0ea342dd43b5ba9593efb585c3c8bf8473.tar.bz2 |
Return created channels synchronously
This CL's focus is to return the channels synchronously. A next CL will introduce a close() api to message ports so resources can be freed when not used, and then will change the way we post messages in background thread.
At the receive side, we need to deal with messages received when a port is being transferred. this is for a next cl.
The channel ports are created in a different thread. This CL introduces an internal "pending" state that is not visible to users to hide the fact that channels are not ready yet.
BUG=393291
Review URL: https://codereview.chromium.org/920873003
Cr-Commit-Position: refs/heads/master@{#316243}
Diffstat (limited to 'android_webview/native')
-rw-r--r-- | android_webview/native/aw_contents.cc | 5 | ||||
-rw-r--r-- | android_webview/native/aw_contents.h | 2 | ||||
-rw-r--r-- | android_webview/native/aw_message_port_service_impl.cc | 13 | ||||
-rw-r--r-- | android_webview/native/aw_message_port_service_impl.h | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 34d9e0a..efa20b2 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -1110,7 +1110,6 @@ void AwContents::PostMessageToFrame(JNIEnv* env, jobject obj, base::Unretained(AwMessagePortServiceImpl::GetInstance()), j_ports)); } - content::MessagePortProvider::PostMessageToFrame(web_contents_.get(), j_source_origin, j_target_origin, @@ -1132,9 +1131,9 @@ AwContents::GetMessagePortMessageFilter() { } void AwContents::CreateMessageChannel(JNIEnv* env, jobject obj, - jobject callback) { + jobjectArray ports) { - AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, callback, + AwMessagePortServiceImpl::GetInstance()->CreateMessageChannel(env, ports, GetMessagePortMessageFilter()); } diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index a1cf788..af6135d 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -224,7 +224,7 @@ class AwContents : public FindHelper::Listener, void PostMessageToFrame(JNIEnv* env, jobject obj, jstring frame_id, jstring message, jstring source_origin, jstring target_origin, jintArray sent_ports); - void CreateMessageChannel(JNIEnv* env, jobject obj, jobject callback); + void CreateMessageChannel(JNIEnv* env, jobject obj, jobjectArray ports); private: void InitDataReductionProxyIfNecessary(); diff --git a/android_webview/native/aw_message_port_service_impl.cc b/android_webview/native/aw_message_port_service_impl.cc index a231d1c..d2e1fa4 100644 --- a/android_webview/native/aw_message_port_service_impl.cc +++ b/android_webview/native/aw_message_port_service_impl.cc @@ -49,12 +49,13 @@ void AwMessagePortServiceImpl::Init(JNIEnv* env, jobject obj) { void AwMessagePortServiceImpl::CreateMessageChannel( JNIEnv* env, - jobject callback, + jobjectArray ports, scoped_refptr<AwMessagePortMessageFilter> filter) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); - j_callback->Reset(env, callback); + ScopedJavaGlobalRef<jobjectArray>* j_ports = + new ScopedJavaGlobalRef<jobjectArray>(); + j_ports->Reset(env, ports); int* portId1 = new int; int* portId2 = new int; @@ -68,7 +69,7 @@ void AwMessagePortServiceImpl::CreateMessageChannel( portId2), base::Bind(&AwMessagePortServiceImpl::OnMessageChannelCreated, base::Unretained(this), - base::Owned(j_callback), + base::Owned(j_ports), base::Owned(portId1), base::Owned(portId2))); } @@ -161,7 +162,7 @@ void AwMessagePortServiceImpl::CreateMessageChannelOnIOThread( } void AwMessagePortServiceImpl::OnMessageChannelCreated( - ScopedJavaGlobalRef<jobject>* callback, + ScopedJavaGlobalRef<jobjectArray>* ports, int* port1, int* port2) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -170,7 +171,7 @@ void AwMessagePortServiceImpl::OnMessageChannelCreated( if (obj.is_null()) return; Java_AwMessagePortService_onMessageChannelCreated(env, obj.obj(), *port1, - *port2, callback->obj()); + *port2, ports->obj()); } void AwMessagePortServiceImpl::AddPort(int message_port_id, diff --git a/android_webview/native/aw_message_port_service_impl.h b/android_webview/native/aw_message_port_service_impl.h index f72f80e..3ab5b88 100644 --- a/android_webview/native/aw_message_port_service_impl.h +++ b/android_webview/native/aw_message_port_service_impl.h @@ -29,7 +29,7 @@ class AwMessagePortServiceImpl : public AwMessagePortService { ~AwMessagePortServiceImpl() override; void Init(JNIEnv* env, jobject object); - void CreateMessageChannel(JNIEnv* env, jobject callback, + void CreateMessageChannel(JNIEnv* env, jobjectArray ports, scoped_refptr<AwMessagePortMessageFilter> filter); // AwMessagePortService implementation @@ -56,7 +56,7 @@ private: int* port1, int* port2); void OnMessageChannelCreated( - base::android::ScopedJavaGlobalRef<jobject>* callback, + base::android::ScopedJavaGlobalRef<jobjectArray>* ports, int* port1, int* port2); void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); |