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

Unified Diff: base/win/scoped_propvariant.h

Issue 11786005: Remove uses of PropVariantTo*; removing the need to DelayLoad propsys.dll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better ScopedPropVariant Created 7 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: base/win/scoped_propvariant.h
diff --git a/base/win/scoped_propvariant.h b/base/win/scoped_propvariant.h
new file mode 100644
index 0000000000000000000000000000000000000000..16b84b507082bc9a11c9a8fdc71e7df3c97b330d
--- /dev/null
+++ b/base/win/scoped_propvariant.h
@@ -0,0 +1,47 @@
+// Copyright (c) 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.
+
+#ifndef BASE_WIN_SCOPED_PROPVARIANT_H_
+#define BASE_WIN_SCOPED_PROPVARIANT_H_
+
+#include <propidl.h>
+
grt (UTC plus 2) 2013/01/10 03:24:05 #include "base/base_export.h" (for BASE_EXPORT) #i
gab 2013/01/10 15:30:42 Oh oops, good catch!
+namespace base {
+namespace win {
+
+// A PROPVARIANT that is automatically initialized and cleared upon respective
+// construction and destruction of this class.
+class ScopedPropVariant {
grt (UTC plus 2) 2013/01/10 03:24:05 class BASE_EXPORT ScopedPropVariant {
gab 2013/01/10 15:30:42 This won't link, as discussed this is probably bec
+ public:
+ ScopedPropVariant() {
+ PropVariantInit(&pv_);
+ }
+ ~ScopedPropVariant() {
+ HRESULT result = PropVariantClear(&pv_);
+ DCHECK_EQ(result, S_OK);
gab 2013/01/09 20:43:40 I could simply call Reset() here, but I felt it mi
grt (UTC plus 2) 2013/01/10 03:24:05 My opinion: call Reset().
gab 2013/01/10 15:30:42 Done.
+ }
+
+ PROPVARIANT* Receive() {
+ DCHECK_EQ(pv_.vt, VT_EMPTY);
+ return &pv_;
+ }
+
+ void Reset() {
+ HRESULT result = PropVariantClear(&pv_);
+ DCHECK_EQ(result, S_OK);
+ }
+
+ // Allow direct read-only access to the members of |pv_| with the -> operator.
+ const PROPVARIANT* operator->() const { return &pv_; }
+
+ const PROPVARIANT* operator&() const { return &pv_; }
+
+ private:
+ PROPVARIANT pv_;
+};
grt (UTC plus 2) 2013/01/10 03:24:05 DISALLOW_COPY_AND_ASSIGN(ScopedPropVariant); also
gab 2013/01/10 15:30:42 Done.
+
+} // namespace win
+} // namespace base
+
+#endif // BASE_WIN_SCOPED_PROPVARIANT_H_

Powered by Google App Engine
This is Rietveld 408576698