More shell cleanup: Move NativeRunner(Factory) to native_runner.h.
(I also want to move the contents of dynamic_service_runner.{h,cc} into
native_runner.{h,cc}, but apparently I have to rectify some issues with
the thunks targets first.)
R=jamesr@chromium.org
Review URL: https://codereview.chromium.org/961053005
diff --git a/shell/application_manager/BUILD.gn b/shell/application_manager/BUILD.gn
index b53e473..c63eee0 100644
--- a/shell/application_manager/BUILD.gn
+++ b/shell/application_manager/BUILD.gn
@@ -5,7 +5,7 @@
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")
-component("application_manager") {
+source_set("application_manager") {
output_name = "mojo_application_manager"
sources = [
"application_loader.h",
@@ -17,6 +17,7 @@
"fetcher.h",
"local_fetcher.cc",
"local_fetcher.h",
+ "native_runner.h",
"network_fetcher.cc",
"network_fetcher.h",
"query_util.cc",
@@ -25,8 +26,6 @@
"shell_impl.h",
]
- defines = [ "MOJO_APPLICATION_MANAGER_IMPLEMENTATION" ]
-
public_deps = [
"//base",
"//mojo/common",
diff --git a/shell/application_manager/application_manager.cc b/shell/application_manager/application_manager.cc
index 64b7c0f..11f8759 100644
--- a/shell/application_manager/application_manager.cc
+++ b/shell/application_manager/application_manager.cc
@@ -5,19 +5,18 @@
#include "shell/application_manager/application_manager.h"
#include "base/bind.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/error_handler.h"
-#include "mojo/public/interfaces/application/shell.mojom.h"
#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
#include "shell/application_manager/fetcher.h"
#include "shell/application_manager/local_fetcher.h"
#include "shell/application_manager/network_fetcher.h"
#include "shell/application_manager/query_util.h"
+#include "shell/application_manager/shell_impl.h"
namespace mojo {
namespace shell {
diff --git a/shell/application_manager/application_manager.h b/shell/application_manager/application_manager.h
index 52b0ec6..38784d7 100644
--- a/shell/application_manager/application_manager.h
+++ b/shell/application_manager/application_manager.h
@@ -7,18 +7,16 @@
#include <map>
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/gtest_prod_util.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/interfaces/application/application.mojom.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
#include "shell/application_manager/application_loader.h"
-#include "shell/application_manager/fetcher.h"
-#include "shell/application_manager/shell_impl.h"
+#include "shell/application_manager/native_runner.h"
#include "url/gurl.h"
namespace base {
@@ -29,42 +27,8 @@
namespace mojo {
namespace shell {
-// ApplicationManager requires implementations of NativeRunner and
-// NativeRunnerFactory to run native applications.
-class NativeRunner {
- public:
- // Parameter for |Start()| to specify its cleanup behavior.
- enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath };
-
- virtual ~NativeRunner() {}
-
- // Loads the app in the file at |app_path| and runs it on some other
- // thread/process. If |cleanup_behavior| is |true|, takes ownership of the
- // file. |app_completed_callback| is posted (to the thread on which |Start()|
- // was called) after |MojoMain()| completes.
- // TODO(vtl): |app_path| and |cleanup_behavior| should probably be moved to
- // the factory's Create(). Rationale: The factory may need information from
- // the file to decide what kind of NativeRunner to make.
- virtual void Start(const base::FilePath& app_path,
- CleanupBehavior cleanup_behavior,
- InterfaceRequest<Application> application_request,
- const base::Closure& app_completed_callback) = 0;
-};
-
-class NativeRunnerFactory {
- public:
- // Options for running the native app. (This will contain, e.g., information
- // about the sandbox profile, etc.)
- struct Options {
- // Constructs with default options.
- Options() : force_in_process(false) {}
-
- bool force_in_process;
- };
-
- virtual ~NativeRunnerFactory() {}
- virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0;
-};
+class Fetcher;
+class ShellImpl;
class ApplicationManager {
public:
diff --git a/shell/application_manager/native_runner.h b/shell/application_manager/native_runner.h
new file mode 100644
index 0000000..b9b0304
--- /dev/null
+++ b/shell/application_manager/native_runner.h
@@ -0,0 +1,60 @@
+// Copyright 2015 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.
+
+#ifndef SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_
+#define SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_
+
+#include "base/callback_forward.h"
+#include "base/memory/scoped_ptr.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/interfaces/application/application.mojom.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace mojo {
+namespace shell {
+
+// ApplicationManager requires implementations of NativeRunner and
+// NativeRunnerFactory to run native applications.
+class NativeRunner {
+ public:
+ // Parameter for |Start()| to specify its cleanup behavior.
+ enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath };
+
+ virtual ~NativeRunner() {}
+
+ // Loads the app in the file at |app_path| and runs it on some other
+ // thread/process. If |cleanup_behavior| is |true|, takes ownership of the
+ // file. |app_completed_callback| is posted (to the thread on which |Start()|
+ // was called) after |MojoMain()| completes.
+ // TODO(vtl): |app_path| and |cleanup_behavior| should probably be moved to
+ // the factory's Create(). Rationale: The factory may need information from
+ // the file to decide what kind of NativeRunner to make.
+ virtual void Start(const base::FilePath& app_path,
+ CleanupBehavior cleanup_behavior,
+ InterfaceRequest<Application> application_request,
+ const base::Closure& app_completed_callback) = 0;
+};
+
+class NativeRunnerFactory {
+ public:
+ // Options for running the native app. (This will contain, e.g., information
+ // about the sandbox profile, etc.)
+ struct Options {
+ // Constructs with default options.
+ Options() : force_in_process(false) {}
+
+ bool force_in_process;
+ };
+
+ virtual ~NativeRunnerFactory() {}
+ virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0;
+};
+
+} // namespace shell
+} // namespace mojo
+
+#endif // SHELL_APPLICATION_MANAGER_NATIVE_RUNNER_H_
diff --git a/shell/application_manager/query_util_unittest.cc b/shell/application_manager/query_util_unittest.cc
index a5309f3..b10a475 100644
--- a/shell/application_manager/query_util_unittest.cc
+++ b/shell/application_manager/query_util_unittest.cc
@@ -42,6 +42,6 @@
EXPECT_EQ(query, "?a=b&c=d");
}
+} // namespace
} // namespace shell
} // namespace mojo
-} // namespace
diff --git a/shell/in_process_native_runner.cc b/shell/in_process_native_runner.cc
index 8582e8a..c6f6e45 100644
--- a/shell/in_process_native_runner.cc
+++ b/shell/in_process_native_runner.cc
@@ -9,6 +9,7 @@
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/threading/platform_thread.h"
+#include "shell/dynamic_service_runner.h"
namespace mojo {
namespace shell {
diff --git a/shell/in_process_native_runner.h b/shell/in_process_native_runner.h
index f8abac1..952b448 100644
--- a/shell/in_process_native_runner.h
+++ b/shell/in_process_native_runner.h
@@ -11,8 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/scoped_native_library.h"
#include "base/threading/simple_thread.h"
-#include "shell/application_manager/application_manager.h"
-#include "shell/dynamic_service_runner.h"
+#include "shell/application_manager/native_runner.h"
namespace mojo {
namespace shell {
diff --git a/shell/out_of_process_native_runner.cc b/shell/out_of_process_native_runner.cc
index 1175b79..d8f824a 100644
--- a/shell/out_of_process_native_runner.cc
+++ b/shell/out_of_process_native_runner.cc
@@ -8,7 +8,6 @@
#include "base/callback_helpers.h"
#include "base/files/file_util.h"
#include "base/logging.h"
-#include "base/scoped_native_library.h"
#include "shell/app_child_process.mojom.h"
#include "shell/app_child_process_host.h"
#include "shell/in_process_native_runner.h"
diff --git a/shell/out_of_process_native_runner.h b/shell/out_of_process_native_runner.h
index d449957..397ced5 100644
--- a/shell/out_of_process_native_runner.h
+++ b/shell/out_of_process_native_runner.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/error_handler.h"
-#include "shell/application_manager/application_manager.h"
+#include "shell/application_manager/native_runner.h"
namespace mojo {
namespace shell {