Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | //* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsUrlClassifierPrefixSet_h_ |
michael@0 | 8 | #define nsUrlClassifierPrefixSet_h_ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsISupportsUtils.h" |
michael@0 | 11 | #include "nsID.h" |
michael@0 | 12 | #include "nsIFile.h" |
michael@0 | 13 | #include "nsIMemoryReporter.h" |
michael@0 | 14 | #include "nsIMutableArray.h" |
michael@0 | 15 | #include "nsIUrlClassifierPrefixSet.h" |
michael@0 | 16 | #include "nsTArray.h" |
michael@0 | 17 | #include "nsToolkitCompsCID.h" |
michael@0 | 18 | #include "mozilla/MemoryReporting.h" |
michael@0 | 19 | #include "mozilla/Mutex.h" |
michael@0 | 20 | #include "mozilla/CondVar.h" |
michael@0 | 21 | #include "mozilla/FileUtils.h" |
michael@0 | 22 | |
michael@0 | 23 | class nsUrlClassifierPrefixSet |
michael@0 | 24 | : public nsIUrlClassifierPrefixSet |
michael@0 | 25 | , public nsIMemoryReporter |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | nsUrlClassifierPrefixSet(); |
michael@0 | 29 | virtual ~nsUrlClassifierPrefixSet(); |
michael@0 | 30 | |
michael@0 | 31 | NS_IMETHOD Init(const nsACString& aName); |
michael@0 | 32 | NS_IMETHOD SetPrefixes(const uint32_t* aArray, uint32_t aLength); |
michael@0 | 33 | NS_IMETHOD GetPrefixes(uint32_t* aCount, uint32_t** aPrefixes); |
michael@0 | 34 | NS_IMETHOD Contains(uint32_t aPrefix, bool* aFound); |
michael@0 | 35 | NS_IMETHOD IsEmpty(bool* aEmpty); |
michael@0 | 36 | NS_IMETHOD LoadFromFile(nsIFile* aFile); |
michael@0 | 37 | NS_IMETHOD StoreToFile(nsIFile* aFile); |
michael@0 | 38 | |
michael@0 | 39 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 40 | NS_DECL_NSIMEMORYREPORTER |
michael@0 | 41 | |
michael@0 | 42 | // Return the estimated size of the set on disk and in memory, in bytes. |
michael@0 | 43 | size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); |
michael@0 | 44 | |
michael@0 | 45 | protected: |
michael@0 | 46 | static const uint32_t DELTAS_LIMIT = 100; |
michael@0 | 47 | static const uint32_t MAX_INDEX_DIFF = (1 << 16); |
michael@0 | 48 | static const uint32_t PREFIXSET_VERSION_MAGIC = 1; |
michael@0 | 49 | |
michael@0 | 50 | nsresult MakePrefixSet(const uint32_t* aArray, uint32_t aLength); |
michael@0 | 51 | uint32_t BinSearch(uint32_t start, uint32_t end, uint32_t target); |
michael@0 | 52 | nsresult LoadFromFd(mozilla::AutoFDClose& fileFd); |
michael@0 | 53 | nsresult StoreToFd(mozilla::AutoFDClose& fileFd); |
michael@0 | 54 | |
michael@0 | 55 | // boolean indicating whether |setPrefixes| has been |
michael@0 | 56 | // called with a non-empty array. |
michael@0 | 57 | bool mHasPrefixes; |
michael@0 | 58 | // the prefix for each index. |
michael@0 | 59 | FallibleTArray<uint32_t> mIndexPrefixes; |
michael@0 | 60 | // the value corresponds to the beginning of the run |
michael@0 | 61 | // (an index in |_deltas|) for the index |
michael@0 | 62 | FallibleTArray<uint32_t> mIndexStarts; |
michael@0 | 63 | // array containing deltas from indices. |
michael@0 | 64 | FallibleTArray<uint16_t> mDeltas; |
michael@0 | 65 | |
michael@0 | 66 | nsCString mMemoryReportPath; |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | #endif |