| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <atlbase.h> | |
| 6 | |
| 7 #include "base/base_drag_source.h" | 5 #include "base/base_drag_source.h" |
| 8 | 6 |
| 9 /////////////////////////////////////////////////////////////////////////////// | 7 /////////////////////////////////////////////////////////////////////////////// |
| 10 // BaseDragSource, public: | 8 // BaseDragSource, public: |
| 11 | 9 |
| 12 BaseDragSource::BaseDragSource() : ref_count_(0) { | 10 BaseDragSource::BaseDragSource() : ref_count_(0) { |
| 13 } | 11 } |
| 14 | 12 |
| 15 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
| 16 // BaseDragSource, IDropSource implementation: | 14 // BaseDragSource, IDropSource implementation: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 43 if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropSource)) { | 41 if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropSource)) { |
| 44 *object = this; | 42 *object = this; |
| 45 } else { | 43 } else { |
| 46 return E_NOINTERFACE; | 44 return E_NOINTERFACE; |
| 47 } | 45 } |
| 48 AddRef(); | 46 AddRef(); |
| 49 return S_OK; | 47 return S_OK; |
| 50 } | 48 } |
| 51 | 49 |
| 52 ULONG BaseDragSource::AddRef() { | 50 ULONG BaseDragSource::AddRef() { |
| 53 return InterlockedIncrement(&ref_count_); | 51 return ++ref_count_; |
| 54 } | 52 } |
| 55 | 53 |
| 56 ULONG BaseDragSource::Release() { | 54 ULONG BaseDragSource::Release() { |
| 57 if (InterlockedDecrement(&ref_count_) == 0) { | 55 if (--ref_count_ == 0) { |
| 58 ULONG copied_refcnt = ref_count_; | |
| 59 delete this; | 56 delete this; |
| 60 return copied_refcnt; | 57 return 0U; |
| 61 } | 58 } |
| 62 return ref_count_; | 59 return ref_count_; |
| 63 } | 60 } |
| 64 | |
| OLD | NEW |