VirtualBox

Changeset 58217 in vbox


Ignore:
Timestamp:
Oct 13, 2015 3:36:47 PM (9 years ago)
Author:
vboxsync
Message:

Runtime/http-curl: added RTHttpSetDownloadProgressCallback()

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/http.h

    r58199 r58217  
    4444/** Nil HTTP/HTTPS client handle. */
    4545#define NIL_RTHTTP                              ((RTHTTP)0)
     46/** Callback function to be called during RTHttpGet*(). Register it using RTHttpSetDownloadProgressCallback(). */
     47typedef DECLCALLBACK(void) RTHTTPDOWNLDPROGRCALLBACK(RTHTTP hHttp, void *pvUser, uint64_t cbDownloadTotal, uint64_t cbDownloaded);
     48typedef RTHTTPDOWNLDPROGRCALLBACK *PRTHTTPDOWNLDPROGRCALLBACK;
     49
    4650
    4751
     
    283287RTR3DECL(int) RTHttpGatherCaCertsInFile(const char *pszCaFile, uint32_t fFlags, PRTERRINFO pErrInfo);
    284288
     289/**
     290 * Set a callback function which is called during RTHttpGet*()
     291 *
     292 * @returns IPRT status code.
     293 * @param   hHttp           The HTTP client instance.
     294 * @param   pfnDownloadProgress Progress function to be called. Set it to
     295 *                          NULL to disable the callback.
     296 */
     297RTR3DECL(int) RTHttpSetDownloadProgressCallback(RTHTTP hHttp, PRTHTTPDOWNLDPROGRCALLBACK pfnDownloadProgress);
     298
     299
    285300/** @} */
    286301
  • trunk/src/VBox/Runtime/generic/http-curl.cpp

    r58206 r58217  
    150150    /** Download size hint set by the progress callback. */
    151151    uint64_t            cbDownloadHint;
     152    /** Callback called during download. */
     153    PRTHTTPDOWNLDPROGRCALLBACK pfnDownloadProgress;
     154    /** User pointer parameter for pfnDownloadProgress. */
     155    void               *pvDownloadProgressUser;
    152156} RTHTTPINTERNAL;
    153157/** Pointer to an internal HTTP client instance. */
     
    21212125    pThis->cbDownloadHint = (uint64_t)rdTotalDownload;
    21222126
     2127    if (pThis->pfnDownloadProgress)
     2128        pThis->pfnDownloadProgress(pThis, pThis->pvDownloadProgressUser, (uint64_t)rdTotalDownload, (uint64_t)rdDownloaded);
     2129
    21232130    return pThis->fAbort ? 1 : 0;
    21242131}
     
    25052512}
    25062513
     2514
     2515RTR3DECL(int) RTHttpSetDownloadProgressCallback(RTHTTP hHttp, PRTHTTPDOWNLDPROGRCALLBACK pfnDownloadProgress, void *pvUser)
     2516{
     2517    PRTHTTPINTERNAL pThis = hHttp;
     2518    RTHTTP_VALID_RETURN(pThis);
     2519
     2520    pThis->pfnDownloadProgress = pfnDownloadProgress;
     2521    pThis->pvDownloadProgressUser = pvUser;
     2522    return VINF_SUCCESS;
     2523}
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