OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_MP_CHILD_PROCESS_CONTEXT_H_ |
| 6 #define BASE_MP_CHILD_PROCESS_CONTEXT_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" |
| 10 #include "base/process.h" |
| 11 #include "base/ref_counted.h" |
| 12 #include "base/task.h" |
| 13 #include "base/tracked.h" |
| 14 #include <string> |
| 15 |
| 16 class CommandLine; |
| 17 class MessageLoop; |
| 18 |
| 19 namespace base { |
| 20 |
| 21 class MpChildProcessContext { |
| 22 public: |
| 23 // Return the bad message received application exit code. |
| 24 virtual int GetBadMessageResultCode() = 0; |
| 25 |
| 26 // Return the normal application exit code. |
| 27 virtual int GetNormalExitResultCode() = 0; |
| 28 |
| 29 // Generate a randome channel ID value. |
| 30 virtual std::string GenerateRandomChannelID(void* instance) = 0; |
| 31 |
| 32 // Return the identifier for the current thread. |
| 33 virtual bool GetCurrentThreadIdentifier(int* identifier) = 0; |
| 34 |
| 35 // Return true if currently on the specified thread. |
| 36 virtual bool CurrentlyOnThread(int identifier) = 0; |
| 37 |
| 38 // Post a task to the specified thread. |
| 39 virtual bool PostTask(int identifier, |
| 40 const tracked_objects::Location& from_here, |
| 41 Task* task) = 0; |
| 42 |
| 43 // Post a task to the thread responsible for launching processes. |
| 44 virtual bool PostProcessLauncherTask( |
| 45 const tracked_objects::Location& from_here, |
| 46 Task* task) = 0; |
| 47 |
| 48 // Derived classes implement this method to create the process. |
| 49 virtual base::ProcessHandle StartProcess( |
| 50 #if defined(OS_WIN) |
| 51 const FilePath& exposed_dir, |
| 52 #elif defined(OS_POSIX) |
| 53 bool use_zygote, |
| 54 const base::environment_vector& environ, |
| 55 int ipcfd, |
| 56 #endif |
| 57 CommandLine* cmd_line) = 0; |
| 58 |
| 59 // Derived classes implement this method to ensure that the process is |
| 60 // terminated. |
| 61 virtual void EnsureProcessTerminated(base::ProcessHandle) = 0; |
| 62 |
| 63 // Derived classes implement this method to check if a process has crashed. |
| 64 virtual bool CheckProcessCrash(bool* child_exited, |
| 65 #if defined(OS_POSIX) |
| 66 bool use_zygote, |
| 67 #endif |
| 68 base::ProcessHandle handle) = 0; |
| 69 }; |
| 70 |
| 71 } // namespace base |
| 72 |
| 73 #endif // BASE_MP_CHILD_PROCESS_CONTEXT_H_ |
OLD | NEW |