michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsCacheMetaData_h_ michael@0: #define _nsCacheMetaData_h_ michael@0: michael@0: #include "nspr.h" michael@0: #include "nscore.h" michael@0: michael@0: class nsICacheMetaDataVisitor; michael@0: michael@0: class nsCacheMetaData { michael@0: public: michael@0: nsCacheMetaData() : mBuffer(nullptr), mBufferSize(0), mMetaSize(0) { } michael@0: michael@0: ~nsCacheMetaData() { michael@0: mBufferSize = mMetaSize = 0; michael@0: moz_free(mBuffer); michael@0: mBuffer = nullptr; michael@0: } michael@0: michael@0: const char * GetElement(const char * key); michael@0: michael@0: nsresult SetElement(const char * key, const char * value); michael@0: michael@0: uint32_t Size(void) { return mMetaSize; } michael@0: michael@0: nsresult FlattenMetaData(char * buffer, uint32_t bufSize); michael@0: michael@0: nsresult UnflattenMetaData(const char * buffer, uint32_t bufSize); michael@0: michael@0: nsresult VisitElements(nsICacheMetaDataVisitor * visitor); michael@0: michael@0: private: michael@0: nsresult EnsureBuffer(uint32_t size); michael@0: michael@0: char * mBuffer; michael@0: uint32_t mBufferSize; michael@0: uint32_t mMetaSize; michael@0: }; michael@0: michael@0: #endif // _nsCacheMetaData_h