diff options
author | Kristian Monsen <kristianm@google.com> | 2011-06-09 11:47:42 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-29 14:33:03 +0100 |
commit | dc0f95d653279beabeb9817299e2902918ba123e (patch) | |
tree | 32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/common/service_process_util_posix.h | |
parent | ba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff) | |
download | external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2 |
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/common/service_process_util_posix.h')
-rw-r--r-- | chrome/common/service_process_util_posix.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/chrome/common/service_process_util_posix.h b/chrome/common/service_process_util_posix.h new file mode 100644 index 0000000..42b0a31 --- /dev/null +++ b/chrome/common/service_process_util_posix.h @@ -0,0 +1,77 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ +#define CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ + +#include "service_process_util.h" + +#include <signal.h> + +#include "base/basictypes.h" +#include "base/message_loop.h" +#include "base/message_pump_libevent.h" +#include "base/scoped_ptr.h" + +#if defined(OS_LINUX) +#include "chrome/common/multi_process_lock.h" +MultiProcessLock* TakeServiceRunningLock(bool waiting); +#endif // OS_LINUX + +#if defined(OS_MACOSX) +#include "base/mac/scoped_cftyperef.h" +class CommandLine; +CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, + bool for_auto_launch); +#endif // OS_MACOSX + +// Watches for |kShutDownMessage| to be written to the file descriptor it is +// watching. When it reads |kShutDownMessage|, it performs |shutdown_task_|. +// Used here to monitor the socket listening to g_signal_socket. +class ServiceProcessShutdownMonitor + : public base::MessagePumpLibevent::Watcher { + public: + + enum { + kShutDownMessage = 0xdecea5e + }; + + explicit ServiceProcessShutdownMonitor(Task* shutdown_task); + virtual ~ServiceProcessShutdownMonitor(); + + // base::MessagePumpLibevent::Watcher overrides + virtual void OnFileCanReadWithoutBlocking(int fd); + virtual void OnFileCanWriteWithoutBlocking(int fd); + + private: + scoped_ptr<Task> shutdown_task_; +}; + +struct ServiceProcessState::StateData + : public base::RefCountedThreadSafe<ServiceProcessState::StateData> { + StateData(); + + // WatchFileDescriptor needs to be set up by the thread that is going + // to be monitoring it. + void SignalReady(); + +#if defined(OS_MACOSX) + base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; +#endif // OS_MACOSX +#if defined(OS_LINUX) + scoped_ptr<MultiProcessLock> initializing_lock_; + scoped_ptr<MultiProcessLock> running_lock_; +#endif // OS_LINUX + scoped_ptr<ServiceProcessShutdownMonitor> shut_down_monitor_; + base::MessagePumpLibevent::FileDescriptorWatcher watcher_; + int sockets_[2]; + struct sigaction old_action_; + bool set_action_; + + protected: + friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; + virtual ~StateData(); +}; + +#endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |