| 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/ref_counted.h" |
| 12 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 13 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "mojo/edk/embedder/named_platform_handle.h" | 17 #include "mojo/edk/embedder/named_platform_handle.h" |
| 16 #include "mojo/edk/embedder/scoped_platform_handle.h" | 18 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 17 | 19 |
| 18 class MultiProcessLock; | 20 class MultiProcessLock; |
| 19 | 21 |
| 20 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
| 21 #ifdef __OBJC__ | 23 #ifdef __OBJC__ |
| 22 @class NSString; | 24 @class NSString; |
| 23 #else | 25 #else |
| 24 class NSString; | 26 class NSString; |
| 25 #endif | 27 #endif |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 namespace base { | 30 namespace base { |
| 29 class CommandLine; | 31 class CommandLine; |
| 30 class SingleThreadTaskRunner; | |
| 31 } | 32 } |
| 32 | 33 |
| 33 // Return the IPC channel to connect to the service process. | 34 // Return the IPC channel to connect to the service process. |
| 34 mojo::edk::NamedPlatformHandle GetServiceProcessChannel(); | 35 mojo::edk::NamedPlatformHandle GetServiceProcessChannel(); |
| 35 | 36 |
| 36 // Return a name that is scoped to this instance of the service process. We | 37 // Return a name that is scoped to this instance of the service process. We |
| 37 // use the user-data-dir as a scoping prefix. | 38 // use the user-data-dir as a scoping prefix. |
| 38 std::string GetServiceProcessScopedName(const std::string& append_str); | 39 std::string GetServiceProcessScopedName(const std::string& append_str); |
| 39 | 40 |
| 40 #if !defined(OS_MACOSX) | 41 #if !defined(OS_MACOSX) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Tries to become the sole service process for the current user data dir. | 85 // Tries to become the sole service process for the current user data dir. |
| 85 // Returns false if another service process is already running. | 86 // Returns false if another service process is already running. |
| 86 bool Initialize(); | 87 bool Initialize(); |
| 87 | 88 |
| 88 // Signal that the service process is ready. | 89 // Signal that the service process is ready. |
| 89 // This method is called when the service process is running and initialized. | 90 // This method is called when the service process is running and initialized. |
| 90 // |terminate_task| is invoked when we get a terminate request from another | 91 // |terminate_task| is invoked when we get a terminate request from another |
| 91 // process (in the same thread that called SignalReady). It can be NULL. | 92 // process (in the same thread that called SignalReady). It can be NULL. |
| 92 // |task_runner| must be of type IO and is the loop that POSIX uses | 93 // |task_runner| must be of type IO and is the loop that POSIX uses |
| 93 // to monitor the service process. | 94 // to monitor the service process. |
| 94 bool SignalReady(base::SingleThreadTaskRunner* task_runner, | 95 bool SignalReady(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 95 const base::Closure& terminate_task); | 96 const base::Closure& terminate_task); |
| 96 | 97 |
| 97 // Signal that the service process is stopped. | 98 // Signal that the service process is stopped. |
| 98 void SignalStopped(); | 99 void SignalStopped(); |
| 99 | 100 |
| 100 // Register the service process to run on startup. | 101 // Register the service process to run on startup. |
| 101 bool AddToAutoRun(); | 102 bool AddToAutoRun(); |
| 102 | 103 |
| 103 // Unregister the service process to run on startup. | 104 // Unregister the service process to run on startup. |
| 104 bool RemoveFromAutoRun(); | 105 bool RemoveFromAutoRun(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 132 | 133 |
| 133 // An opaque object that maintains state. The actual definition of this is | 134 // An opaque object that maintains state. The actual definition of this is |
| 134 // platform dependent. | 135 // platform dependent. |
| 135 struct StateData; | 136 struct StateData; |
| 136 StateData* state_; | 137 StateData* state_; |
| 137 std::unique_ptr<base::SharedMemory> shared_mem_service_data_; | 138 std::unique_ptr<base::SharedMemory> shared_mem_service_data_; |
| 138 std::unique_ptr<base::CommandLine> autorun_command_line_; | 139 std::unique_ptr<base::CommandLine> autorun_command_line_; |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ | 142 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ |
| OLD | NEW |