OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/java/java_bridge_dispatcher_host.h" | 5 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h" |
6 | 6 |
7 #include "base/android/java_handler_thread.h" | 7 #include "base/android/java_handler_thread.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" | 10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // NPObjectStub. Post that message before doing any IPC, to make sure that | 121 // NPObjectStub. Post that message before doing any IPC, to make sure that |
122 // the channel and object proxies are ready before responses are received | 122 // the channel and object proxies are ready before responses are received |
123 // from the renderer. | 123 // from the renderer. |
124 | 124 |
125 // Create an NPVariantParam suitable for serialization over IPC from our | 125 // Create an NPVariantParam suitable for serialization over IPC from our |
126 // NPVariant. See CreateNPVariantParam() in npobject_utils. | 126 // NPVariant. See CreateNPVariantParam() in npobject_utils. |
127 param->type = NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID; | 127 param->type = NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID; |
128 int route_id = JavaBridgeChannelHost::ThreadsafeGenerateRouteID(); | 128 int route_id = JavaBridgeChannelHost::ThreadsafeGenerateRouteID(); |
129 param->npobject_routing_id = route_id; | 129 param->npobject_routing_id = route_id; |
130 | 130 |
131 WebKit::WebBindings::retainObject(object); | 131 blink::WebBindings::retainObject(object); |
132 g_background_thread.Get().message_loop()->PostTask( | 132 g_background_thread.Get().message_loop()->PostTask( |
133 FROM_HERE, | 133 FROM_HERE, |
134 base::Bind(&JavaBridgeDispatcherHost::CreateObjectStub, this, object, | 134 base::Bind(&JavaBridgeDispatcherHost::CreateObjectStub, this, object, |
135 render_view_host_->GetProcess()->GetID(), route_id)); | 135 render_view_host_->GetProcess()->GetID(), route_id)); |
136 } | 136 } |
137 | 137 |
138 void JavaBridgeDispatcherHost::CreateObjectStub(NPObject* object, | 138 void JavaBridgeDispatcherHost::CreateObjectStub(NPObject* object, |
139 int render_process_id, | 139 int render_process_id, |
140 int route_id) { | 140 int route_id) { |
141 DCHECK_EQ(g_background_thread.Get().message_loop(), | 141 DCHECK_EQ(g_background_thread.Get().message_loop(), |
(...skipping 12 matching lines...) Expand all Loading... |
154 | 154 |
155 // Pass 0 for the containing window, as it's only used by plugins to pump the | 155 // Pass 0 for the containing window, as it's only used by plugins to pump the |
156 // window message queue when a method on a renderer-side object causes a | 156 // window message queue when a method on a renderer-side object causes a |
157 // dialog to be displayed, and the Java Bridge does not need this | 157 // dialog to be displayed, and the Java Bridge does not need this |
158 // functionality. The page URL is also not required. | 158 // functionality. The page URL is also not required. |
159 stubs_.push_back((new NPObjectStub( | 159 stubs_.push_back((new NPObjectStub( |
160 object, channel_.get(), route_id, 0, GURL()))->AsWeakPtr()); | 160 object, channel_.get(), route_id, 0, GURL()))->AsWeakPtr()); |
161 | 161 |
162 // The NPObjectStub takes a reference to the NPObject. Release the ref added | 162 // The NPObjectStub takes a reference to the NPObject. Release the ref added |
163 // in CreateNPVariantParam(). | 163 // in CreateNPVariantParam(). |
164 WebKit::WebBindings::releaseObject(object); | 164 blink::WebBindings::releaseObject(object); |
165 } | 165 } |
166 | 166 |
167 } // namespace content | 167 } // namespace content |
OLD | NEW |