diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop/message_pump_android.cc | 25 | ||||
-rw-r--r-- | base/message_loop/message_pump_android.h | 2 |
2 files changed, 11 insertions, 16 deletions
diff --git a/base/message_loop/message_pump_android.cc b/base/message_loop/message_pump_android.cc index dda8730..70eb6ef 100644 --- a/base/message_loop/message_pump_android.cc +++ b/base/message_loop/message_pump_android.cc @@ -16,13 +16,6 @@ using base::android::ScopedJavaLocalRef; -namespace { - -base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> > - g_system_message_handler_obj = LAZY_INSTANCE_INITIALIZER; - -} // namespace - // ---------------------------------------------------------------------------- // Native JNI methods called by Java. // ---------------------------------------------------------------------------- @@ -81,23 +74,23 @@ void MessagePumpForUI::Start(Delegate* delegate) { if (!run_loop_->BeforeRun()) NOTREACHED(); - DCHECK(g_system_message_handler_obj.Get().is_null()); + DCHECK(system_message_handler_obj_.is_null()); JNIEnv* env = base::android::AttachCurrentThread(); DCHECK(env); - g_system_message_handler_obj.Get().Reset( + system_message_handler_obj_.Reset( Java_SystemMessageHandler_create(env, reinterpret_cast<jint>(delegate))); } void MessagePumpForUI::Quit() { - if (!g_system_message_handler_obj.Get().is_null()) { + if (!system_message_handler_obj_.is_null()) { JNIEnv* env = base::android::AttachCurrentThread(); DCHECK(env); Java_SystemMessageHandler_removeTimer(env, - g_system_message_handler_obj.Get().obj()); - g_system_message_handler_obj.Get().Reset(); + system_message_handler_obj_.obj()); + system_message_handler_obj_.Reset(); } if (run_loop_) { @@ -108,17 +101,17 @@ void MessagePumpForUI::Quit() { } void MessagePumpForUI::ScheduleWork() { - DCHECK(!g_system_message_handler_obj.Get().is_null()); + DCHECK(!system_message_handler_obj_.is_null()); JNIEnv* env = base::android::AttachCurrentThread(); DCHECK(env); Java_SystemMessageHandler_setTimer(env, - g_system_message_handler_obj.Get().obj()); + system_message_handler_obj_.obj()); } void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) { - DCHECK(!g_system_message_handler_obj.Get().is_null()); + DCHECK(!system_message_handler_obj_.is_null()); JNIEnv* env = base::android::AttachCurrentThread(); DCHECK(env); @@ -128,7 +121,7 @@ void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) { // Note that we're truncating to milliseconds as required by the java side, // even though delayed_work_time is microseconds resolution. Java_SystemMessageHandler_setDelayedTimer(env, - g_system_message_handler_obj.Get().obj(), millis); + system_message_handler_obj_.obj(), millis); } // static diff --git a/base/message_loop/message_pump_android.h b/base/message_loop/message_pump_android.h index fd934a7..f3a8ded 100644 --- a/base/message_loop/message_pump_android.h +++ b/base/message_loop/message_pump_android.h @@ -7,6 +7,7 @@ #include <jni.h> +#include "base/android/scoped_java_ref.h" #include "base/base_export.h" #include "base/compiler_specific.h" #include "base/message_loop/message_pump.h" @@ -36,6 +37,7 @@ class BASE_EXPORT MessagePumpForUI : public MessagePump { private: RunLoop* run_loop_; + base::android::ScopedJavaGlobalRef<jobject> system_message_handler_obj_; DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); }; |