| OLD | NEW |
| 1 // Copyright (c) 2011 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/process.h" | 13 #include "base/process.h" |
| 14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
| 15 #include "ipc/ipc_channel_handle.h" | 15 #include "ipc/ipc_channel_handle.h" |
| 16 | 16 |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 class MultiProcessLock; |
| 19 |
| 20 #if defined(OS_MACOSX) |
| 21 #ifdef __OBJC__ |
| 22 @class NSString; |
| 23 #else |
| 24 class NSString; |
| 25 #endif |
| 26 #endif |
| 18 | 27 |
| 19 namespace base { | 28 namespace base { |
| 20 class MessageLoopProxy; | 29 class MessageLoopProxy; |
| 21 } | 30 } |
| 22 | 31 |
| 23 // Return the IPC channel to connect to the service process. | 32 // Return the IPC channel to connect to the service process. |
| 24 IPC::ChannelHandle GetServiceProcessChannel(); | 33 IPC::ChannelHandle GetServiceProcessChannel(); |
| 25 | 34 |
| 26 #if !defined(OS_MACOSX) | 35 #if !defined(OS_MACOSX) |
| 27 // 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 |
| 28 // use the user-data-dir as a scoping prefix. | 37 // use the user-data-dir as a scoping prefix. |
| 29 std::string GetServiceProcessScopedName(const std::string& append_str); | 38 std::string GetServiceProcessScopedName(const std::string& append_str); |
| 30 | 39 |
| 31 // Return a name that is scoped to this instance of the service process. We | 40 // Return a name that is scoped to this instance of the service process. We |
| 32 // use the user-data-dir and the version as a scoping prefix. | 41 // use the user-data-dir and the version as a scoping prefix. |
| 33 std::string GetServiceProcessScopedVersionedName(const std::string& append_str); | 42 std::string GetServiceProcessScopedVersionedName(const std::string& append_str); |
| 34 #endif // OS_MACOSX | 43 #endif // OS_MACOSX |
| 35 | 44 |
| 45 #if defined(OS_MACOSX) |
| 46 // Return the name that is used to extract the socket path out of the |
| 47 // dictionary provided by launchd. |
| 48 NSString* GetServiceProcessLaunchDSocketEnvVar(); |
| 49 #endif |
| 50 |
| 51 #if defined(OS_POSIX) |
| 52 // Attempts to take a lock named |name|. If |waiting| is true then this will |
| 53 // make multiple attempts to acquire the lock. |
| 54 // Caller is responsible for ownership of the MultiProcessLock. |
| 55 MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting); |
| 56 #endif |
| 57 |
| 36 // The following methods are used in a process that acts as a client to the | 58 // The following methods are used in a process that acts as a client to the |
| 37 // service process (typically the browser process). | 59 // service process (typically the browser process). |
| 38 // -------------------------------------------------------------------------- | 60 // -------------------------------------------------------------------------- |
| 39 // This method checks that if the service process is ready to receive | 61 // This method checks that if the service process is ready to receive |
| 40 // IPC commands. | 62 // IPC commands. |
| 41 bool CheckServiceProcessReady(); | 63 bool CheckServiceProcessReady(); |
| 42 | 64 |
| 43 // Returns the process id and version of the currently running service process. | 65 // Returns the process id and version of the currently running service process. |
| 44 // Note: DO NOT use this check whether the service process is ready because | 66 // Note: DO NOT use this check whether the service process is ready because |
| 45 // a true return value only means that some process shared data was available, | 67 // a true return value only means that some process shared data was available, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 135 |
| 114 // An opaque object that maintains state. The actual definition of this is | 136 // An opaque object that maintains state. The actual definition of this is |
| 115 // platform dependent. | 137 // platform dependent. |
| 116 struct StateData; | 138 struct StateData; |
| 117 StateData* state_; | 139 StateData* state_; |
| 118 scoped_ptr<base::SharedMemory> shared_mem_service_data_; | 140 scoped_ptr<base::SharedMemory> shared_mem_service_data_; |
| 119 scoped_ptr<CommandLine> autorun_command_line_; | 141 scoped_ptr<CommandLine> autorun_command_line_; |
| 120 }; | 142 }; |
| 121 | 143 |
| 122 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ | 144 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_H_ |
| OLD | NEW |