llhttpassetstorage.h

Go to the documentation of this file.
00001 
00032 #ifndef LLHTTPASSETSTORAGE_H
00033 #define LLHTTPASSETSTORAGE_H
00034 
00035 #include "llassetstorage.h"
00036 #include "curl/curl.h"
00037 
00038 class LLVFile;
00039 class LLHTTPAssetRequest;
00040 typedef void (*progress_callback)(void* userdata);
00041 
00042 struct LLTempAssetData;
00043 
00044 typedef std::map<LLUUID,LLTempAssetData> uuid_tempdata_map;
00045 
00046 class LLHTTPAssetStorage : public LLAssetStorage
00047 {
00048 public:
00049         LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer,
00050                                            LLVFS *vfs, const LLHost &upstream_host,
00051                                            const char *web_host,
00052                                            const char *local_web_host,
00053                                            const char *host_name);
00054 
00055         LLHTTPAssetStorage(LLMessageSystem *msg, LLXferManager *xfer,
00056                                            LLVFS *vfs,
00057                                            const char *web_host,
00058                                            const char *local_web_host,
00059                                            const char *host_name);
00060 
00061 
00062         virtual ~LLHTTPAssetStorage();
00063 
00064         virtual void storeAssetData(
00065                 const LLUUID& uuid,
00066                 LLAssetType::EType atype,
00067                 LLStoreAssetCallback callback,
00068                 void* user_data,
00069                 bool temp_file = false,
00070                 bool is_priority = false,
00071                 bool store_local = false,
00072                 const LLUUID& requesting_agent_id = LLUUID::null,
00073                 bool user_waiting=FALSE,
00074                 F64 timeout=LL_ASSET_STORAGE_TIMEOUT);
00075 
00076         virtual void storeAssetData(
00077                 const char* filename,
00078                 const LLUUID& asset_id,
00079                 LLAssetType::EType atype,
00080                 LLStoreAssetCallback callback,
00081                 void* user_data,
00082                 bool temp_file,
00083                 bool is_priority,
00084                 bool user_waiting=FALSE,
00085                 F64 timeout=LL_ASSET_STORAGE_TIMEOUT);
00086 
00087         virtual LLSD getPendingDetails(ERequestType rt,
00088                                         LLAssetType::EType asset_type,
00089                                         const std::string& detail_prefix) const;
00090 
00091         virtual LLSD getPendingRequest(ERequestType rt,
00092                                                         LLAssetType::EType asset_type,
00093                                                         const LLUUID& asset_id) const;
00094 
00095         virtual bool deletePendingRequest(ERequestType rt,
00096                                                         LLAssetType::EType asset_type,
00097                                                         const LLUUID& asset_id);
00098 
00099         // Hack.  One off curl download an URL to a file.  Probably should be elsewhere.
00100         // Only used by lldynamicstate.  The API is broken, and should be replaced with
00101         // a generic HTTP file fetch - Doug 9/25/06
00102         S32 getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata);
00103         
00104         LLAssetRequest* findNextRequest(request_list_t& pending, request_list_t& running);
00105 
00106         void checkForTimeouts();
00107         
00108         static size_t curlDownCallback(void *data, size_t size, size_t nmemb, void *user_data);
00109         static size_t curlFileDownCallback(void *data, size_t size, size_t nmemb, void *user_data);
00110         static size_t curlUpCallback(void *data, size_t size, size_t nmemb, void *user_data);
00111         static size_t nullOutputCallback(void *data, size_t size, size_t nmemb, void *user_data);
00112 
00113         // Should only be used by the LLHTTPAssetRequest
00114         void addRunningRequest(ERequestType rt, LLHTTPAssetRequest* request);
00115         void removeRunningRequest(ERequestType rt, LLHTTPAssetRequest* request);
00116 
00117         request_list_t* getRunningList(ERequestType rt);
00118         const request_list_t* getRunningList(ERequestType rt) const;
00119 
00120         // Temp assets are stored on sim nodes, they have agent ID and location data associated with them.
00121         virtual void addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name);
00122         virtual BOOL hasTempAssetData(const LLUUID& texture_id) const;
00123         virtual std::string getTempAssetHostName(const LLUUID& texture_id) const;
00124         virtual LLUUID getTempAssetAgentID(const LLUUID& texture_id) const;
00125         virtual void removeTempAssetData(const LLUUID& asset_id);
00126         virtual void removeTempAssetDataByAgentID(const LLUUID& agent_id);
00127 
00128         // Pass LLUUID::null for all
00129         virtual void dumpTempAssetData(const LLUUID& avatar_id) const;
00130         virtual void clearTempAssetData();
00131 
00132 protected:
00133         void _queueDataRequest(const LLUUID& uuid, LLAssetType::EType type,
00134                                                    void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32, LLExtStat),
00135                                                    void *user_data, BOOL duplicate, BOOL is_priority);
00136 
00137 private:
00138         void _init(const char *web_host, const char *local_web_host, const char* host_name);
00139 
00140         // This will return the correct base URI for any http asset request
00141         std::string getBaseURL(const LLUUID& asset_id, LLAssetType::EType asset_type);
00142 
00143         // Check for running uploads that have timed out
00144         // Bump these to the back of the line to let other uploads complete.
00145         void bumpTimedOutUploads();
00146 
00147 protected:
00148         std::string             mBaseURL;
00149         std::string             mLocalBaseURL;
00150         std::string             mHostName;
00151 
00152         CURLM  *mCurlMultiHandle;
00153 
00154         request_list_t mRunningDownloads;
00155         request_list_t mRunningUploads;
00156         request_list_t mRunningLocalUploads;
00157 
00158         uuid_tempdata_map mTempAssets;
00159 };
00160 
00161 #endif

Generated on Fri May 16 08:32:25 2008 for SecondLife by  doxygen 1.5.5