Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: content/browser/android/java/gin_java_bridge_dispatcher_host.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/ptr_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 int routing_id, 323 int routing_id,
324 GinJavaBoundObject::ObjectID object_id, 324 GinJavaBoundObject::ObjectID object_id,
325 const std::string& method_name, 325 const std::string& method_name,
326 const base::ListValue& arguments, 326 const base::ListValue& arguments,
327 base::ListValue* wrapped_result, 327 base::ListValue* wrapped_result,
328 content::GinJavaBridgeError* error_code) { 328 content::GinJavaBridgeError* error_code) {
329 DCHECK(JavaBridgeThread::CurrentlyOn()); 329 DCHECK(JavaBridgeThread::CurrentlyOn());
330 DCHECK(routing_id != MSG_ROUTING_NONE); 330 DCHECK(routing_id != MSG_ROUTING_NONE);
331 scoped_refptr<GinJavaBoundObject> object = FindObject(object_id); 331 scoped_refptr<GinJavaBoundObject> object = FindObject(object_id);
332 if (!object.get()) { 332 if (!object.get()) {
333 wrapped_result->Append(base::Value::CreateNullValue()); 333 wrapped_result->Append(base::MakeUnique<base::Value>());
334 *error_code = kGinJavaBridgeUnknownObjectId; 334 *error_code = kGinJavaBridgeUnknownObjectId;
335 return; 335 return;
336 } 336 }
337 scoped_refptr<GinJavaMethodInvocationHelper> result = 337 scoped_refptr<GinJavaMethodInvocationHelper> result =
338 new GinJavaMethodInvocationHelper( 338 new GinJavaMethodInvocationHelper(
339 base::MakeUnique<GinJavaBoundObjectDelegate>(object), method_name, 339 base::MakeUnique<GinJavaBoundObjectDelegate>(object), method_name,
340 arguments); 340 arguments);
341 result->Init(this); 341 result->Init(this);
342 result->Invoke(); 342 result->Invoke();
343 *error_code = result->GetInvocationError(); 343 *error_code = result->GetInvocationError();
344 if (result->HoldsPrimitiveResult()) { 344 if (result->HoldsPrimitiveResult()) {
345 std::unique_ptr<base::ListValue> result_copy( 345 std::unique_ptr<base::ListValue> result_copy(
346 result->GetPrimitiveResult().DeepCopy()); 346 result->GetPrimitiveResult().DeepCopy());
347 wrapped_result->Swap(result_copy.get()); 347 wrapped_result->Swap(result_copy.get());
348 } else if (!result->GetObjectResult().is_null()) { 348 } else if (!result->GetObjectResult().is_null()) {
349 GinJavaBoundObject::ObjectID returned_object_id; 349 GinJavaBoundObject::ObjectID returned_object_id;
350 if (FindObjectId(result->GetObjectResult(), &returned_object_id)) { 350 if (FindObjectId(result->GetObjectResult(), &returned_object_id)) {
351 base::AutoLock locker(objects_lock_); 351 base::AutoLock locker(objects_lock_);
352 objects_[returned_object_id]->AddHolder(routing_id); 352 objects_[returned_object_id]->AddHolder(routing_id);
353 } else { 353 } else {
354 returned_object_id = AddObject(result->GetObjectResult(), 354 returned_object_id = AddObject(result->GetObjectResult(),
355 result->GetSafeAnnotationClass(), 355 result->GetSafeAnnotationClass(),
356 false, 356 false,
357 routing_id); 357 routing_id);
358 } 358 }
359 wrapped_result->Append( 359 wrapped_result->Append(
360 GinJavaBridgeValue::CreateObjectIDValue( 360 GinJavaBridgeValue::CreateObjectIDValue(
361 returned_object_id).release()); 361 returned_object_id).release());
362 } else { 362 } else {
363 wrapped_result->Append(base::Value::CreateNullValue()); 363 wrapped_result->Append(base::MakeUnique<base::Value>());
364 } 364 }
365 } 365 }
366 366
367 void GinJavaBridgeDispatcherHost::OnObjectWrapperDeleted( 367 void GinJavaBridgeDispatcherHost::OnObjectWrapperDeleted(
368 int routing_id, 368 int routing_id,
369 GinJavaBoundObject::ObjectID object_id) { 369 GinJavaBoundObject::ObjectID object_id) {
370 DCHECK(JavaBridgeThread::CurrentlyOn()); 370 DCHECK(JavaBridgeThread::CurrentlyOn());
371 DCHECK(routing_id != MSG_ROUTING_NONE); 371 DCHECK(routing_id != MSG_ROUTING_NONE);
372 base::AutoLock locker(objects_lock_); 372 base::AutoLock locker(objects_lock_);
373 auto iter = objects_.find(object_id); 373 auto iter = objects_.find(object_id);
374 if (iter == objects_.end()) 374 if (iter == objects_.end())
375 return; 375 return;
376 JavaObjectWeakGlobalRef ref = 376 JavaObjectWeakGlobalRef ref =
377 RemoveHolderAndAdvanceLocked(routing_id, &iter); 377 RemoveHolderAndAdvanceLocked(routing_id, &iter);
378 if (!ref.is_uninitialized()) { 378 if (!ref.is_uninitialized()) {
379 RemoveFromRetainedObjectSetLocked(ref); 379 RemoveFromRetainedObjectSetLocked(ref);
380 } 380 }
381 } 381 }
382 382
383 } // namespace content 383 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698