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

Unified Diff: services/service_manager/runner/host/service_process_launcher.h

Issue 2576233002: Consolidating the mojo NativeRunner functionality. (Closed)
Patch Set: Merged mojo_runner_host_unittests in service_manager_unittests Created 4 years 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
Index: services/service_manager/runner/host/service_process_launcher.h
diff --git a/services/service_manager/runner/host/child_process_host.h b/services/service_manager/runner/host/service_process_launcher.h
similarity index 65%
rename from services/service_manager/runner/host/child_process_host.h
rename to services/service_manager/runner/host/service_process_launcher.h
index ab87d02ae29048e8c89489bfe762c80f6c8bc269..d117f7c82bd079959214bae484aafdd18b396986 100644
--- a/services/service_manager/runner/host/child_process_host.h
+++ b/services/service_manager/runner/host/service_process_launcher.h
@@ -2,37 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef SERVICES_SERVICE_MANAGER_RUNNER_HOST_CHILD_PROCESS_HOST_H_
-#define SERVICES_SERVICE_MANAGER_RUNNER_HOST_CHILD_PROCESS_HOST_H_
-
-#include <stdint.h>
+#ifndef SERVICES_SERVICE_MANAGER_RUNNER_HOST_SERVICE_PROCESS_LAUNCHER_H_
+#define SERVICES_SERVICE_MANAGER_RUNNER_HOST_SERVICE_PROCESS_LAUNCHER_H_
#include <memory>
#include <string>
#include "base/callback.h"
-#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process.h"
-#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-#include "services/service_manager/public/cpp/identity.h"
#include "services/service_manager/public/interfaces/service_factory.mojom.h"
-#include "services/service_manager/runner/host/child_process_host.h"
namespace base {
+class CommandLine;
class TaskRunner;
}
namespace service_manager {
class Identity;
-class NativeRunnerDelegate;
// This class represents a "child process host". Handles launching and
// connecting a platform-specific "pipe" to the child, and supports joining the
@@ -43,37 +36,45 @@ class NativeRunnerDelegate;
// single thread.
//
// Note: Does not currently work on Windows before Vista.
-class ChildProcessHost {
+class ServiceProcessLauncher {
public:
using ProcessReadyCallback = base::Callback<void(base::ProcessId)>;
+ class Delegate {
+ public:
+ // Called to adjust the commandline for launching the specified app.
+ // WARNING: this is called on a background thread.
+ virtual void AdjustCommandLineArgumentsForTarget(
+ const Identity& target,
+ base::CommandLine* command_line) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
// |name| is just for debugging ease. We will spawn off a process so that it
// can be sandboxed if |start_sandboxed| is true. |service_path| is a path to
// the service executable we wish to start.
- ChildProcessHost(base::TaskRunner* launch_process_runner,
- NativeRunnerDelegate* delegate,
- bool start_sandboxed,
- const Identity& target,
- const base::FilePath& service_path);
- virtual ~ChildProcessHost();
+ ServiceProcessLauncher(base::TaskRunner* launch_process_runner,
+ Delegate* delegate,
+ const base::FilePath& service_path);
+ ~ServiceProcessLauncher();
// |Start()|s the child process; calls |DidStart()| (on the thread on which
// |Start()| was called) when the child has been started (or failed to start).
mojom::ServicePtr Start(const Identity& target,
- const ProcessReadyCallback& callback,
- const base::Closure& quit_closure);
+ bool start_sandboxed,
+ const ProcessReadyCallback& callback);
// Waits for the child process to terminate.
void Join();
- protected:
- void DidStart(const ProcessReadyCallback& callback);
-
private:
+ void DidStart(const ProcessReadyCallback& callback);
void DoLaunch(std::unique_ptr<base::CommandLine> child_command_line);
scoped_refptr<base::TaskRunner> launch_process_runner_;
- NativeRunnerDelegate* delegate_ = nullptr;
+ Delegate* delegate_ = nullptr;
bool start_sandboxed_ = false;
Identity target_;
base::FilePath service_path_;
@@ -88,11 +89,18 @@ class ChildProcessHost {
// the main thread if it tries to destruct |this| while launching the process.
base::WaitableEvent start_child_process_event_;
- base::WeakPtrFactory<ChildProcessHost> weak_factory_;
+ base::WeakPtrFactory<ServiceProcessLauncher> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncher);
+};
- DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
+class ServiceProcessLauncherFactory {
+ public:
+ virtual ~ServiceProcessLauncherFactory() {}
+ virtual std::unique_ptr<ServiceProcessLauncher> Create(
+ const base::FilePath& service_path) = 0;
};
} // namespace service_manager
-#endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_CHILD_PROCESS_HOST_H_
+#endif // SERVICES_SERVICE_MANAGER_RUNNER_HOST_SERVICE_PROCESS_LAUNCHER_H_

Powered by Google App Engine
This is Rietveld 408576698