OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ | 5 #ifndef BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ |
6 #define BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ | 6 #define BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ |
7 | 7 |
8 #include "base/android/java_handler_thread.h" | 8 #include "base/android/java_handler_thread.h" |
9 #include "base/android/java_message_handler_factory.h" | 9 #include "base/android/java_message_handler_factory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // does. | 31 // does. |
32 // This is partly because we need to create a test-only java-side message | 32 // This is partly because we need to create a test-only java-side message |
33 // handler to back the native message loop, and partly because our tests cause | 33 // handler to back the native message loop, and partly because our tests cause |
34 // the corresponding message pump to abort which means it won't reach its idle | 34 // the corresponding message pump to abort which means it won't reach its idle |
35 // work state and thus can't quit when idle. We here stop the pump more abruptly | 35 // work state and thus can't quit when idle. We here stop the pump more abruptly |
36 // instead. | 36 // instead. |
37 class JavaHandlerThreadForTesting : public JavaHandlerThread { | 37 class JavaHandlerThreadForTesting : public JavaHandlerThread { |
38 public: | 38 public: |
39 JavaHandlerThreadForTesting(const char* name, | 39 JavaHandlerThreadForTesting(const char* name, |
40 base::WaitableEvent* test_done_event); | 40 base::WaitableEvent* test_done_event); |
| 41 // Create java peer first, then connect with native. |
| 42 explicit JavaHandlerThreadForTesting(base::WaitableEvent* test_done_event); |
41 ~JavaHandlerThreadForTesting() override; | 43 ~JavaHandlerThreadForTesting() override; |
42 | 44 |
43 void StartMessageLoop() override; | 45 void StartMessageLoop() override; |
44 void StopMessageLoop() override; | 46 void StopMessageLoop() override; |
45 | 47 |
46 private: | 48 private: |
47 std::unique_ptr<JavaMessageHandlerFactory> message_handler_factory_; | 49 std::unique_ptr<JavaMessageHandlerFactory> message_handler_factory_; |
48 base::WaitableEvent* test_done_event_; | 50 base::WaitableEvent* test_done_event_; |
49 }; | 51 }; |
50 | 52 |
51 } // namespace android | 53 } // namespace android |
52 } // namespace base | 54 } // namespace base |
53 | 55 |
54 #endif // BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ | 56 #endif // BASE_ANDROID_JAVA_HANDLER_THREAD_FOR_TESTING_H_ |
OLD | NEW |