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/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/memory/ptr_util.h" |
9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
10 #include "content/browser/android/java/gin_java_bound_object_delegate.h" | 11 #include "content/browser/android/java/gin_java_bound_object_delegate.h" |
11 #include "content/browser/android/java/gin_java_bridge_message_filter.h" | 12 #include "content/browser/android/java/gin_java_bridge_message_filter.h" |
12 #include "content/browser/android/java/java_bridge_thread.h" | 13 #include "content/browser/android/java/java_bridge_thread.h" |
13 #include "content/browser/android/java/jni_helper.h" | 14 #include "content/browser/android/java/jni_helper.h" |
14 #include "content/common/android/gin_java_bridge_value.h" | 15 #include "content/common/android/gin_java_bridge_value.h" |
15 #include "content/common/android/hash_set.h" | 16 #include "content/common/android/hash_set.h" |
16 #include "content/common/gin_java_bridge_messages.h" | 17 #include "content/common/gin_java_bridge_messages.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 DCHECK(JavaBridgeThread::CurrentlyOn()); | 328 DCHECK(JavaBridgeThread::CurrentlyOn()); |
328 DCHECK(routing_id != MSG_ROUTING_NONE); | 329 DCHECK(routing_id != MSG_ROUTING_NONE); |
329 scoped_refptr<GinJavaBoundObject> object = FindObject(object_id); | 330 scoped_refptr<GinJavaBoundObject> object = FindObject(object_id); |
330 if (!object.get()) { | 331 if (!object.get()) { |
331 wrapped_result->Append(base::Value::CreateNullValue()); | 332 wrapped_result->Append(base::Value::CreateNullValue()); |
332 *error_code = kGinJavaBridgeUnknownObjectId; | 333 *error_code = kGinJavaBridgeUnknownObjectId; |
333 return; | 334 return; |
334 } | 335 } |
335 scoped_refptr<GinJavaMethodInvocationHelper> result = | 336 scoped_refptr<GinJavaMethodInvocationHelper> result = |
336 new GinJavaMethodInvocationHelper( | 337 new GinJavaMethodInvocationHelper( |
337 make_scoped_ptr(new GinJavaBoundObjectDelegate(object)), | 338 base::WrapUnique(new GinJavaBoundObjectDelegate(object)), method_name, |
338 method_name, | |
339 arguments); | 339 arguments); |
340 result->Init(this); | 340 result->Init(this); |
341 result->Invoke(); | 341 result->Invoke(); |
342 *error_code = result->GetInvocationError(); | 342 *error_code = result->GetInvocationError(); |
343 if (result->HoldsPrimitiveResult()) { | 343 if (result->HoldsPrimitiveResult()) { |
344 scoped_ptr<base::ListValue> result_copy( | 344 std::unique_ptr<base::ListValue> result_copy( |
345 result->GetPrimitiveResult().DeepCopy()); | 345 result->GetPrimitiveResult().DeepCopy()); |
346 wrapped_result->Swap(result_copy.get()); | 346 wrapped_result->Swap(result_copy.get()); |
347 } else if (!result->GetObjectResult().is_null()) { | 347 } else if (!result->GetObjectResult().is_null()) { |
348 GinJavaBoundObject::ObjectID returned_object_id; | 348 GinJavaBoundObject::ObjectID returned_object_id; |
349 if (FindObjectId(result->GetObjectResult(), &returned_object_id)) { | 349 if (FindObjectId(result->GetObjectResult(), &returned_object_id)) { |
350 base::AutoLock locker(objects_lock_); | 350 base::AutoLock locker(objects_lock_); |
351 objects_[returned_object_id]->AddHolder(routing_id); | 351 objects_[returned_object_id]->AddHolder(routing_id); |
352 } else { | 352 } else { |
353 returned_object_id = AddObject(result->GetObjectResult(), | 353 returned_object_id = AddObject(result->GetObjectResult(), |
354 result->GetSafeAnnotationClass(), | 354 result->GetSafeAnnotationClass(), |
(...skipping 18 matching lines...) Expand all Loading... |
373 if (iter == objects_.end()) | 373 if (iter == objects_.end()) |
374 return; | 374 return; |
375 JavaObjectWeakGlobalRef ref = | 375 JavaObjectWeakGlobalRef ref = |
376 RemoveHolderAndAdvanceLocked(routing_id, &iter); | 376 RemoveHolderAndAdvanceLocked(routing_id, &iter); |
377 if (!ref.is_empty()) { | 377 if (!ref.is_empty()) { |
378 RemoveFromRetainedObjectSetLocked(ref); | 378 RemoveFromRetainedObjectSetLocked(ref); |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 } // namespace content | 382 } // namespace content |
OLD | NEW |