summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 02:55:36 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 02:55:36 +0000
commitcd5a32f483300bc2ba17f1b9aae589bd4f128eaa (patch)
tree01d8d98cf19fb4de0dc3c06545cd5ec7d38c0541 /remoting/base
parentf4c378dd2231a2917ee1e07206e631ced38ea811 (diff)
downloadchromium_src-cd5a32f483300bc2ba17f1b9aae589bd4f128eaa.zip
chromium_src-cd5a32f483300bc2ba17f1b9aae589bd4f128eaa.tar.gz
chromium_src-cd5a32f483300bc2ba17f1b9aae589bd4f128eaa.tar.bz2
1. Implemented installation and uninstallation code for the Chromoting service.
2. Introduced base::win::ScopedScHandle wrapper to make sure SCM handles are released properly. Review URL: http://codereview.chromium.org/9358034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/scoped_sc_handle_win.cc45
-rw-r--r--remoting/base/scoped_sc_handle_win.h43
2 files changed, 88 insertions, 0 deletions
diff --git a/remoting/base/scoped_sc_handle_win.cc b/remoting/base/scoped_sc_handle_win.cc
new file mode 100644
index 0000000..3e062e6
--- /dev/null
+++ b/remoting/base/scoped_sc_handle_win.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 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 "remoting/base/scoped_sc_handle_win.h"
+
+namespace remoting {
+
+ScopedScHandle::ScopedScHandle() : handle_(NULL) {
+}
+
+ScopedScHandle::ScopedScHandle(SC_HANDLE h) : handle_(NULL) {
+ Set(h);
+}
+
+ScopedScHandle::~ScopedScHandle() {
+ Close();
+}
+
+void ScopedScHandle::Close() {
+ if (handle_) {
+ if (!::CloseServiceHandle(handle_)) {
+ NOTREACHED();
+ }
+ handle_ = NULL;
+ }
+}
+
+bool ScopedScHandle::IsValid() const {
+ return handle_ != NULL;
+}
+
+void ScopedScHandle::Set(SC_HANDLE new_handle) {
+ Close();
+ handle_ = new_handle;
+}
+
+SC_HANDLE ScopedScHandle::Take() {
+ // transfers ownership away from this object
+ SC_HANDLE h = handle_;
+ handle_ = NULL;
+ return h;
+}
+
+} // namespace remoting
diff --git a/remoting/base/scoped_sc_handle_win.h b/remoting/base/scoped_sc_handle_win.h
new file mode 100644
index 0000000..da623ad
--- /dev/null
+++ b/remoting/base/scoped_sc_handle_win.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 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 REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_
+#define REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_
+
+#include <windows.h>
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+
+namespace remoting {
+
+// Used so we always remember to close service control manager handles.
+// The class interface matches that of base::win::ScopedHandle.
+class ScopedScHandle {
+ public:
+ ScopedScHandle();
+ explicit ScopedScHandle(SC_HANDLE h);
+ ~ScopedScHandle();
+
+ SC_HANDLE Get() {
+ return handle_;
+ }
+
+ operator SC_HANDLE() {
+ return handle_;
+ }
+
+ void Close();
+ bool IsValid() const;
+ void Set(SC_HANDLE new_handle);
+ SC_HANDLE Take();
+
+ private:
+ SC_HANDLE handle_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedScHandle);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_