Moves BackgroundShellApplicationLoader to shell/android

As this is the only place that uses it. Also renamed to
BackgroundApplicationLoader.

BUG=none
TEST=none
R=qsr@chromium.org

Review URL: https://codereview.chromium.org/788243007
diff --git a/mojo/application_manager/BUILD.gn b/mojo/application_manager/BUILD.gn
index c1cf8ed..7437534 100644
--- a/mojo/application_manager/BUILD.gn
+++ b/mojo/application_manager/BUILD.gn
@@ -13,8 +13,6 @@
     "application_manager.cc",
     "application_manager.h",
     "application_manager_export.h",
-    "background_shell_application_loader.cc",
-    "background_shell_application_loader.h",
   ]
 
   defines = [ "MOJO_APPLICATION_MANAGER_IMPLEMENTATION" ]
@@ -41,7 +39,6 @@
 test("mojo_application_manager_unittests") {
   sources = [
     "application_manager_unittest.cc",
-    "background_shell_application_loader_unittest.cc",
   ]
 
   deps = [
diff --git a/shell/BUILD.gn b/shell/BUILD.gn
index 4506cc2..d36b7bb 100644
--- a/shell/BUILD.gn
+++ b/shell/BUILD.gn
@@ -196,6 +196,8 @@
       "android/android_handler.h",
       "android/android_handler_loader.cc",
       "android/android_handler_loader.h",
+      "android/background_application_loader.cc",
+      "android/background_application_loader.h",
       "android/native_viewport_application_loader.cc",
       "android/native_viewport_application_loader.h",
       "android/ui_application_loader_android.cc",
@@ -398,6 +400,8 @@
   ]
 
   if (is_android) {
+    sources += [ "android/background_application_loader_unittest.cc" ]
+
     deps += [
       # TODO(GYP):
       #'../testing/android/native_test.gyp:native_test_native_code',
diff --git a/mojo/application_manager/background_shell_application_loader.cc b/shell/android/background_application_loader.cc
similarity index 67%
rename from mojo/application_manager/background_shell_application_loader.cc
rename to shell/android/background_application_loader.cc
index a89e36a..8e6d0f4 100644
--- a/mojo/application_manager/background_shell_application_loader.cc
+++ b/shell/android/background_application_loader.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/application_manager/background_shell_application_loader.h"
+#include "shell/android/background_application_loader.h"
 
 #include "base/bind.h"
 #include "base/run_loop.h"
@@ -10,7 +10,7 @@
 
 namespace mojo {
 
-BackgroundShellApplicationLoader::BackgroundShellApplicationLoader(
+BackgroundApplicationLoader::BackgroundApplicationLoader(
     scoped_ptr<ApplicationLoader> real_loader,
     const std::string& thread_name,
     base::MessageLoop::Type message_loop_type)
@@ -20,16 +20,15 @@
       message_loop_created_(true, false) {
 }
 
-BackgroundShellApplicationLoader::~BackgroundShellApplicationLoader() {
+BackgroundApplicationLoader::~BackgroundApplicationLoader() {
   if (thread_)
     thread_->Join();
 }
 
-void BackgroundShellApplicationLoader::Load(
-    ApplicationManager* manager,
-    const GURL& url,
-    ScopedMessagePipeHandle shell_handle,
-    LoadCallback callback) {
+void BackgroundApplicationLoader::Load(ApplicationManager* manager,
+                                       const GURL& url,
+                                       ScopedMessagePipeHandle shell_handle,
+                                       LoadCallback callback) {
   DCHECK(shell_handle.is_valid());
   if (!thread_) {
     // TODO(tim): It'd be nice if we could just have each Load call
@@ -46,23 +45,22 @@
 
   task_runner_->PostTask(
       FROM_HERE,
-      base::Bind(&BackgroundShellApplicationLoader::LoadOnBackgroundThread,
+      base::Bind(&BackgroundApplicationLoader::LoadOnBackgroundThread,
                  base::Unretained(this), manager, url,
                  base::Passed(&shell_handle)));
 }
 
-void BackgroundShellApplicationLoader::OnApplicationError(
+void BackgroundApplicationLoader::OnApplicationError(
     ApplicationManager* manager,
     const GURL& url) {
-  task_runner_->PostTask(FROM_HERE,
-                         base::Bind(&BackgroundShellApplicationLoader::
-                                        OnApplicationErrorOnBackgroundThread,
-                                    base::Unretained(this),
-                                    manager,
-                                    url));
+  task_runner_->PostTask(
+      FROM_HERE,
+      base::Bind(
+          &BackgroundApplicationLoader::OnApplicationErrorOnBackgroundThread,
+          base::Unretained(this), manager, url));
 }
 
-void BackgroundShellApplicationLoader::Run() {
+void BackgroundApplicationLoader::Run() {
   base::MessageLoop message_loop(message_loop_type_);
   base::RunLoop loop;
   task_runner_ = message_loop.task_runner();
@@ -74,7 +72,7 @@
   loader_.reset();
 }
 
-void BackgroundShellApplicationLoader::LoadOnBackgroundThread(
+void BackgroundApplicationLoader::LoadOnBackgroundThread(
     ApplicationManager* manager,
     const GURL& url,
     ScopedMessagePipeHandle shell_handle) {
@@ -82,7 +80,7 @@
   loader_->Load(manager, url, shell_handle.Pass(), SimpleLoadCallback());
 }
 
-void BackgroundShellApplicationLoader::OnApplicationErrorOnBackgroundThread(
+void BackgroundApplicationLoader::OnApplicationErrorOnBackgroundThread(
     ApplicationManager* manager,
     const GURL& url) {
   DCHECK(task_runner_->RunsTasksOnCurrentThread());
diff --git a/mojo/application_manager/background_shell_application_loader.h b/shell/android/background_application_loader.h
similarity index 72%
rename from mojo/application_manager/background_shell_application_loader.h
rename to shell/android/background_application_loader.h
index a1d8ef3..5321d97 100644
--- a/mojo/application_manager/background_shell_application_loader.h
+++ b/shell/android/background_application_loader.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_
-#define MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_
+#ifndef SHELL_ANDROID_BACKGROUND_APPLICATION_LOADER_H_
+#define SHELL_ANDROID_BACKGROUND_APPLICATION_LOADER_H_
 
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
@@ -14,17 +14,14 @@
 
 namespace mojo {
 
-// TODO(tim): Eventually this should be Android-only to support services
-// that we need to bundle with the shell (such as NetworkService). Perhaps
-// we should move it to shell/ as well.
-class MOJO_APPLICATION_MANAGER_EXPORT BackgroundShellApplicationLoader
+class MOJO_APPLICATION_MANAGER_EXPORT BackgroundApplicationLoader
     : public ApplicationLoader,
       public base::DelegateSimpleThread::Delegate {
  public:
-  BackgroundShellApplicationLoader(scoped_ptr<ApplicationLoader> real_loader,
-                                   const std::string& thread_name,
-                                   base::MessageLoop::Type message_loop_type);
-  ~BackgroundShellApplicationLoader() override;
+  BackgroundApplicationLoader(scoped_ptr<ApplicationLoader> real_loader,
+                              const std::string& thread_name,
+                              base::MessageLoop::Type message_loop_type);
+  ~BackgroundApplicationLoader() override;
 
   // ApplicationLoader overrides:
   void Load(ApplicationManager* manager,
@@ -65,9 +62,9 @@
 
   scoped_ptr<base::DelegateSimpleThread> thread_;
 
-  DISALLOW_COPY_AND_ASSIGN(BackgroundShellApplicationLoader);
+  DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationLoader);
 };
 
 }  // namespace mojo
 
-#endif  // MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_
+#endif  // SHELL_ANDROID_BACKGROUND_APPLICATION_LOADER_H_
diff --git a/mojo/application_manager/background_shell_application_loader_unittest.cc b/shell/android/background_application_loader_unittest.cc
similarity index 75%
rename from mojo/application_manager/background_shell_application_loader_unittest.cc
rename to shell/android/background_application_loader_unittest.cc
index b783a72..09bc2c8 100644
--- a/mojo/application_manager/background_shell_application_loader_unittest.cc
+++ b/shell/android/background_application_loader_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "mojo/application_manager/background_shell_application_loader.h"
+#include "shell/android/background_application_loader.h"
 
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -36,18 +36,18 @@
 }  // namespace
 
 // Tests that the loader can start and stop gracefully.
-TEST(BackgroundShellApplicationLoaderTest, StartStop) {
+TEST(BackgroundApplicationLoaderTest, StartStop) {
   scoped_ptr<ApplicationLoader> real_loader(new DummyLoader());
-  BackgroundShellApplicationLoader loader(
-      real_loader.Pass(), "test", base::MessageLoop::TYPE_DEFAULT);
+  BackgroundApplicationLoader loader(real_loader.Pass(), "test",
+                                     base::MessageLoop::TYPE_DEFAULT);
 }
 
 // Tests that the loader can load a service that is well behaved (quits
 // itself).
-TEST(BackgroundShellApplicationLoaderTest, Load) {
+TEST(BackgroundApplicationLoaderTest, Load) {
   scoped_ptr<ApplicationLoader> real_loader(new DummyLoader());
-  BackgroundShellApplicationLoader loader(
-      real_loader.Pass(), "test", base::MessageLoop::TYPE_DEFAULT);
+  BackgroundApplicationLoader loader(real_loader.Pass(), "test",
+                                     base::MessageLoop::TYPE_DEFAULT);
   MessagePipe dummy;
   loader.Load(NULL, GURL(), dummy.handle0.Pass(),
               ApplicationLoader::SimpleLoadCallback());
diff --git a/shell/android/mojo_main.cc b/shell/android/mojo_main.cc
index d19e3db..086d29f 100644
--- a/shell/android/mojo_main.cc
+++ b/shell/android/mojo_main.cc
@@ -18,8 +18,8 @@
 #include "base/message_loop/message_loop.h"
 #include "jni/MojoMain_jni.h"
 #include "mojo/application_manager/application_loader.h"
-#include "mojo/application_manager/background_shell_application_loader.h"
 #include "shell/android/android_handler_loader.h"
+#include "shell/android/background_application_loader.h"
 #include "shell/android/native_viewport_application_loader.h"
 #include "shell/android/ui_application_loader_android.h"
 #include "shell/context.h"
@@ -52,7 +52,7 @@
   // MojoShell application as the JNI bridge to bootstrap execution of other
   // Android Mojo apps that need JNI.
   context->application_manager()->SetLoaderForURL(
-      make_scoped_ptr(new BackgroundShellApplicationLoader(
+      make_scoped_ptr(new BackgroundApplicationLoader(
           make_scoped_ptr(new AndroidHandlerLoader()), "android_handler",
           base::MessageLoop::TYPE_DEFAULT)),
       GURL("mojo:android_handler"));
diff --git a/shell/context.cc b/shell/context.cc
index c38de5e..cd65273 100644
--- a/shell/context.cc
+++ b/shell/context.cc
@@ -17,7 +17,6 @@
 #include "build/build_config.h"
 #include "mojo/application_manager/application_loader.h"
 #include "mojo/application_manager/application_manager.h"
-#include "mojo/application_manager/background_shell_application_loader.h"
 #include "mojo/common/tracing_impl.h"
 #include "mojo/edk/embedder/embedder.h"
 #include "mojo/edk/embedder/simple_platform_support.h"