예제 #1
0
void NetworkAdapter::updateBandwidthGroup(BandwidthGroup *aBwGroup)
{
    LogFlowThisFuncEnter();
    Assert(isWriteLockOnCurrentThread());

    ComObjPtr<BandwidthGroup> pOldBwGroup;
    if (!mData->mBandwidthGroup.isEmpty())
        {
            HRESULT hrc = mParent->getBandwidthGroup(mData->mBandwidthGroup, pOldBwGroup, false /* fSetError */);
            NOREF(hrc);
            Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of the group was checked when it was attached. */
        }

    mData.backup();
    if (!pOldBwGroup.isNull())
    {
        pOldBwGroup->release();
        mData->mBandwidthGroup = Utf8Str::Empty;
    }

    if (aBwGroup)
    {
        mData->mBandwidthGroup = aBwGroup->getName();
        aBwGroup->reference();
    }

    LogFlowThisFuncLeave();
}