Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: base/android/java_handler_thread.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/java_handler_thread.h ('k') | base/android/java_runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java_handler_thread.cc
diff --git a/base/android/java_handler_thread.cc b/base/android/java_handler_thread.cc
deleted file mode 100644
index 117971eda5d0674468e96325d8da9286c9f20088..0000000000000000000000000000000000000000
--- a/base/android/java_handler_thread.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/android/java_handler_thread.h"
-
-#include <jni.h>
-
-#include "base/android/jni_android.h"
-#include "base/android/jni_string.h"
-#include "base/message_loop/message_loop.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread_restrictions.h"
-#include "jni/JavaHandlerThread_jni.h"
-
-namespace base {
-
-namespace android {
-
-JavaHandlerThread::JavaHandlerThread(const char* name) {
- JNIEnv* env = base::android::AttachCurrentThread();
-
- java_thread_.Reset(Java_JavaHandlerThread_create(
- env, ConvertUTF8ToJavaString(env, name).Release()));
-}
-
-JavaHandlerThread::~JavaHandlerThread() {
-}
-
-void JavaHandlerThread::Start() {
- // Check the thread has not already been started.
- DCHECK(!message_loop_);
-
- JNIEnv* env = base::android::AttachCurrentThread();
- base::WaitableEvent initialize_event(false, false);
- Java_JavaHandlerThread_start(env,
- java_thread_.obj(),
- reinterpret_cast<intptr_t>(this),
- reinterpret_cast<intptr_t>(&initialize_event));
- // Wait for thread to be initialized so it is ready to be used when Start
- // returns.
- base::ThreadRestrictions::ScopedAllowWait wait_allowed;
- initialize_event.Wait();
-}
-
-void JavaHandlerThread::Stop() {
- JNIEnv* env = base::android::AttachCurrentThread();
- base::WaitableEvent shutdown_event(false, false);
- Java_JavaHandlerThread_stop(env,
- java_thread_.obj(),
- reinterpret_cast<intptr_t>(this),
- reinterpret_cast<intptr_t>(&shutdown_event));
- // Wait for thread to shut down before returning.
- base::ThreadRestrictions::ScopedAllowWait wait_allowed;
- shutdown_event.Wait();
-}
-
-void JavaHandlerThread::InitializeThread(JNIEnv* env, jobject obj,
- jlong event) {
- // TYPE_JAVA to get the Android java style message loop.
- message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_JAVA));
- static_cast<MessageLoopForUI*>(message_loop_.get())->Start();
- reinterpret_cast<base::WaitableEvent*>(event)->Signal();
-}
-
-void JavaHandlerThread::StopThread(JNIEnv* env, jobject obj, jlong event) {
- static_cast<MessageLoopForUI*>(message_loop_.get())->Quit();
- reinterpret_cast<base::WaitableEvent*>(event)->Signal();
-}
-
-// static
-bool JavaHandlerThread::RegisterBindings(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-} // namespace android
-} // namespace base
« no previous file with comments | « base/android/java_handler_thread.h ('k') | base/android/java_runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698