Overte C++ Documentation
AssetResourceRequest.h
1 //
2 // AssetResourceRequest.h
3 // libraries/networking/src
4 //
5 // Created by Ryan Huffman on 2015/07/23
6 // Copyright 2015 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_AssetResourceRequest_h
13 #define hifi_AssetResourceRequest_h
14 
15 #include <QUrl>
16 
17 #include <PortableHighResolutionClock.h>
18 
19 #include "AssetRequest.h"
20 #include "ResourceRequest.h"
21 
22 class AssetResourceRequest : public ResourceRequest {
23  Q_OBJECT
24 public:
25  AssetResourceRequest(
26  const QUrl& url,
27  const bool isObservable = true,
28  const qint64 callerId = -1,
29  const QString& extra = "");
30  virtual ~AssetResourceRequest() override;
31 
32 protected:
33  virtual void doSend() override;
34 
35 private slots:
36  void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
37 
38 private:
39  static bool urlIsAssetHash(const QUrl& url);
40 
41  void requestMappingForPath(const AssetUtils::AssetPath& path);
42  void requestHash(const AssetUtils::AssetHash& hash);
43 
44  GetMappingRequest* _assetMappingRequest { nullptr };
45  AssetRequest* _assetRequest { nullptr };
46 
47  p_high_resolution_clock::time_point _lastProgressDebug;
48 
49  int64_t _lastRecordedBytesDownloaded { 0 };
50 };
51 
52 #endif