VirtualBox

Ignore:
Timestamp:
Oct 25, 2017 6:57:26 PM (7 years ago)
Author:
vboxsync
Message:

Medium: use ready made callback which optimizes update frequency, not a simple private implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r68789 r69321  
    242242        /* Set up a per-operation progress interface, can be used freely (for
    243243         * binary operations you can use it either on the source or target). */
    244         mVDIfProgress.pfnProgress = vdProgressCall;
     244        mVDIfProgress = VDINTERFACEPROGRESS_INITALIZER(aProgress->i_vdProgressCallback);
    245245        int vrc = VDInterfaceAdd(&mVDIfProgress.Core,
    246246                                "Medium::Task::vdInterfaceProgress",
    247247                                VDINTERFACETYPE_PROGRESS,
    248248                                mProgress,
    249                                 sizeof(VDINTERFACEPROGRESS),
     249                                sizeof(mVDIfProgress),
    250250                                &mVDOperationIfaces);
    251251        AssertRC(vrc);
     
    315315
    316316    const ComObjPtr<Progress> mProgress;
    317 
    318     static DECLCALLBACK(int) vdProgressCall(void *pvUser, unsigned uPercent);
    319317
    320318    VDINTERFACEPROGRESS mVDIfProgress;
     
    800798    VDINTERFACECRYPTO vdIfCrypto;
    801799};
    802 
    803 /**
    804  * PFNVDPROGRESS callback handler for Task operations.
    805  *
    806  * @param pvUser      Pointer to the Progress instance.
    807  * @param uPercent    Completion percentage (0-100).
    808  */
    809 /*static*/
    810 DECLCALLBACK(int) Medium::Task::vdProgressCall(void *pvUser, unsigned uPercent)
    811 {
    812     Progress *that = static_cast<Progress *>(pvUser);
    813 
    814     if (that != NULL)
    815     {
    816         /* update the progress object, capping it at 99% as the final percent
    817          * is used for additional operations like setting the UUIDs and similar. */
    818         HRESULT rc = that->SetCurrentOperationProgress(uPercent * 99 / 100);
    819         if (FAILED(rc))
    820         {
    821             if (rc == E_FAIL)
    822                 return VERR_CANCELLED;
    823             else
    824                 return VERR_INVALID_STATE;
    825         }
    826     }
    827 
    828     return VINF_SUCCESS;
    829 }
    830800
    831801/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette