diff --git a/api/@ohos.request.cacheDownload.d.ts b/api/@ohos.request.cacheDownload.d.ts index 6a7e13cafa8931457573a96d940e8f15e020ac80..97e5e3b257b14957ece83cc84e8883519f4d8195 100644 --- a/api/@ohos.request.cacheDownload.d.ts +++ b/api/@ohos.request.cacheDownload.d.ts @@ -28,6 +28,15 @@ import { BusinessError } from './@ohos.base'; * @since 18 */ declare namespace cacheDownload { + /** + * The secure communication protocol. + * + * @typedef { 'TLS' | 'TLCP' } + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + export type SslType = 'TLS' | 'TLCP'; + /** * Options of the cache download task. * @@ -44,6 +53,133 @@ declare namespace cacheDownload { * @since 18 */ headers?: Record; + /** + * Which secure communication protocol is used. + * If this value is not specified, use 'TLS' by default. + * + * @type { ?SslType } + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + sslType?: SslType; + } + + /** + * Network information of historical cache downloads. + * + * @typedef NetworkInfo + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + interface NetworkInfo { + /** + * The IP address of a specific URL is used when downloading resources. + * + * @type string + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly ip: string; + /** + * The DNS server list is used when downloading resources. + * + * @type string[] + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly dnsServers: string[]; + } + + /** + * Performance information of historical cache downloads. + * + * @typedef PerformanceInfo + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + interface PerformanceInfo { + /** + * Time taken from startup to DNS resolution completion, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly dnsTiming: number; + /** + * Time taken from startup to TCP connection completion, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly connectTiming: number; + /** + * Time taken from startup to TLS connection completion, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly tlsTiming: number; + /** + * Time taken from startup to start sending the first byte, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly firstSendTiming: number; + /** + * Time taken from startup to receiving the first byte, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly firstReceiveTiming: number; + /** + * Time taken from startup to the completion of the request, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly totalTiming: number; + /** + * Time taken from startup to completion of all redirection steps, in milliseconds. + * + * @type number + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly redirectTiming: number; + } + + /** + * Information of historical cache downloads. + * + * @typedef CacheDownloadOptions + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + interface CacheInfo { + /** + * Network information of historical cache downloads. + * + * @type NetworkInfo + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly network: NetworkInfo; + /** + * Performance information of historical cache downloads. + * + * @type PerformanceInfo + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + */ + readonly performance: PerformanceInfo; } /** @@ -100,6 +236,18 @@ declare namespace cacheDownload { * @since 18 */ function setFileCacheSize(bytes: number); + + /** + * Gets historical information of cache downloads based on URL. + * If the specified URL has been downloaded before, return `CacheInfo`. + * If the specified URL has not been downloaded before, return `undefined`. + * + * @param { string } url - URL to be queried. + * @syscap SystemCapability.Request.FileTransferAgent + * @since 20 + * @arkts 1.1&1.2 + */ + function getCacheInfo(url: string): CacheInfo | undefined; } export default cacheDownload; \ No newline at end of file