Home | History | Annotate | Download | only in win
      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) {
     12 }
     13 
     14 IUnknownImpl::~IUnknownImpl() {
     15 }
     16 
     17 ULONG STDMETHODCALLTYPE IUnknownImpl::AddRef() {
     18   base::AtomicRefCountInc(&ref_count_);
     19   return 1;
     20 }
     21 
     22 ULONG STDMETHODCALLTYPE IUnknownImpl::Release() {
     23   if (!base::AtomicRefCountDec(&ref_count_)) {
     24     delete this;
     25     return 0;
     26   }
     27   return 1;
     28 }
     29 
     30 STDMETHODIMP IUnknownImpl::QueryInterface(REFIID riid, void** ppv) {
     31   if (riid == IID_IUnknown) {
     32     *ppv = static_cast<IUnknown*>(this);
     33     AddRef();
     34     return S_OK;
     35   }
     36 
     37   *ppv = NULL;
     38   return E_NOINTERFACE;
     39 }
     40 
     41 }  // namespace win
     42 }  // namespace base
     43