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

Side by Side Diff: base/scoped_variant_win.cc

Issue 200045: Use Scoped[Bstr,ComPtr,Variant] instead of their ATL equivalents to reduce de... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "base/scoped_variant_win.h" 5 #include "base/scoped_variant_win.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 7
8 // Global, const instance of an empty variant. 8 // Global, const instance of an empty variant.
9 const VARIANT ScopedVariant::kEmptyVariant = { VT_EMPTY }; 9 const VARIANT ScopedVariant::kEmptyVariant = { VT_EMPTY };
10 10
(...skipping 10 matching lines...) Expand all
21 ScopedVariant::ScopedVariant(const wchar_t* str, UINT length) { 21 ScopedVariant::ScopedVariant(const wchar_t* str, UINT length) {
22 var_.vt = VT_BSTR; 22 var_.vt = VT_BSTR;
23 var_.bstrVal = ::SysAllocStringLen(str, length); 23 var_.bstrVal = ::SysAllocStringLen(str, length);
24 } 24 }
25 25
26 ScopedVariant::ScopedVariant(int value, VARTYPE vt) { 26 ScopedVariant::ScopedVariant(int value, VARTYPE vt) {
27 var_.vt = vt; 27 var_.vt = vt;
28 var_.lVal = value; 28 var_.lVal = value;
29 } 29 }
30 30
31 ScopedVariant::ScopedVariant(double value, VARTYPE vt) {
32 DCHECK(vt == VT_R8 || vt == VT_DATE);
33 var_.vt = vt;
34 var_.dblVal = value;
35 }
36
31 ScopedVariant::ScopedVariant(IDispatch* dispatch) { 37 ScopedVariant::ScopedVariant(IDispatch* dispatch) {
32 var_.vt = VT_EMPTY; 38 var_.vt = VT_EMPTY;
33 Set(dispatch); 39 Set(dispatch);
34 } 40 }
35 41
36 ScopedVariant::ScopedVariant(IUnknown* unknown) { 42 ScopedVariant::ScopedVariant(IUnknown* unknown) {
37 var_.vt = VT_EMPTY; 43 var_.vt = VT_EMPTY;
38 Set(unknown); 44 Set(unknown);
39 } 45 }
40 46
47 ScopedVariant::ScopedVariant(SAFEARRAY* safearray) {
48 var_.vt = VT_EMPTY;
49 Set(safearray);
50 }
51
41 ScopedVariant::ScopedVariant(const VARIANT& var) { 52 ScopedVariant::ScopedVariant(const VARIANT& var) {
42 var_.vt = VT_EMPTY; 53 var_.vt = VT_EMPTY;
43 Set(var); 54 Set(var);
44 } 55 }
45 56
46 void ScopedVariant::Reset(const VARIANT& var) { 57 void ScopedVariant::Reset(const VARIANT& var) {
47 if (&var != &var_) { 58 if (&var != &var_) {
48 ::VariantClear(&var_); 59 ::VariantClear(&var_);
49 var_ = var; 60 var_ = var;
50 } 61 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 leakable = true; 261 leakable = true;
251 break; 262 break;
252 } 263 }
253 264
254 if (!leakable && (vt & VT_ARRAY) != 0) { 265 if (!leakable && (vt & VT_ARRAY) != 0) {
255 leakable = true; 266 leakable = true;
256 } 267 }
257 268
258 return leakable; 269 return leakable;
259 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698