OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ |
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 MessagePumpForUI(); | 25 MessagePumpForUI(); |
26 ~MessagePumpForUI() override; | 26 ~MessagePumpForUI() override; |
27 | 27 |
28 void Run(Delegate* delegate) override; | 28 void Run(Delegate* delegate) override; |
29 void Quit() override; | 29 void Quit() override; |
30 void ScheduleWork() override; | 30 void ScheduleWork() override; |
31 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; | 31 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; |
32 | 32 |
33 virtual void Start(Delegate* delegate); | 33 virtual void Start(Delegate* delegate); |
| 34 // We call Abort when there is a pending JNI exception, meaning that the |
| 35 // current thread will crash when we return to Java. |
| 36 // We can't call any jni-methods before returning to Java as we would then |
| 37 // cause a native crash (instead of the original Java crash) |
| 38 void Abort() { should_abort_ = true; } |
| 39 bool ShouldAbort() const { return should_abort_; } |
34 | 40 |
35 static bool RegisterBindings(JNIEnv* env); | 41 static bool RegisterBindings(JNIEnv* env); |
36 | 42 |
37 private: | 43 private: |
38 RunLoop* run_loop_; | 44 RunLoop* run_loop_; |
39 base::android::ScopedJavaGlobalRef<jobject> system_message_handler_obj_; | 45 base::android::ScopedJavaGlobalRef<jobject> system_message_handler_obj_; |
| 46 bool should_abort_; |
40 | 47 |
41 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); | 48 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); |
42 }; | 49 }; |
43 | 50 |
44 } // namespace base | 51 } // namespace base |
45 | 52 |
46 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ | 53 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_ANDROID_H_ |
OLD | NEW |