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/browser/android/java/gin_java_bridge_dispatcher_host.h" | 5 #include "content/browser/android/java/gin_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/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 : GinJavaBoundObject::CreateTransient(ref, safe_annotation_clazz, | 137 : GinJavaBoundObject::CreateTransient(ref, safe_annotation_clazz, |
138 holder); | 138 holder); |
139 // Note that we are abusing the fact that StaticAtomicSequenceNumber | 139 // Note that we are abusing the fact that StaticAtomicSequenceNumber |
140 // uses Atomic32 as a counter, so it is guaranteed that it will not | 140 // uses Atomic32 as a counter, so it is guaranteed that it will not |
141 // overflow our int32 IDs. IDs start from 1. | 141 // overflow our int32 IDs. IDs start from 1. |
142 GinJavaBoundObject::ObjectID object_id = g_next_object_id.GetNext() + 1; | 142 GinJavaBoundObject::ObjectID object_id = g_next_object_id.GetNext() + 1; |
143 { | 143 { |
144 base::AutoLock locker(objects_lock_); | 144 base::AutoLock locker(objects_lock_); |
145 objects_[object_id] = new_object; | 145 objects_[object_id] = new_object; |
146 } | 146 } |
147 #if DCHECK_IS_ON | 147 #if DCHECK_IS_ON() |
148 { | 148 { |
149 GinJavaBoundObject::ObjectID added_object_id; | 149 GinJavaBoundObject::ObjectID added_object_id; |
150 DCHECK(FindObjectId(object, &added_object_id)); | 150 DCHECK(FindObjectId(object, &added_object_id)); |
151 DCHECK_EQ(object_id, added_object_id); | 151 DCHECK_EQ(object_id, added_object_id); |
152 } | 152 } |
153 #endif // DCHECK_IS_ON | 153 #endif // DCHECK_IS_ON() |
154 base::android::ScopedJavaLocalRef<jobject> retained_object_set = | 154 base::android::ScopedJavaLocalRef<jobject> retained_object_set = |
155 retained_object_set_.get(env); | 155 retained_object_set_.get(env); |
156 if (!retained_object_set.is_null()) { | 156 if (!retained_object_set.is_null()) { |
157 base::AutoLock locker(objects_lock_); | 157 base::AutoLock locker(objects_lock_); |
158 JNI_Java_HashSet_add(env, retained_object_set, object); | 158 JNI_Java_HashSet_add(env, retained_object_set, object); |
159 } | 159 } |
160 return object_id; | 160 return object_id; |
161 } | 161 } |
162 | 162 |
163 bool GinJavaBridgeDispatcherHost::FindObjectId( | 163 bool GinJavaBridgeDispatcherHost::FindObjectId( |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 if (iter == objects_.end()) | 481 if (iter == objects_.end()) |
482 return; | 482 return; |
483 JavaObjectWeakGlobalRef ref = | 483 JavaObjectWeakGlobalRef ref = |
484 RemoveHolderAndAdvanceLocked(GetCurrentRoutingID(), &iter); | 484 RemoveHolderAndAdvanceLocked(GetCurrentRoutingID(), &iter); |
485 if (!ref.is_empty()) { | 485 if (!ref.is_empty()) { |
486 RemoveFromRetainedObjectSetLocked(ref); | 486 RemoveFromRetainedObjectSetLocked(ref); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 } // namespace content | 490 } // namespace content |
OLD | NEW |