Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_THREADING_JAVA_THREAD_H_ | |
| 6 #define BASE_THREADING_JAVA_THREAD_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include "base/android/scoped_java_ref.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 class MessageLoop; | |
| 16 class WaitableEvent; | |
| 17 | |
| 18 namespace android { | |
| 19 | |
| 20 // A Java Thread with a native message loop. To run tasks, post them | |
| 21 // to the message loop and they will be scheduled along Java tasks | |
| 22 // on the thread. | |
| 23 // This is useful for callbacks where the receiver expects a thread | |
| 24 // with a prepared Looper. | |
| 25 class JavaThread { | |
| 26 public: | |
| 27 JavaThread(const char* name); | |
| 28 virtual ~JavaThread() {} | |
| 29 | |
| 30 base::MessageLoop* message_loop() const { return message_loop_.get(); } | |
| 31 void Start(); | |
| 32 void Stop(); | |
| 33 | |
| 34 // Called from java on the newly created thread. | |
| 35 // Start() will not return before this methods has finished. | |
| 36 void InitializeThread(JNIEnv* env, jobject obj, jint event); | |
|
joth
2013/07/17 16:29:18
guess this can be private
Kristian Monsen
2013/07/17 21:02:37
Done.
Kristian Monsen
2013/07/17 21:54:40
Actually it cannot be private since it is called b
| |
| 37 | |
| 38 static bool RegisterBindings(JNIEnv* env); | |
| 39 | |
| 40 private: | |
| 41 scoped_ptr<base::MessageLoop> message_loop_; | |
| 42 ScopedJavaGlobalRef<jobject> java_thread_; | |
| 43 | |
| 44 bool started_; | |
| 45 }; | |
| 46 | |
| 47 } // namespace android | |
| 48 | |
|
joth
2013/07/17 16:29:18
uber nit: no blank line here (nor in the .cc, nor
Kristian Monsen
2013/07/17 21:02:37
Done. You mean in general for closing two namespac
| |
| 49 } // namespace base | |
| 50 | |
| 51 #endif // BASE_THREADING_JAVA_THREAD_H_ | |
| OLD | NEW |