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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef ChunkSet_h__ |
michael@0 | 7 | #define ChunkSet_h__ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "Entries.h" |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | #include "nsTArray.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace safebrowsing { |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * Store the chunk numbers as an array of uint32_t. We need chunk numbers in |
michael@0 | 19 | * order to ask for incremental updates from the server. |
michael@0 | 20 | * XXX: We should optimize this further to compress the many consecutive |
michael@0 | 21 | * numbers. |
michael@0 | 22 | */ |
michael@0 | 23 | class ChunkSet { |
michael@0 | 24 | public: |
michael@0 | 25 | ChunkSet() {} |
michael@0 | 26 | ~ChunkSet() {} |
michael@0 | 27 | |
michael@0 | 28 | nsresult Serialize(nsACString& aStr); |
michael@0 | 29 | nsresult Set(uint32_t aChunk); |
michael@0 | 30 | nsresult Unset(uint32_t aChunk); |
michael@0 | 31 | void Clear(); |
michael@0 | 32 | nsresult Merge(const ChunkSet& aOther); |
michael@0 | 33 | nsresult Remove(const ChunkSet& aOther); |
michael@0 | 34 | |
michael@0 | 35 | bool Has(uint32_t chunk) const; |
michael@0 | 36 | |
michael@0 | 37 | uint32_t Length() const { return mChunks.Length(); } |
michael@0 | 38 | |
michael@0 | 39 | nsresult Write(nsIOutputStream* aOut) { |
michael@0 | 40 | return WriteTArray(aOut, mChunks); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | nsresult Read(nsIInputStream* aIn, uint32_t aNumElements) { |
michael@0 | 44 | return ReadTArray(aIn, &mChunks, aNumElements); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | uint32_t *Begin() { return mChunks.Elements(); } |
michael@0 | 48 | uint32_t *End() { return mChunks.Elements() + mChunks.Length(); } |
michael@0 | 49 | |
michael@0 | 50 | private: |
michael@0 | 51 | nsTArray<uint32_t> mChunks; |
michael@0 | 52 | }; |
michael@0 | 53 | |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | #endif |