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

Unified Diff: base/win/scoped_comptr.h

Issue 2789273002: Add IID_PPV_ARGS_Helper for ScopedComPtr (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | base/win/scoped_comptr_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_comptr.h
diff --git a/base/win/scoped_comptr.h b/base/win/scoped_comptr.h
index 8e052500cc86a978f1634eebc7f4d77b9e9734ee..d4aaa842017f4db185381bc5001e40ac9ddff12f 100644
--- a/base/win/scoped_comptr.h
+++ b/base/win/scoped_comptr.h
@@ -5,6 +5,7 @@
#ifndef BASE_WIN_SCOPED_COMPTR_H_
#define BASE_WIN_SCOPED_COMPTR_H_
+#include <objbase.h>
#include <unknwn.h>
#include "base/logging.h"
@@ -99,7 +100,7 @@ class ScopedComPtr {
// IUnknown already has a template version of QueryInterface
// so the iid parameter is implicit here. The only thing this
// function adds are the DCHECKs.
- return ptr_->QueryInterface(p);
+ return ptr_->QueryInterface(IID_PPV_ARGS(p));
}
// QI for times when the IID is not associated with the type.
@@ -113,7 +114,7 @@ class ScopedComPtr {
// error code from the other->QueryInterface operation.
HRESULT QueryFrom(IUnknown* object) {
DCHECK(object);
- return object->QueryInterface(Receive());
+ return object->QueryInterface(IID_PPV_ARGS(Receive()));
}
// Convenience wrapper around CoCreateInstance
@@ -135,10 +136,10 @@ class ScopedComPtr {
return false;
ScopedComPtr<IUnknown> my_identity;
- QueryInterface(my_identity.Receive());
+ QueryInterface(IID_PPV_ARGS(my_identity.Receive()));
ScopedComPtr<IUnknown> other_identity;
- other->QueryInterface(other_identity.Receive());
+ other->QueryInterface(IID_PPV_ARGS(other_identity.Receive()));
return my_identity == other_identity;
}
@@ -257,6 +258,12 @@ std::ostream& operator<<(std::ostream& out, const ScopedComPtr<T>& p) {
return out << p.get();
}
+// Helper to make IID_PPV_ARGS work with ScopedComPtr.
+template <typename T>
+void** IID_PPV_ARGS_Helper(base::win::ScopedComPtr<T>* pp) throw() {
+ return pp->ReceiveVoid();
+}
+
} // namespace win
} // namespace base
« no previous file with comments | « no previous file | base/win/scoped_comptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698