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

Unified Diff: base/mp/mp_child_process_launcher.h

Issue 1625015: Refactor ChildProcess and related classes to create a framework outside of br... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 8 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/mp/mp_child_process_host.cc ('k') | base/mp/mp_child_process_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mp/mp_child_process_launcher.h
===================================================================
--- base/mp/mp_child_process_launcher.h (revision 0)
+++ base/mp/mp_child_process_launcher.h (revision 0)
@@ -0,0 +1,72 @@
+// Copyright (c) 2010 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 BASE_MP_CHILD_PROCESS_LAUNCHER_H_
+#define BASE_MP_CHILD_PROCESS_LAUNCHER_H_
+
+#include "base/basictypes.h"
+#include "base/mp/mp_child_process_context.h"
+#include "base/process_util.h"
+#include "base/ref_counted.h"
+
+class CommandLine;
+class MessageLoop;
+
+namespace base {
+
+// Launches a process asynchronously and notifies the client of the process
+// handle when it's available. It's used to avoid blocking the calling thread
+// on the OS since often it can take > 100 ms to create the process.
+class MpChildProcessLauncher {
+ public:
+ class Client {
+ public:
+ // Will be called on the thread that the MpChildProcessLauncher was
+ // constructed on.
+ virtual void OnProcessLaunched() = 0;
+ };
+
+ // Launches the process asynchronously, calling the client when the result is
+ // ready. Deleting this object before the process is created is safe, since
+ // the callback won't be called. If the process is still running by the time
+ // this object destructs, it will be terminated.
+ // Takes ownership of cmd_line.
+ MpChildProcessLauncher(
+#if defined(OS_WIN)
+ const FilePath& exposed_dir,
+#elif defined(OS_POSIX)
+ bool use_zygote,
+ const base::environment_vector& environ,
+ int ipcfd,
+#endif
+ CommandLine* cmd_line,
+ MpChildProcessContext* context,
+ Client* client);
+ virtual ~MpChildProcessLauncher();
+
+ // True if the process is being launched and so the handle isn't available.
+ bool IsStarting();
+
+ // Getter for the process handle. Only call after the process has started.
+ base::ProcessHandle GetHandle();
+
+ // Call this when the process exits to know if a process crashed or not.
+ bool DidProcessCrash();
+
+ // Changes whether the process runs in the background or not. Only call
+ // this after the process has started.
+ void SetProcessBackgrounded(bool background);
+
+ private:
+ class Context;
+
+ scoped_refptr<Context> context_;
+ MpChildProcessContext* process_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(MpChildProcessLauncher);
+};
+
+} // namespace base
+
+#endif // BASE_MP_CHILD_PROCESS_LAUNCHER_H_
« no previous file with comments | « base/mp/mp_child_process_host.cc ('k') | base/mp/mp_child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698