Index: mojo/public/utility/scoped_handle.cc |
diff --git a/mojo/public/utility/scoped_handle.cc b/mojo/public/utility/scoped_handle.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cba4b8aadbbb5715699e4ab15ea798fd8e58c50e |
--- /dev/null |
+++ b/mojo/public/utility/scoped_handle.cc |
@@ -0,0 +1,25 @@ |
+// Copyright 2013 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 "mojo/public/utility/scoped_handle.h" |
+ |
+namespace mojo { |
+ |
+ScopedHandle::ScopedHandle(Handle handle) : handle_(handle) { |
+} |
+ |
+ScopedHandle::~ScopedHandle() { |
+ if (handle_.value == kInvalidHandle.value) |
+ return; |
+ Close(handle_); |
+ Release(); |
+} |
+ |
+Handle ScopedHandle::Release() { |
+ Handle temp = handle_; |
+ handle_ = kInvalidHandle; |
+ return temp; |
+} |
+ |
+} // namespace mojo |