OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
7 | 7 |
8 #include "base/process.h" | 8 #include "base/process.h" |
9 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 9 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" |
10 | 10 |
| 11 namespace base { |
11 class FilePath; | 12 class FilePath; |
| 13 } |
12 | 14 |
13 namespace extensions { | 15 namespace extensions { |
14 | 16 |
15 class NativeProcessLauncher { | 17 class NativeProcessLauncher { |
16 public: | 18 public: |
17 // Callback that's called after the process has been launched. | 19 // Callback that's called after the process has been launched. |
18 // |native_process_handle| is set to base::kNullProcessHandle in case of a | 20 // |native_process_handle| is set to base::kNullProcessHandle in case of a |
19 // failure. | 21 // failure. |
20 typedef base::Callback<void (base::ProcessHandle native_process_handle, | 22 typedef base::Callback<void (base::ProcessHandle native_process_handle, |
21 base::PlatformFile read_file, | 23 base::PlatformFile read_file, |
22 base::PlatformFile write_file)> LaunchedCallback; | 24 base::PlatformFile write_file)> LaunchedCallback; |
23 | 25 |
24 static scoped_ptr<NativeProcessLauncher> CreateDefault(); | 26 static scoped_ptr<NativeProcessLauncher> CreateDefault(); |
25 | 27 |
26 NativeProcessLauncher() {} | 28 NativeProcessLauncher() {} |
27 virtual ~NativeProcessLauncher() {} | 29 virtual ~NativeProcessLauncher() {} |
28 | 30 |
29 // Launches native host with the specified name asynchronously. |callback| is | 31 // Launches native host with the specified name asynchronously. |callback| is |
30 // called after the process has been started. If the launcher is destroyed | 32 // called after the process has been started. If the launcher is destroyed |
31 // before the callback is called then the call is canceled and the process is | 33 // before the callback is called then the call is canceled and the process is |
32 // killed if it has been started already. | 34 // killed if it has been started already. |
33 virtual void Launch(const std::string& native_host_name, | 35 virtual void Launch(const std::string& native_host_name, |
34 LaunchedCallback callback) const = 0; | 36 LaunchedCallback callback) const = 0; |
35 | 37 |
36 protected: | 38 protected: |
37 static bool LaunchNativeProcess( | 39 static bool LaunchNativeProcess( |
38 const FilePath& path, | 40 const base::FilePath& path, |
39 base::ProcessHandle* native_process_handle, | 41 base::ProcessHandle* native_process_handle, |
40 base::PlatformFile* read_file, | 42 base::PlatformFile* read_file, |
41 base::PlatformFile* write_file); | 43 base::PlatformFile* write_file); |
42 | 44 |
43 private: | 45 private: |
44 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher); | 46 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher); |
45 }; | 47 }; |
46 | 48 |
47 } // namespace extensions | 49 } // namespace extensions |
48 | 50 |
49 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ | 51 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ |
OLD | NEW |