summaryrefslogtreecommitdiffstats
path: root/chrome/common/service_process_util_posix.cc
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-01 12:19:54 +0000
committerIain Merrick <husky@google.com>2010-11-03 10:21:10 +0000
commit731df977c0511bca2206b5f333555b1205ff1f43 (patch)
tree0e750b949b3f00a1ac11fda25d3c2de512f2b465 /chrome/common/service_process_util_posix.cc
parent5add15e10e7bb80512f2c597ca57221314abe577 (diff)
downloadexternal_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'chrome/common/service_process_util_posix.cc')
-rw-r--r--chrome/common/service_process_util_posix.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/chrome/common/service_process_util_posix.cc b/chrome/common/service_process_util_posix.cc
new file mode 100644
index 0000000..e547223
--- /dev/null
+++ b/chrome/common/service_process_util_posix.cc
@@ -0,0 +1,83 @@
+// 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.
+
+#include "chrome/common/service_process_util.h"
+
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_version_info.h"
+
+namespace {
+
+// Gets the name of the lock file for service process.
+FilePath GetServiceProcessLockFilePath() {
+ FilePath user_data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ chrome::VersionInfo version_info;
+ std::string lock_file_name = version_info.Version() + "Service Process Lock";
+ return user_data_dir.Append(lock_file_name);
+}
+
+} // namespace
+
+bool ForceServiceProcessShutdown(const std::string& version) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool CheckServiceProcessReady() {
+ const FilePath path = GetServiceProcessLockFilePath();
+ return file_util::PathExists(path);
+}
+
+struct ServiceProcessState::StateData {
+ // No state yet for Posix.
+};
+
+bool ServiceProcessState::TakeSingletonLock() {
+ // TODO(sanjeevr): Implement singleton mechanism for POSIX.
+ NOTIMPLEMENTED();
+ return true;
+}
+
+void ServiceProcessState::SignalReady(Task* shutdown_task) {
+ // TODO(hclam): Implement better mechanism for these platform.
+ // Also we need to save shutdown task. For now we just delete the shutdown
+ // task because we have not way to listen for shutdown requests.
+ delete shutdown_task;
+ const FilePath path = GetServiceProcessLockFilePath();
+ FILE* file = file_util::OpenFile(path, "wb+");
+ if (!file)
+ return;
+ VLOG(1) << "Created Service Process lock file: " << path.value();
+ file_util::TruncateFile(file) && file_util::CloseFile(file);
+}
+
+void ServiceProcessState::SignalStopped() {
+ const FilePath path = GetServiceProcessLockFilePath();
+ file_util::Delete(path, false);
+ shared_mem_service_data_.reset();
+}
+
+bool ServiceProcessState::AddToAutoRun() {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool ServiceProcessState::RemoveFromAutoRun() {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void ServiceProcessState::TearDownState() {
+}
+
+bool ServiceProcessState::ShouldHandleOtherVersion() {
+ // On POSIX, the shared memory is a file in disk. We may have a stale file
+ // lying around from a previous run. So the check is not reliable.
+ return false;
+}
+