LCOV - app.info - toolkit/components/url-classifier/ChunkSet.h

LCOV - code coverage report
| Current view: | directory - toolkit/components/url-classifier - ChunkSet.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 7 | 7 | 100.0 %
| Date: | 2012-04-21 | Functions: | 5 | 5 | 100.0 %

           1                 : //* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is Url Classifier code
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * the Mozilla Foundation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *   Dave Camp <dcamp@mozilla.com>
          24                 :  *   Gian-Carlo Pascutto <gpascutto@mozilla.com>
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : #ifndef ChunkSet_h__
          41                 : #define ChunkSet_h__
          42                 :
          43                 :
          44                 : #include "Entries.h"
          45                 : #include "nsString.h"
          46                 : #include "nsTArray.h"
          47                 :
          48                 : namespace mozilla {
          49                 : namespace safebrowsing {
          50                 :
          51                 : /**
          52                 :  * Store the chunks as an array of uint32.
          53                 :  * XXX: We should optimize this further to compress the
          54                 :  * many consecutive numbers.
          55                 :  */
          56                 : class ChunkSet {
          57                 : public:
          58            1605 :   ChunkSet() {}
          59            1601 :   ~ChunkSet() {}
          60                 :
          61                 :   nsresult Serialize(nsACString& aStr);
          62                 :   nsresult Set(PRUint32 aChunk);
          63                 :   nsresult Unset(PRUint32 aChunk);
          64                 :   void Clear();
          65                 :   nsresult Merge(const ChunkSet& aOther);
          66                 :   nsresult Remove(const ChunkSet& aOther);
          67                 :
          68                 :   bool Has(PRUint32 chunk) const;
          69                 :
          70            1254 :   uint32 Length() const { return mChunks.Length(); }
          71                 :
          72             194 :   nsresult Write(nsIOutputStream* aOut) {
          73             194 :     return WriteTArray(aOut, mChunks);
          74                 :   }
          75                 :
          76             502 :   nsresult Read(nsIInputStream* aIn, PRUint32 aNumElements) {
          77             502 :     return ReadTArray(aIn, &mChunks, aNumElements);
          78                 :   }
          79                 :
          80                 :   uint32 *Begin() { return mChunks.Elements(); }
          81                 :   uint32 *End() { return mChunks.Elements() + mChunks.Length(); }
          82                 :
          83                 : private:
          84                 :   nsTArray<uint32> mChunks;
          85                 : };
          86                 :
          87                 : }
          88                 : }
          89                 :
          90                 : #endif

Generated by: LCOV version 1.7