llviewerassetstorage.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * @file llviewerassetstorage.h
  3. * @brief Class for loading asset data to/from an external source.
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LLVIEWERASSETSTORAGE_H
  33. #define LLVIEWERASSETSTORAGE_H
  34. #include <list>
  35. #include "llassetstorage.h"
  36. #include "llcorehttprequest.h"
  37. class LLViewerAssetStorage final : public LLAssetStorage
  38. {
  39. protected:
  40. LOG_CLASS(LLViewerAssetStorage);
  41. public:
  42. LLViewerAssetStorage(LLMessageSystem* msg, LLXferManager* xfer);
  43. ~LLViewerAssetStorage() override;
  44. void storeAssetData(const LLTransactionID& tid, LLAssetType::EType atype,
  45. LLStoreAssetCallback callback, void* user_data,
  46. bool temp_file = false, bool is_priority = false,
  47. bool store_local = false, bool user_waiting = false,
  48. F64 timeout = LL_ASSET_STORAGE_TIMEOUT) override;
  49. void storeAssetData(const std::string& fname, const LLTransactionID& tid,
  50. LLAssetType::EType type, LLStoreAssetCallback callback,
  51. void* user_data, bool temp_file = false,
  52. bool is_priority = false, bool user_waiting = false,
  53. F64 timeout = LL_ASSET_STORAGE_TIMEOUT) override;
  54. void checkForTimeouts() override;
  55. protected:
  56. void queueDataRequest(const LLUUID& uuid, LLAssetType::EType type,
  57. LLGetAssetCallback callback, void* user_data,
  58. bool duplicate, bool is_priority) override;
  59. void queueUdpRequest(const LLUUID& uuid, LLAssetType::EType type,
  60. LLGetAssetCallback callback, void* user_data,
  61. bool duplicate, bool is_priority);
  62. void queueHttpRequest(const LLUUID& uuid, LLAssetType::EType type,
  63. LLGetAssetCallback callback, void* user_data,
  64. bool duplicate, bool is_priority);
  65. void assetRequestCoro(std::string query, LLAssetRequest* req, LLUUID uuid,
  66. LLAssetType::EType atype,
  67. LLGetAssetCallback callback, void* user_data);
  68. protected:
  69. // Asset storage works through coprocedures which have a limited queue
  70. // capacity. This structure is meant to temporary store requests when the
  71. // coprocedure queue is full.
  72. struct CoroWaitList
  73. {
  74. CoroWaitList(LLAssetRequest* req, const std::string& url,
  75. const LLUUID& asset_id, LLAssetType::EType atype,
  76. LLGetAssetCallback callback, void* user_data)
  77. : mRequest(req),
  78. mUrl(url),
  79. mId(asset_id),
  80. mType(atype),
  81. mCallback(callback),
  82. mUserData(user_data)
  83. {
  84. }
  85. LLAssetRequest* mRequest;
  86. std::string mUrl;
  87. LLUUID mId;
  88. LLAssetType::EType mType;
  89. LLGetAssetCallback mCallback;
  90. void* mUserData;
  91. };
  92. typedef std::list<CoroWaitList> wait_list_t;
  93. wait_list_t mCoroWaitList;
  94. LLCore::HttpRequest::policy_t mHttpPolicyClass;
  95. };
  96. #endif