progress.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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, <daniel@haxx.se>, 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 "timeval.h"
  27. typedef enum {
  28. TIMER_NONE,
  29. TIMER_STARTOP,
  30. TIMER_STARTSINGLE, /* start of transfer, might get queued */
  31. TIMER_POSTQUEUE, /* start, immediately after dequeue */
  32. TIMER_NAMELOOKUP,
  33. TIMER_CONNECT,
  34. TIMER_APPCONNECT,
  35. TIMER_PRETRANSFER,
  36. TIMER_STARTTRANSFER,
  37. TIMER_POSTRANSFER,
  38. TIMER_STARTACCEPT,
  39. TIMER_REDIRECT,
  40. TIMER_LAST /* must be last */
  41. } timerid;
  42. int Curl_pgrsDone(struct Curl_easy *data);
  43. void Curl_pgrsStartNow(struct Curl_easy *data);
  44. void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
  45. void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
  46. /* It is fine to not check the return code if 'size' is set to 0 */
  47. CURLcode Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
  48. void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
  49. void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
  50. int Curl_pgrsUpdate(struct Curl_easy *data);
  51. void Curl_pgrsUpdate_nometer(struct Curl_easy *data);
  52. void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
  53. struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
  54. timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d,
  55. curl_off_t speed_limit,
  56. struct curltime now);
  57. /**
  58. * Update progress timer with the elapsed time from its start to `timestamp`.
  59. * This allows updating timers later and is used by happy eyeballing, where
  60. * we only want to record the winner's times.
  61. */
  62. void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
  63. struct curltime timestamp);
  64. void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent);
  65. #define PGRS_HIDE (1<<4)
  66. #define PGRS_UL_SIZE_KNOWN (1<<5)
  67. #define PGRS_DL_SIZE_KNOWN (1<<6)
  68. #define PGRS_HEADERS_OUT (1<<7) /* set when the headers have been written */
  69. #endif /* HEADER_CURL_PROGRESS_H */