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

Unified Diff: base/win/scoped_comptr.h

Issue 2471043002: Allow icomplete types in scoped_refptr<T>. (Closed)
Patch Set: Release can delete this Created 4 years, 1 month 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 | « base/test/opaque_ref_counted.cc ('k') | no next file » | 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 5ce60e2b688f603b2b681e42a270e41e6156f704..ee232898c842c9cff57c03ff95a86f38af69b0a5 100644
--- a/base/win/scoped_comptr.h
+++ b/base/win/scoped_comptr.h
@@ -40,14 +40,6 @@ class ScopedComPtr : public scoped_refptr<Interface> {
: ParentClass(p) {
}
- ~ScopedComPtr() {
- // We don't want the smart pointer class to be bigger than the pointer
- // it wraps.
- static_assert(
- sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*),
- "ScopedComPtrSize");
- }
-
// Explicit Release() of the held object. Useful for reuse of the
// ScopedComPtr instance.
// Note that this function equates to IUnknown::Release and should not
@@ -70,6 +62,7 @@ class ScopedComPtr : public scoped_refptr<Interface> {
// Accepts an interface pointer that has already been addref-ed.
void Attach(Interface* p) {
DCHECK(!this->ptr_);
+ this->ptr_caller_ = &ParentClass::PtrCallerImpl;
this->ptr_ = p;
}
@@ -79,6 +72,7 @@ class ScopedComPtr : public scoped_refptr<Interface> {
// Usage: Foo(p.Receive());
Interface** Receive() {
DCHECK(!this->ptr_) << "Object leak. Pointer must be NULL";
+ this->ptr_caller_ = &ParentClass::PtrCallerImpl;
return &this->ptr_;
}
@@ -114,9 +108,8 @@ class ScopedComPtr : public scoped_refptr<Interface> {
// Convenience wrapper around CoCreateInstance
HRESULT CreateInstance(const CLSID& clsid, IUnknown* outer = NULL,
DWORD context = CLSCTX_ALL) {
- DCHECK(!this->ptr_);
HRESULT hr = ::CoCreateInstance(clsid, outer, context, *interface_id,
- reinterpret_cast<void**>(&this->ptr_));
+ ReceiveVoid());
return hr;
}
« no previous file with comments | « base/test/opaque_ref_counted.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698