/src/mozilla-central/toolkit/components/url-classifier/LookupCacheV4.h
Line | Count | Source (jump to first uncovered line) |
1 | | //* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef LookupCacheV4_h__ |
7 | | #define LookupCacheV4_h__ |
8 | | |
9 | | #include "LookupCache.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace safebrowsing { |
13 | | |
14 | | // Forward declaration. |
15 | | class TableUpdateV4; |
16 | | |
17 | | class LookupCacheV4 final : public LookupCache |
18 | | { |
19 | | public: |
20 | | explicit LookupCacheV4(const nsACString& aTableName, |
21 | | const nsACString& aProvider, |
22 | | nsCOMPtr<nsIFile>& aStoreFile) |
23 | 0 | : LookupCache(aTableName, aProvider, aStoreFile) {} |
24 | | |
25 | | virtual nsresult Init() override; |
26 | | virtual nsresult Has(const Completion& aCompletion, |
27 | | bool* aHas, |
28 | | uint32_t* aMatchLength, |
29 | | bool* aConfirmed) override; |
30 | | |
31 | | virtual bool IsEmpty() const override; |
32 | | |
33 | | nsresult Build(PrefixStringMap& aPrefixMap); |
34 | | |
35 | | nsresult GetPrefixes(PrefixStringMap& aPrefixMap); |
36 | | nsresult GetFixedLengthPrefixes(FallibleTArray<uint32_t>& aPrefixes); |
37 | | |
38 | | // ApplyUpdate will merge data stored in aTableUpdate with prefixes in aInputMap. |
39 | | nsresult ApplyUpdate(RefPtr<TableUpdateV4> aTableUpdate, |
40 | | PrefixStringMap& aInputMap, |
41 | | PrefixStringMap& aOutputMap); |
42 | | |
43 | | nsresult AddFullHashResponseToCache(const FullHashResponseMap& aResponseMap); |
44 | | |
45 | | nsresult WriteMetadata(RefPtr<const TableUpdateV4> aTableUpdate); |
46 | | nsresult LoadMetadata(nsACString& aState, nsACString& aChecksum); |
47 | | |
48 | | static const int VER; |
49 | | static const uint32_t MAX_METADATA_VALUE_LENGTH; |
50 | | |
51 | | protected: |
52 | | virtual nsresult ClearPrefixes() override; |
53 | | virtual nsresult StoreToFile(nsCOMPtr<nsIFile>& aFile) override; |
54 | | virtual nsresult LoadFromFile(nsCOMPtr<nsIFile>& aFile) override; |
55 | | virtual size_t SizeOfPrefixSet() const override; |
56 | | |
57 | | private: |
58 | 0 | ~LookupCacheV4() {} |
59 | | |
60 | 0 | virtual int Ver() const override { return VER; } |
61 | | |
62 | | nsresult VerifyChecksum(const nsACString& aChecksum); |
63 | | |
64 | | RefPtr<VariableLengthPrefixSet> mVLPrefixSet; |
65 | | }; |
66 | | |
67 | | } // namespace safebrowsing |
68 | | } // namespace mozilla |
69 | | |
70 | | #endif |