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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_process_launcher.h

Issue 12386018: Revert 185189. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class GURL;
12
13 namespace base { 11 namespace base {
14 class FilePath; 12 class FilePath;
15 } 13 }
16 14
17 namespace extensions { 15 namespace extensions {
18 16
19 class NativeMessagingHostManifest;
20
21 class NativeProcessLauncher { 17 class NativeProcessLauncher {
22 public: 18 public:
23 // Callback that's called after the process has been launched. |result| is 19 // Callback that's called after the process has been launched. |result| is
24 // set to false in case of a failure. Handler must take ownership of the IO 20 // set to false in case of a failure. Handler must take ownership of the IO
25 // handles. 21 // handles.
26 typedef base::Callback<void (bool result, 22 typedef base::Callback<void (bool result,
27 base::PlatformFile read_file, 23 base::PlatformFile read_file,
28 base::PlatformFile write_file)> LaunchedCallback; 24 base::PlatformFile write_file)> LaunchedCallback;
29 25
30 static scoped_ptr<NativeProcessLauncher> CreateDefault(); 26 static scoped_ptr<NativeProcessLauncher> CreateDefault();
31 27
32 NativeProcessLauncher() {} 28 NativeProcessLauncher() {}
33 virtual ~NativeProcessLauncher() {} 29 virtual ~NativeProcessLauncher() {}
34 30
35 // Finds native messaging host with the specified name and launches it 31 // Launches native host with the specified name asynchronously. |callback| is
36 // asynchronously. Also checks that the specified |origin| is permitted to 32 // called after the process has been started. If the launcher is destroyed
37 // access the host. |callback| is called after the process has been started. 33 // before the callback is called then the call is canceled and the process is
38 // If the launcher is destroyed before the callback is called then the call is 34 // stopped if it has been started already (by closing IO pipes).
39 // canceled and the process is stopped if it has been started already (by 35 virtual void Launch(const std::string& native_host_name,
40 // closing IO pipes).
41 virtual void Launch(const GURL& origin,
42 const std::string& native_host_name,
43 LaunchedCallback callback) const = 0; 36 LaunchedCallback callback) const = 0;
44 37
45 protected: 38 protected:
46 // The following two methods are platform specific and are implemented in
47 // platform-specific .cc files.
48
49 // Loads manifest for the native messaging host |name|.
50 static scoped_ptr<NativeMessagingHostManifest> FindAndLoadManifest(
51 const std::string& native_host_name,
52 std::string* error_message);
53
54 // Launches native messaging process.
55 static bool LaunchNativeProcess( 39 static bool LaunchNativeProcess(
56 const base::FilePath& path, 40 const base::FilePath& path,
57 base::PlatformFile* read_file, 41 base::PlatformFile* read_file,
58 base::PlatformFile* write_file); 42 base::PlatformFile* write_file);
59 43
60 private: 44 private:
61 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher); 45 DISALLOW_COPY_AND_ASSIGN(NativeProcessLauncher);
62 }; 46 };
63 47
64 } // namespace extensions 48 } // namespace extensions
65 49
66 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_ 50 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698