| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/java/gin_java_bridge_dispatcher.h" | 5 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/common/gin_java_bridge_messages.h" | 10 #include "content/common/gin_java_bridge_messages.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { | 116 GinJavaBridgeObject* GinJavaBridgeDispatcher::GetObject(ObjectID object_id) { |
| 117 GinJavaBridgeObject* result = objects_.Lookup(object_id); | 117 GinJavaBridgeObject* result = objects_.Lookup(object_id); |
| 118 if (!result) { | 118 if (!result) { |
| 119 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); | 119 result = GinJavaBridgeObject::InjectAnonymous(AsWeakPtr(), object_id); |
| 120 if (result) | 120 if (result) |
| 121 objects_.AddWithID(result, object_id); | 121 objects_.AddWithID(result, object_id); |
| 122 } | 122 } |
| 123 return result; | 123 return result; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted(ObjectID object_id) { | 126 void GinJavaBridgeDispatcher::OnGinJavaBridgeObjectDeleted( |
| 127 if (!objects_.Lookup(object_id)) | 127 GinJavaBridgeObject* object) { |
| 128 return; | 128 int object_id = object->object_id(); |
| 129 // Ignore cleaning up of old object wrappers. |
| 130 if (objects_.Lookup(object_id) != object) return; |
| 129 objects_.Remove(object_id); | 131 objects_.Remove(object_id); |
| 130 render_frame()->Send( | 132 render_frame()->Send( |
| 131 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); | 133 new GinJavaBridgeHostMsg_ObjectWrapperDeleted(routing_id(), object_id)); |
| 132 } | 134 } |
| 133 | 135 |
| 134 } // namespace content | 136 } // namespace content |
| OLD | NEW |