1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_
7 
8 #include <jni.h>
9 
10 #include "base/android/scoped_java_ref.h"
11 #include "base/base_export.h"
12 #include "base/compiler_specific.h"
13 #include "base/macros.h"
14 #include "base/message_loop/message_pump.h"
15 
16 namespace base {
17 
18 class RunLoop;
19 class TimeTicks;
20 
21 // This class implements a MessagePump needed for TYPE_UI MessageLoops on
22 // OS_ANDROID platform.
23 class BASE_EXPORT MessagePumpForUI : public MessagePump {
24  public:
25   MessagePumpForUI();
26   ~MessagePumpForUI() override;
27 
28   void Run(Delegate* delegate) override;
29   void Quit() override;
30   void ScheduleWork() override;
31   void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override;
32 
33   virtual void Start(Delegate* delegate);
34 
35   static bool RegisterBindings(JNIEnv* env);
36 
37  private:
38   RunLoop* run_loop_;
39   base::android::ScopedJavaGlobalRef<jobject> system_message_handler_obj_;
40 
41   DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
42 };
43 
44 }  // namespace base
45 
46 #endif  // BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_
47