toolkit/components/url-classifier/ChunkSet.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     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/. */
     6 #ifndef ChunkSet_h__
     7 #define ChunkSet_h__
    10 #include "Entries.h"
    11 #include "nsString.h"
    12 #include "nsTArray.h"
    14 namespace mozilla {
    15 namespace safebrowsing {
    17 /**
    18  * Store the chunk numbers as an array of uint32_t. We need chunk numbers in
    19  * order to ask for incremental updates from the server.
    20  * XXX: We should optimize this further to compress the many consecutive
    21  * numbers.
    22  */
    23 class ChunkSet {
    24 public:
    25   ChunkSet() {}
    26   ~ChunkSet() {}
    28   nsresult Serialize(nsACString& aStr);
    29   nsresult Set(uint32_t aChunk);
    30   nsresult Unset(uint32_t aChunk);
    31   void Clear();
    32   nsresult Merge(const ChunkSet& aOther);
    33   nsresult Remove(const ChunkSet& aOther);
    35   bool Has(uint32_t chunk) const;
    37   uint32_t Length() const { return mChunks.Length(); }
    39   nsresult Write(nsIOutputStream* aOut) {
    40     return WriteTArray(aOut, mChunks);
    41   }
    43   nsresult Read(nsIInputStream* aIn, uint32_t aNumElements) {
    44     return ReadTArray(aIn, &mChunks, aNumElements);
    45   }
    47   uint32_t *Begin() { return mChunks.Elements(); }
    48   uint32_t *End() { return mChunks.Elements() + mChunks.Length(); }
    50 private:
    51   nsTArray<uint32_t> mChunks;
    52 };
    54 }
    55 }
    57 #endif

mercurial