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

Side by Side Diff: base/win/scoped_comptr.h

Issue 2885063003: Remove ScopedComPtr::QueryFrom() (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « base/test/test_shortcut_win.cc ('k') | base/win/shortcut.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_WIN_SCOPED_COMPTR_H_ 5 #ifndef BASE_WIN_SCOPED_COMPTR_H_
6 #define BASE_WIN_SCOPED_COMPTR_H_ 6 #define BASE_WIN_SCOPED_COMPTR_H_
7 7
8 #include <objbase.h> 8 #include <objbase.h>
9 #include <unknwn.h> 9 #include <unknwn.h>
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return ptr_->QueryInterface(IID_PPV_ARGS(p)); 109 return ptr_->QueryInterface(IID_PPV_ARGS(p));
110 } 110 }
111 111
112 // QI for times when the IID is not associated with the type. 112 // QI for times when the IID is not associated with the type.
113 HRESULT CopyTo(const IID& iid, void** obj) { 113 HRESULT CopyTo(const IID& iid, void** obj) {
114 DCHECK(obj); 114 DCHECK(obj);
115 DCHECK(ptr_); 115 DCHECK(ptr_);
116 return ptr_->QueryInterface(iid, obj); 116 return ptr_->QueryInterface(iid, obj);
117 } 117 }
118 118
119 // Queries |other| for the interface this object wraps and returns the
120 // error code from the other->QueryInterface operation.
121 HRESULT QueryFrom(IUnknown* object) {
122 DCHECK(object);
123 return object->QueryInterface(IID_PPV_ARGS(GetAddressOf()));
124 }
125
126 // Convenience wrapper around CoCreateInstance 119 // Convenience wrapper around CoCreateInstance
127 HRESULT CreateInstance(const CLSID& clsid, 120 HRESULT CreateInstance(const CLSID& clsid,
128 IUnknown* outer = nullptr, 121 IUnknown* outer = nullptr,
129 DWORD context = CLSCTX_ALL) { 122 DWORD context = CLSCTX_ALL) {
130 DCHECK(!ptr_); 123 DCHECK(!ptr_);
131 HRESULT hr = ::CoCreateInstance(clsid, outer, context, *interface_id, 124 HRESULT hr = ::CoCreateInstance(clsid, outer, context, *interface_id,
132 reinterpret_cast<void**>(&ptr_)); 125 reinterpret_cast<void**>(&ptr_));
133 return hr; 126 return hr;
134 } 127 }
135 128
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Helper to make IID_PPV_ARGS work with ScopedComPtr. 270 // Helper to make IID_PPV_ARGS work with ScopedComPtr.
278 template <typename T> 271 template <typename T>
279 void** IID_PPV_ARGS_Helper(base::win::details::ScopedComPtrRef<T> pp) throw() { 272 void** IID_PPV_ARGS_Helper(base::win::details::ScopedComPtrRef<T> pp) throw() {
280 return pp; 273 return pp;
281 } 274 }
282 275
283 } // namespace win 276 } // namespace win
284 } // namespace base 277 } // namespace base
285 278
286 #endif // BASE_WIN_SCOPED_COMPTR_H_ 279 #endif // BASE_WIN_SCOPED_COMPTR_H_
OLDNEW
« no previous file with comments | « base/test/test_shortcut_win.cc ('k') | base/win/shortcut.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698