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

Side by Side Diff: base/android/jni_weak_ref.cc

Issue 1489703002: android: Don't log error when checking weak ref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/android/jni_weak_ref.h" 5 #include "base/android/jni_weak_ref.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 using base::android::AttachCurrentThread; 10 using base::android::AttachCurrentThread;
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 base::android::ScopedJavaLocalRef<jobject> 42 base::android::ScopedJavaLocalRef<jobject>
43 JavaObjectWeakGlobalRef::get(JNIEnv* env) const { 43 JavaObjectWeakGlobalRef::get(JNIEnv* env) const {
44 return GetRealObject(env, obj_); 44 return GetRealObject(env, obj_);
45 } 45 }
46 46
47 base::android::ScopedJavaLocalRef<jobject> GetRealObject( 47 base::android::ScopedJavaLocalRef<jobject> GetRealObject(
48 JNIEnv* env, jweak obj) { 48 JNIEnv* env, jweak obj) {
49 jobject real = NULL; 49 jobject real = NULL;
50 if (obj) { 50 if (obj)
51 real = env->NewLocalRef(obj); 51 real = env->NewLocalRef(obj);
52 if (!real)
53 DLOG(ERROR) << "The real object has been deleted!";
54 }
55 return base::android::ScopedJavaLocalRef<jobject>(env, real); 52 return base::android::ScopedJavaLocalRef<jobject>(env, real);
56 } 53 }
57 54
58 void JavaObjectWeakGlobalRef::Assign(const JavaObjectWeakGlobalRef& other) { 55 void JavaObjectWeakGlobalRef::Assign(const JavaObjectWeakGlobalRef& other) {
59 if (&other == this) 56 if (&other == this)
60 return; 57 return;
61 58
62 JNIEnv* env = AttachCurrentThread(); 59 JNIEnv* env = AttachCurrentThread();
63 if (obj_) 60 if (obj_)
64 env->DeleteWeakGlobalRef(obj_); 61 env->DeleteWeakGlobalRef(obj_);
65 62
66 obj_ = other.obj_ ? env->NewWeakGlobalRef(other.obj_) : NULL; 63 obj_ = other.obj_ ? env->NewWeakGlobalRef(other.obj_) : NULL;
67 } 64 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698