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

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

Issue 748073004: Disable implicit conversion of scoped_refptr<T> to T* on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comptr too Created 6 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 unified diff | Download patch
« base/memory/ref_counted.h ('K') | « base/memory/ref_counted.h ('k') | no next file » | 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 <unknwn.h> 8 #include <unknwn.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 if (!other || !ptr_) 127 if (!other || !ptr_)
128 return false; 128 return false;
129 129
130 ScopedComPtr<IUnknown> my_identity; 130 ScopedComPtr<IUnknown> my_identity;
131 QueryInterface(my_identity.Receive()); 131 QueryInterface(my_identity.Receive());
132 132
133 ScopedComPtr<IUnknown> other_identity; 133 ScopedComPtr<IUnknown> other_identity;
134 other->QueryInterface(other_identity.Receive()); 134 other->QueryInterface(other_identity.Receive());
135 135
136 return static_cast<IUnknown*>(my_identity) == 136 return my_identity == other_identity;
137 static_cast<IUnknown*>(other_identity);
138 } 137 }
139 138
140 // Provides direct access to the interface. 139 // Provides direct access to the interface.
141 // Here we use a well known trick to make sure we block access to 140 // Here we use a well known trick to make sure we block access to
142 // IUnknown methods so that something bad like this doesn't happen: 141 // IUnknown methods so that something bad like this doesn't happen:
143 // ScopedComPtr<IUnknown> p(Foo()); 142 // ScopedComPtr<IUnknown> p(Foo());
144 // p->Release(); 143 // p->Release();
145 // ... later the destructor runs, which will Release() again. 144 // ... later the destructor runs, which will Release() again.
146 // and to get the benefit of the DCHECKs we add to QueryInterface. 145 // and to get the benefit of the DCHECKs we add to QueryInterface.
147 // There's still a way to call these methods if you absolutely must 146 // There's still a way to call these methods if you absolutely must
(...skipping 11 matching lines...) Expand all
159 158
160 static const IID& iid() { 159 static const IID& iid() {
161 return *interface_id; 160 return *interface_id;
162 } 161 }
163 }; 162 };
164 163
165 } // namespace win 164 } // namespace win
166 } // namespace base 165 } // namespace base
167 166
168 #endif // BASE_WIN_SCOPED_COMPTR_H_ 167 #endif // BASE_WIN_SCOPED_COMPTR_H_
OLDNEW
« base/memory/ref_counted.h ('K') | « base/memory/ref_counted.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698