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_(0) {} | |
M-A Ruel
2011/12/01 00:35:13
One reason to keep the brackets on two lines, like
dmazzoni
2011/12/02 00:44:07
Done.
| |
12 | |
13 IUnknownImpl::~IUnknownImpl() { | |
14 } | |
15 | |
16 ULONG STDMETHODCALLTYPE IUnknownImpl::AddRef() { | |
17 return base::AtomicRefCountIncAndReturnValue(&ref_count_); | |
18 } | |
19 | |
20 ULONG STDMETHODCALLTYPE IUnknownImpl::Release() { | |
21 AtomicRefCount new_ref_count = | |
22 base::AtomicRefCountDecAndReturnValue(&ref_count_); | |
23 if (new_ref_count == 0) | |
24 delete this; | |
25 return new_ref_count; | |
26 } | |
27 | |
28 STDMETHODIMP IUnknownImpl::QueryInterface(REFIID riid, void** ppv) { | |
29 if (riid == IID_IUnknown) { | |
30 *ppv = static_cast<IUnknown*>(this); | |
31 AddRef(); | |
32 return S_OK; | |
33 } | |
34 | |
35 *ppv = NULL; | |
36 return E_NOINTERFACE; | |
37 } | |
38 | |
39 } // namespace win | |
40 } // namespace base | |
OLD | NEW |