diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 23:13:33 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 23:13:33 +0000 |
commit | 9ada8c1bd489afe5859c7a17938fc68821c62b78 (patch) | |
tree | a3ed975054747519faf89ac71121e43137e304a2 /mojo | |
parent | 5195fc585a5dc844956405835ab258094d460e45 (diff) | |
download | chromium_src-9ada8c1bd489afe5859c7a17938fc68821c62b78.zip chromium_src-9ada8c1bd489afe5859c7a17938fc68821c62b78.tar.gz chromium_src-9ada8c1bd489afe5859c7a17938fc68821c62b78.tar.bz2 |
Remove separate thread for the shell on Android.
The shell is now run on the main (UI) thread along with the NativeViewport stuff.
R=abarth@chromium.org
http://crbug.com/324637
Review URL: https://codereview.chromium.org/100623003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238474 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/services/native_viewport/native_viewport_android.cc | 5 | ||||
-rw-r--r-- | mojo/shell/android/mojo_main.cc | 35 | ||||
-rw-r--r-- | mojo/shell/task_runners.h | 15 |
3 files changed, 8 insertions, 47 deletions
diff --git a/mojo/services/native_viewport/native_viewport_android.cc b/mojo/services/native_viewport/native_viewport_android.cc index 5c03a0a..bc80716 100644 --- a/mojo/services/native_viewport/native_viewport_android.cc +++ b/mojo/services/native_viewport/native_viewport_android.cc @@ -71,10 +71,7 @@ void NativeViewportAndroid::Init() { init->ui_runner = context_->task_runners()->ui_runner(); init->native_viewport = GetWeakPtr(); - context_->task_runners()->java_runner()->PostTask(FROM_HERE, - base::Bind(MojoViewport::CreateForActivity, - context_->activity(), - init)); + MojoViewport::CreateForActivity(context_->activity(), init); } void NativeViewportAndroid::Close() { diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc index 55b1c53..18dc5f6 100644 --- a/mojo/shell/android/mojo_main.cc +++ b/mojo/shell/android/mojo_main.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/logging.h" -#include "base/threading/thread.h" #include "jni/MojoMain_jni.h" #include "mojo/shell/init.h" #include "mojo/shell/run.h" @@ -27,28 +26,9 @@ base::AtExitManager* g_at_exit = 0; LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = LAZY_INSTANCE_INITIALIZER; -LazyInstance<scoped_ptr<base::Thread> > g_shell_thread = - LAZY_INSTANCE_INITIALIZER; - LazyInstance<scoped_ptr<shell::Context> > g_context = LAZY_INSTANCE_INITIALIZER; -struct ShellInit { - scoped_refptr<base::SingleThreadTaskRunner> java_runner; - base::android::ScopedJavaGlobalRef<jobject> activity; -}; - -void StartOnShellThread(ShellInit* init) { - shell::Context* context = new shell::Context(); - - context->set_activity(init->activity.obj()); - context->task_runners()->set_java_runner(init->java_runner.get()); - delete init; - - g_context.Get().reset(context); - shell::Run(context); -} - } // namspace static void Init(JNIEnv* env, jclass clazz, jobject context) { @@ -83,16 +63,13 @@ static void Start(JNIEnv* env, jclass clazz, jobject context, jstring jurl) { CommandLine::ForCurrentProcess()->InitFromArgv(argv); } - ShellInit* init = new ShellInit(); - init->java_runner = base::MessageLoopForUI::current()->message_loop_proxy(); - init->activity.Reset(env, context); - - g_shell_thread.Get().reset(new base::Thread("shell_thread")); - g_shell_thread.Get()->Start(); - g_shell_thread.Get()->message_loop()->PostTask(FROM_HERE, - base::Bind(StartOnShellThread, init)); + base::android::ScopedJavaGlobalRef<jobject> activity; + activity.Reset(env, context); - // TODO(abarth): Currently we leak g_shell_thread. + shell::Context* shell_context = new shell::Context(); + shell_context->set_activity(activity.obj()); + g_context.Get().reset(shell_context); + shell::Run(shell_context); } bool RegisterMojoMain(JNIEnv* env) { diff --git a/mojo/shell/task_runners.h b/mojo/shell/task_runners.h index 509c5ae..7311cad 100644 --- a/mojo/shell/task_runners.h +++ b/mojo/shell/task_runners.h @@ -34,26 +34,13 @@ class TaskRunners { return cache_thread_->message_loop_proxy(); } -#if defined(OS_ANDROID) - void set_java_runner(base::SingleThreadTaskRunner* java_runner) { - java_runner_ = java_runner; - } - - base::SingleThreadTaskRunner* java_runner() const { - return java_runner_.get(); - } -#endif // defined(OS_ANDROID) - private: + // TODO(beng): should this be named shell_runner_? scoped_refptr<base::SingleThreadTaskRunner> ui_runner_; scoped_ptr<base::Thread> cache_thread_; scoped_ptr<base::Thread> io_thread_; scoped_ptr<base::Thread> file_thread_; -#if defined(OS_ANDROID) - scoped_refptr<base::SingleThreadTaskRunner> java_runner_; -#endif // defined(OS_ANDROID) - DISALLOW_COPY_AND_ASSIGN(TaskRunners); }; |