Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5148)

Unified Diff: chrome/tools/crash_service/caps/process_singleton_win.cc

Issue 1921973006: Revert of Remove CAPS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/tools/crash_service/caps/process_singleton_win.cc
diff --git a/chrome/tools/crash_service/caps/process_singleton_win.cc b/chrome/tools/crash_service/caps/process_singleton_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f51acccc6d4a52e5f48463619038b6041a2630db
--- /dev/null
+++ b/chrome/tools/crash_service/caps/process_singleton_win.cc
@@ -0,0 +1,29 @@
+// Copyright 2015 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 <windows.h>
+
+#include "chrome/tools/crash_service/caps/process_singleton_win.h"
+
+namespace caps {
+
+ProcessSingleton::ProcessSingleton() : mutex_(nullptr) {
+ auto mutex = ::CreateMutex(nullptr, TRUE, L"CHROME.CAPS.V1");
+ if (!mutex)
+ return;
+ if (::GetLastError() == ERROR_ALREADY_EXISTS) {
+ ::CloseHandle(mutex);
+ return;
+ }
+ // We are now the single instance.
+ mutex_ = mutex;
+}
+
+ProcessSingleton::~ProcessSingleton() {
+ if (mutex_)
+ ::CloseHandle(mutex_);
+}
+
+} // namespace caps
+
« no previous file with comments | « chrome/tools/crash_service/caps/process_singleton_win.h ('k') | chrome/tools/crash_service/crash_service.exe.manifest » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698