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_COMMON_SERVICE_PROCESS_UTIL_H_ | 5 #ifndef CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ |
6 #define CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ | 6 #define CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "ipc/ipc_channel_handle.h" | 15 #include "mojo/edk/embedder/named_platform_handle.h" |
| 16 #include "mojo/edk/embedder/scoped_platform_handle.h" |
16 | 17 |
17 class MultiProcessLock; | 18 class MultiProcessLock; |
18 | 19 |
19 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
20 #ifdef __OBJC__ | 21 #ifdef __OBJC__ |
21 @class NSString; | 22 @class NSString; |
22 #else | 23 #else |
23 class NSString; | 24 class NSString; |
24 #endif | 25 #endif |
25 #endif | 26 #endif |
26 | 27 |
27 namespace base { | 28 namespace base { |
28 class CommandLine; | 29 class CommandLine; |
29 class SingleThreadTaskRunner; | 30 class SingleThreadTaskRunner; |
30 } | 31 } |
31 | 32 |
32 // Return the IPC channel to connect to the service process. | 33 // Return the IPC channel to connect to the service process. |
33 IPC::ChannelHandle GetServiceProcessChannel(); | 34 mojo::edk::NamedPlatformHandle GetServiceProcessChannel(); |
34 | 35 |
35 // Return a name that is scoped to this instance of the service process. We | 36 // Return a name that is scoped to this instance of the service process. We |
36 // use the user-data-dir as a scoping prefix. | 37 // use the user-data-dir as a scoping prefix. |
37 std::string GetServiceProcessScopedName(const std::string& append_str); | 38 std::string GetServiceProcessScopedName(const std::string& append_str); |
38 | 39 |
39 #if !defined(OS_MACOSX) | 40 #if !defined(OS_MACOSX) |
40 // Return a name that is scoped to this instance of the service process. We | 41 // Return a name that is scoped to this instance of the service process. We |
41 // use the user-data-dir and the version as a scoping prefix. | 42 // use the user-data-dir and the version as a scoping prefix. |
42 std::string GetServiceProcessScopedVersionedName(const std::string& append_str); | 43 std::string GetServiceProcessScopedVersionedName(const std::string& append_str); |
43 #endif // !OS_MACOSX | 44 #endif // !OS_MACOSX |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Signal that the service process is stopped. | 97 // Signal that the service process is stopped. |
97 void SignalStopped(); | 98 void SignalStopped(); |
98 | 99 |
99 // Register the service process to run on startup. | 100 // Register the service process to run on startup. |
100 bool AddToAutoRun(); | 101 bool AddToAutoRun(); |
101 | 102 |
102 // Unregister the service process to run on startup. | 103 // Unregister the service process to run on startup. |
103 bool RemoveFromAutoRun(); | 104 bool RemoveFromAutoRun(); |
104 | 105 |
105 // Return the channel handle used for communicating with the service. | 106 // Return the channel handle used for communicating with the service. |
106 IPC::ChannelHandle GetServiceProcessChannel(); | 107 #if defined(OS_MACOSX) |
| 108 mojo::edk::ScopedPlatformHandle GetServiceProcessChannel(); |
| 109 #else |
| 110 mojo::edk::NamedPlatformHandle GetServiceProcessChannel(); |
| 111 #endif |
107 | 112 |
108 private: | 113 private: |
109 #if !defined(OS_MACOSX) | 114 #if !defined(OS_MACOSX) |
110 // Create the shared memory data for the service process. | 115 // Create the shared memory data for the service process. |
111 bool CreateSharedData(); | 116 bool CreateSharedData(); |
112 | 117 |
113 // If an older version of the service process running, it should be shutdown. | 118 // If an older version of the service process running, it should be shutdown. |
114 // Returns false if this process needs to exit. | 119 // Returns false if this process needs to exit. |
115 bool HandleOtherVersion(); | 120 bool HandleOtherVersion(); |
116 | 121 |
(...skipping 10 matching lines...) Expand all Loading... |
127 | 132 |
128 // An opaque object that maintains state. The actual definition of this is | 133 // An opaque object that maintains state. The actual definition of this is |
129 // platform dependent. | 134 // platform dependent. |
130 struct StateData; | 135 struct StateData; |
131 StateData* state_; | 136 StateData* state_; |
132 std::unique_ptr<base::SharedMemory> shared_mem_service_data_; | 137 std::unique_ptr<base::SharedMemory> shared_mem_service_data_; |
133 std::unique_ptr<base::CommandLine> autorun_command_line_; | 138 std::unique_ptr<base::CommandLine> autorun_command_line_; |
134 }; | 139 }; |
135 | 140 |
136 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ | 141 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ |
OLD | NEW |