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

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

Issue 890213002: Add basic support for CAPS exe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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..3859a6674226f3c955df29e7bf46ecbfd34303a4
--- /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_(NULL) {
scottmg 2015/02/01 19:55:35 NULL -> nullptr
+ auto mutex = ::CreateMutexW(nullptr, TRUE, L"CHROME.CAPS.V1");
scottmg 2015/02/01 19:55:35 no W (are we not building as _UNICODE properly? if
cpu_(ooo_6.6-7.5) 2015/02/03 02:44:58 afaik we build ok, old habits die hard. changed.
+ 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
+

Powered by Google App Engine
This is Rietveld 408576698