Chromium Code Reviews| Index: content/browser/android/content_view_core_impl.cc |
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc |
| index 16e83d8a457ae3969bb8eed13a164c4879ec6290..62c4fed0611f792e137f470085958aff2b97cc79 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -26,6 +26,7 @@ |
| #include "content/browser/frame_host/navigation_entry_impl.h" |
| #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
| #include "content/browser/media/media_web_contents_observer.h" |
| +#include "content/browser/message_port_service.h" |
| #include "content/browser/renderer_host/compositor_impl_android.h" |
| #include "content/browser/renderer_host/input/motion_event_android.h" |
| #include "content/browser/renderer_host/input/web_input_event_builders_android.h" |
| @@ -158,6 +159,28 @@ float GetPrimaryDisplayDeviceScaleFactor() { |
| return display.device_scale_factor(); |
| } |
| +void CreateMessageChannelOnIOThread( |
| + MessagePortMessageFilter* filter, |
| + int routing_id, |
| + int* port1, int* port2) { |
| + |
| + *port1 = 0; |
| + *port2 = 0; |
| + MessagePortService* msp = MessagePortService::GetInstance(); |
| + msp->Create(routing_id, filter, port1); |
| + msp->Create(routing_id, filter, port2); |
| + msp->QueueMessages(*port1); |
| + msp->QueueMessages(*port2); |
| +} |
| + |
| +void OnMessageChannelCreated( |
| + ScopedJavaGlobalRef<jobject>* callback, |
| + int* port1, int* port2) { |
| + JNIEnv* env = AttachCurrentThread(); |
| + Java_ContentViewCore_onMessageChannelCreated(env, *port1, *port2, |
| + callback->obj()); |
| +} |
| + |
| } // namespace |
| // Enables a callback when the underlying WebContents is destroyed, to enable |
| @@ -1423,6 +1446,31 @@ void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env, |
| c_callback); |
| } |
| +void ContentViewCoreImpl::CreateMessageChannel(JNIEnv* env, jobject obj, |
| + jobject callback) { |
| + |
| + ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>(); |
| + j_callback->Reset(env, callback); |
| + RenderProcessHostImpl* rph = |
| + static_cast<RenderProcessHostImpl*>( |
| + web_contents_->GetRenderProcessHost()); |
| + MessagePortMessageFilter* mf = rph->message_port_message_filter(); |
| + |
| + int port1; |
|
Yaron
2014/07/18 21:54:00
These are stack allocated and are passing to anoth
sgurun-gerrit only
2014/10/28 00:41:10
Done.
|
| + int port2; |
| + // Create message channel on IO thread |
| + BrowserThread::PostTaskAndReply( |
| + BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(&CreateMessageChannelOnIOThread, |
| + mf, |
| + GetWebContents()->GetRoutingID(), |
| + &port1, &port2), |
| + base::Bind(&OnMessageChannelCreated, |
| + base::Owned(j_callback), |
| + &port1, &port2)); |
| +} |
| + |
| bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
| JNIEnv* env, jobject obj) { |
| NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |