OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/win/iunknown_impl.h" | |
6 | |
7 namespace base { | |
8 namespace win { | |
9 | |
10 IUnknownImpl::IUnknownImpl() { | |
11 ref_count_ = 1; | |
M-A Ruel
2011/11/29 22:12:33
See base/memory/ref_counted.cc. It's highly prefer
| |
12 } | |
13 | |
14 IUnknownImpl::~IUnknownImpl() { | |
15 } | |
16 | |
17 ULONG STDMETHODCALLTYPE IUnknownImpl::AddRef() { | |
18 return base::AtomicRefCountIncAndReturnValue(&ref_count_); | |
19 } | |
20 | |
21 ULONG STDMETHODCALLTYPE IUnknownImpl::Release() { | |
22 AtomicRefCount new_ref_count = | |
23 base::AtomicRefCountDecAndReturnValue(&ref_count_); | |
24 if (new_ref_count == 0) | |
25 delete this; | |
26 return new_ref_count; | |
27 } | |
28 | |
29 STDMETHODIMP IUnknownImpl::QueryInterface(REFIID riid, void** ppv) { | |
30 if (riid == IID_IUnknown) { | |
31 *ppv = static_cast<IUnknown*>(this); | |
32 AddRef(); | |
33 return S_OK; | |
34 } | |
35 | |
36 *ppv = NULL; | |
37 return E_NOINTERFACE; | |
38 } | |
39 | |
40 } // namespace win | |
41 } // namespace base | |
OLD | NEW |