APIContentRuleListStore.h [plain text]
#pragma once
#if ENABLE(CONTENT_EXTENSIONS)
#include "APIObject.h"
#include <system_error>
#include <wtf/text/WTFString.h>
namespace WebCore {
class SharedBuffer;
}
namespace WTF {
class WorkQueue;
}
namespace API {
class ContentRuleList;
class ContentRuleListStore final : public ObjectImpl<Object::Type::ContentRuleListStore> {
public:
enum class Error {
LookupFailed = 1,
VersionMismatch,
CompileFailed,
RemoveFailed
};
static constexpr uint32_t CurrentContentRuleListFileVersion = 10;
static ContentRuleListStore& defaultStore(bool legacyFilename);
static Ref<ContentRuleListStore> storeWithPath(const WTF::String& storePath, bool legacyFilename);
explicit ContentRuleListStore(bool legacyFilename);
explicit ContentRuleListStore(const WTF::String& storePath, bool legacyFilename);
virtual ~ContentRuleListStore();
void compileContentRuleList(const WTF::String& identifier, WTF::String&& json, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>);
void lookupContentRuleList(const WTF::String& identifier, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>);
void removeContentRuleList(const WTF::String& identifier, CompletionHandler<void(std::error_code)>);
void getAvailableContentRuleListIdentifiers(CompletionHandler<void(WTF::Vector<WTF::String>)>);
void synchronousRemoveAllContentRuleLists();
void invalidateContentRuleListVersion(const WTF::String& identifier);
void getContentRuleListSource(const WTF::String& identifier, CompletionHandler<void(WTF::String)>);
private:
WTF::String defaultStorePath(bool legacyFilename);
static ContentRuleListStore& legacyDefaultStore();
static ContentRuleListStore& nonLegacyDefaultStore();
const WTF::String m_storePath;
Ref<WTF::WorkQueue> m_compileQueue;
Ref<WTF::WorkQueue> m_readQueue;
Ref<WTF::WorkQueue> m_removeQueue;
bool m_legacyFilename { false };
};
const std::error_category& contentRuleListStoreErrorCategory();
inline std::error_code make_error_code(ContentRuleListStore::Error error)
{
return { static_cast<int>(error), contentRuleListStoreErrorCategory() };
}
}
namespace std {
template<> struct is_error_code_enum<API::ContentRuleListStore::Error> : public true_type { };
}
#endif // ENABLE(CONTENT_EXTENSIONS)