progress.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef HEADER_CURL_PROGRESS_H
  2. #define HEADER_CURL_PROGRESS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "curlx/timeval.h"
  27. struct Curl_easy;
  28. typedef enum {
  29. TIMER_NONE,
  30. TIMER_STARTOP,
  31. TIMER_STARTSINGLE, /* start of transfer, might get queued */
  32. TIMER_POSTQUEUE, /* start, immediately after dequeue */
  33. TIMER_NAMELOOKUP,
  34. TIMER_CONNECT,
  35. TIMER_APPCONNECT,
  36. TIMER_PRETRANSFER,
  37. TIMER_STARTTRANSFER,
  38. TIMER_POSTRANSFER,
  39. TIMER_STARTACCEPT,
  40. TIMER_REDIRECT,
  41. TIMER_LAST /* must be last */
  42. } timerid;
  43. /* Get the current timestamp of the transfer */
  44. const struct curltime *Curl_pgrs_now(struct Curl_easy *data);
  45. int Curl_pgrsDone(struct Curl_easy *data);
  46. void Curl_pgrsStartNow(struct Curl_easy *data);
  47. void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
  48. void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
  49. void Curl_pgrs_download_inc(struct Curl_easy *data, size_t delta);
  50. void Curl_pgrs_upload_inc(struct Curl_easy *data, size_t delta);
  51. void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
  52. /* perform progress update, invoking callbacks at intervals */
  53. CURLcode Curl_pgrsUpdate(struct Curl_easy *data);
  54. /* perform progress update, no callbacks invoked */
  55. void Curl_pgrsUpdate_nometer(struct Curl_easy *data);
  56. /* perform progress update with callbacks and speed checks */
  57. CURLcode Curl_pgrsCheck(struct Curl_easy *data);
  58. /* Inform progress/speedcheck about receive/send pausing */
  59. void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable);
  60. void Curl_pgrsSendPause(struct Curl_easy *data, bool enable);
  61. /* Reset sizes and counters for up- and download. */
  62. void Curl_pgrsReset(struct Curl_easy *data);
  63. /* Reset sizes for up- and download. */
  64. void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
  65. void Curl_pgrsTime(struct Curl_easy *data, timerid timer);
  66. /**
  67. * Update progress timer with the elapsed time from its start to `timestamp`.
  68. * This allows updating timers later and is used by happy eyeballing, where
  69. * we only want to record the winner's times.
  70. */
  71. void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
  72. struct curltime timestamp);
  73. void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent);
  74. #ifdef UNITTESTS
  75. UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
  76. const struct curltime *pnow);
  77. #endif
  78. #endif /* HEADER_CURL_PROGRESS_H */