| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 RenderViewHost* render_view_host) | 52 RenderViewHost* render_view_host) |
| 53 : render_view_host_(render_view_host) { | 53 : render_view_host_(render_view_host) { |
| 54 } | 54 } |
| 55 | 55 |
| 56 JavaBridgeDispatcherHost::~JavaBridgeDispatcherHost() { | 56 JavaBridgeDispatcherHost::~JavaBridgeDispatcherHost() { |
| 57 g_background_thread.Get().message_loop()->PostTask( | 57 g_background_thread.Get().message_loop()->PostTask( |
| 58 FROM_HERE, | 58 FROM_HERE, |
| 59 base::Bind(&CleanUpStubs, stubs_)); | 59 base::Bind(&CleanUpStubs, stubs_)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void JavaBridgeDispatcherHost::AddNamedObject(const string16& name, | 62 void JavaBridgeDispatcherHost::AddNamedObject(const base::string16& name, |
| 63 NPObject* object) { | 63 NPObject* object) { |
| 64 NPVariant_Param variant_param; | 64 NPVariant_Param variant_param; |
| 65 CreateNPVariantParam(object, &variant_param); | 65 CreateNPVariantParam(object, &variant_param); |
| 66 | 66 |
| 67 Send(new JavaBridgeMsg_AddNamedObject( | 67 Send(new JavaBridgeMsg_AddNamedObject( |
| 68 render_view_host_->GetRoutingID(), name, variant_param)); | 68 render_view_host_->GetRoutingID(), name, variant_param)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void JavaBridgeDispatcherHost::RemoveNamedObject(const string16& name) { | 71 void JavaBridgeDispatcherHost::RemoveNamedObject(const base::string16& name) { |
| 72 // On receipt of this message, the JavaBridgeDispatcher will drop its | 72 // On receipt of this message, the JavaBridgeDispatcher will drop its |
| 73 // reference to the corresponding proxy object. When the last reference is | 73 // reference to the corresponding proxy object. When the last reference is |
| 74 // removed, the proxy object will delete its NPObjectProxy, which will cause | 74 // removed, the proxy object will delete its NPObjectProxy, which will cause |
| 75 // the NPObjectStub to be deleted, which will drop its reference to the | 75 // the NPObjectStub to be deleted, which will drop its reference to the |
| 76 // original NPObject. | 76 // original NPObject. |
| 77 Send(new JavaBridgeMsg_RemoveNamedObject( | 77 Send(new JavaBridgeMsg_RemoveNamedObject( |
| 78 render_view_host_->GetRoutingID(), name)); | 78 render_view_host_->GetRoutingID(), name)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void JavaBridgeDispatcherHost::RenderViewDeleted() { | 81 void JavaBridgeDispatcherHost::RenderViewDeleted() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 blink::WebBindings::releaseObject(object); | 164 blink::WebBindings::releaseObject(object); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace content | 167 } // namespace content |
| OLD | NEW |