| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 bool use_zygote, | 69 bool use_zygote, |
| 70 const base::environment_vector& environ, | 70 const base::environment_vector& environ, |
| 71 #endif | 71 #endif |
| 72 CommandLine* cmd_line); | 72 CommandLine* cmd_line); |
| 73 | 73 |
| 74 // Returns the handle of the child process. This can be called only after | 74 // Returns the handle of the child process. This can be called only after |
| 75 // OnProcessLaunched is called or it will be invalid and may crash. | 75 // OnProcessLaunched is called or it will be invalid and may crash. |
| 76 base::ProcessHandle GetChildProcessHandle() const; | 76 base::ProcessHandle GetChildProcessHandle() const; |
| 77 | 77 |
| 78 // ChildProcessLauncher::Client implementation. | 78 // ChildProcessLauncher::Client implementation. |
| 79 virtual void OnProcessLaunched() {} | 79 virtual void OnProcessLaunched() OVERRIDE {} |
| 80 | 80 |
| 81 // Derived classes can override this to know if the process crashed. | 81 // Derived classes can override this to know if the process crashed. |
| 82 // |exit_code| is the status returned when the process crashed (for | 82 // |exit_code| is the status returned when the process crashed (for |
| 83 // posix, as returned from waitpid(), for Windows, as returned from | 83 // posix, as returned from waitpid(), for Windows, as returned from |
| 84 // GetExitCodeProcess()). | 84 // GetExitCodeProcess()). |
| 85 virtual void OnProcessCrashed(int exit_code) {} | 85 virtual void OnProcessCrashed(int exit_code) {} |
| 86 | 86 |
| 87 // Derived classes can override this to know if the process was | 87 // Derived classes can override this to know if the process was |
| 88 // killed. |exit_code| is the status returned when the process | 88 // killed. |exit_code| is the status returned when the process |
| 89 // was killed (for posix, as returned from waitpid(), for Windows, | 89 // was killed (for posix, as returned from waitpid(), for Windows, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 111 // Sends the given notification on the UI thread. | 111 // Sends the given notification on the UI thread. |
| 112 void Notify(int type); | 112 void Notify(int type); |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 // By using an internal class as the ChildProcessLauncher::Client, we can | 115 // By using an internal class as the ChildProcessLauncher::Client, we can |
| 116 // intercept OnProcessLaunched and do our own processing before | 116 // intercept OnProcessLaunched and do our own processing before |
| 117 // calling the subclass' implementation. | 117 // calling the subclass' implementation. |
| 118 class ClientHook : public ChildProcessLauncher::Client { | 118 class ClientHook : public ChildProcessLauncher::Client { |
| 119 public: | 119 public: |
| 120 explicit ClientHook(BrowserChildProcessHost* host); | 120 explicit ClientHook(BrowserChildProcessHost* host); |
| 121 virtual void OnProcessLaunched(); | 121 virtual void OnProcessLaunched() OVERRIDE; |
| 122 private: | 122 private: |
| 123 BrowserChildProcessHost* host_; | 123 BrowserChildProcessHost* host_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 ClientHook client_; | 126 ClientHook client_; |
| 127 scoped_ptr<ChildProcessLauncher> child_process_; | 127 scoped_ptr<ChildProcessLauncher> child_process_; |
| 128 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 129 base::WaitableEventWatcher child_watcher_; | 129 base::WaitableEventWatcher child_watcher_; |
| 130 #else | 130 #else |
| 131 base::WeakPtrFactory<BrowserChildProcessHost> task_factory_; | 131 base::WeakPtrFactory<BrowserChildProcessHost> task_factory_; |
| 132 #endif | 132 #endif |
| 133 bool disconnect_was_alive_; | 133 bool disconnect_was_alive_; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 136 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |