summaryrefslogtreecommitdiffstats
path: root/chrome/common/launchd_mac.h
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 05:19:29 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 05:19:29 +0000
commit4130d9e2ee756e06aae9861eb4658b0578ee67bd (patch)
tree18d47b0dac25e8bf76783ce524d37b21dc9bcbe1 /chrome/common/launchd_mac.h
parent9b8dea2472f7df4036f07f370ab4321f24823c8c (diff)
downloadchromium_src-4130d9e2ee756e06aae9861eb4658b0578ee67bd.zip
chromium_src-4130d9e2ee756e06aae9861eb4658b0578ee67bd.tar.gz
chromium_src-4130d9e2ee756e06aae9861eb4658b0578ee67bd.tar.bz2
Getting service process on Mac to handle having things moved/changed underneath it.
BUG=74983 TEST=See http://code.google.com/p/chromium/issues/detail?id=74983#c16 Review URL: http://codereview.chromium.org/6660001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78967 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/launchd_mac.h')
-rw-r--r--chrome/common/launchd_mac.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/chrome/common/launchd_mac.h b/chrome/common/launchd_mac.h
new file mode 100644
index 0000000..1f692dd
--- /dev/null
+++ b/chrome/common/launchd_mac.h
@@ -0,0 +1,100 @@
+// Copyright (c) 2011 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_LAUNCHD_MAC_H_
+#define CHROME_COMMON_LAUNCHD_MAC_H_
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "base/basictypes.h"
+#include "base/singleton.h"
+
+class Launchd {
+ public:
+ enum Type {
+ Agent, // LaunchAgent
+ Daemon // LaunchDaemon
+ };
+
+ // Domains map to NSSearchPathDomainMask so Foundation does not need to be
+ // included.
+ enum Domain {
+ User = 1, // ~/Library/Launch*
+ Local = 2, // /Library/Launch*
+ Network = 4, // /Network/Library/Launch*
+ System = 8 // /System/Library/Launch*
+ };
+
+ // TODO(dmaclach): Get rid of this pseudo singleton, and inject it
+ // appropriately wherever it is used.
+ // http://crbug.com/76925
+ static Launchd* GetInstance();
+
+ virtual ~Launchd();
+
+ // Return a dictionary with the launchd export settings.
+ virtual CFDictionaryRef CopyExports();
+
+ // Return a dictionary with the launchd entries for job labeled |name|.
+ virtual CFDictionaryRef CopyJobDictionary(CFStringRef label);
+
+ // Return a dictionary for launchd process.
+ virtual CFDictionaryRef CopyDictionaryByCheckingIn(CFErrorRef* error);
+
+ // Remove a launchd process from launchd.
+ virtual bool RemoveJob(CFStringRef label, CFErrorRef* error);
+
+ // Used by a process controlled by launchd to restart itself.
+ // |session_type| can be "Aqua", "LoginWindow", "Background", "StandardIO" or
+ // "System".
+ // RestartLaunchdJob starts up a separate process to tell launchd to
+ // send this process a SIGTERM. This call will return, but a SIGTERM will be
+ // received shortly.
+ virtual bool RestartJob(Domain domain,
+ Type type,
+ CFStringRef name,
+ CFStringRef session_type);
+
+ // Read a launchd plist from disk.
+ // |name| should not have an extension.
+ virtual CFMutableDictionaryRef CreatePlistFromFile(Domain domain,
+ Type type,
+ CFStringRef name);
+ // Write a launchd plist to disk.
+ // |name| should not have an extension.
+ virtual bool WritePlistToFile(Domain domain,
+ Type type,
+ CFStringRef name,
+ CFDictionaryRef dict);
+
+ // Delete a launchd plist.
+ // |name| should not have an extension.
+ virtual bool DeletePlist(Domain domain, Type type, CFStringRef name);
+
+ // TODO(dmaclach): remove this once http://crbug.com/76925 is fixed.
+ // Scaffolding for doing unittests with our singleton.
+ static void SetInstance(Launchd* instance);
+ class ScopedInstance {
+ public:
+ explicit ScopedInstance(Launchd* instance) {
+ Launchd::SetInstance(instance);
+ }
+ ~ScopedInstance() {
+ Launchd::SetInstance(NULL);
+ }
+ };
+
+ protected:
+ Launchd() { }
+
+ private:
+ // TODO(dmaclach): remove this once http://crbug.com/76925 is fixed.
+ // Scaffolding for doing unittests with our singleton.
+ friend struct DefaultSingletonTraits<Launchd>;
+ static Launchd* g_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(Launchd);
+};
+
+#endif // CHROME_COMMON_LAUNCHD_MAC_H_