OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/context_utils.h" | 5 #include "base/android/context_utils.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (env->IsSameObject(g_application_context.Get().obj(), context.obj())) { | 26 if (env->IsSameObject(g_application_context.Get().obj(), context.obj())) { |
27 // It's safe to set the context more than once if it's the same context. | 27 // It's safe to set the context more than once if it's the same context. |
28 return; | 28 return; |
29 } | 29 } |
30 DCHECK(g_application_context.Get().is_null()); | 30 DCHECK(g_application_context.Get().is_null()); |
31 g_application_context.Get().Reset(context); | 31 g_application_context.Get().Reset(context); |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 jobject GetApplicationContext() { | 36 const JavaRef<jobject>& GetApplicationContext() { |
37 DCHECK(!g_application_context.Get().is_null()); | 37 DCHECK(!g_application_context.Get().is_null()); |
38 return g_application_context.Get().obj(); | 38 return g_application_context.Get(); |
39 } | 39 } |
40 | 40 |
41 static void InitNativeSideApplicationContext( | 41 static void InitNativeSideApplicationContext( |
42 JNIEnv* env, | 42 JNIEnv* env, |
43 const JavaParamRef<jclass>& clazz, | 43 const JavaParamRef<jclass>& clazz, |
44 const JavaParamRef<jobject>& context) { | 44 const JavaParamRef<jobject>& context) { |
45 SetNativeApplicationContext(env, context); | 45 SetNativeApplicationContext(env, context); |
46 } | 46 } |
47 | 47 |
48 bool RegisterContextUtils(JNIEnv* env) { | 48 bool RegisterContextUtils(JNIEnv* env) { |
49 return RegisterNativesImpl(env); | 49 return RegisterNativesImpl(env); |
50 } | 50 } |
51 | 51 |
52 } // namespace android | 52 } // namespace android |
53 } // namespace base | 53 } // namespace base |
OLD | NEW |