netwerk/protocol/http/SpdyZlibReporter.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set sw=2 ts=8 et tw=80 : */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /* A memory allocator for zlib use in SPDY that reports to about:memory. */
     9 #include "mozilla/Assertions.h"
    10 #include "mozilla/Atomics.h"
    11 #include "mozilla/Attributes.h"
    12 #include "nsIMemoryReporter.h"
    13 #include "zlib.h"
    15 namespace mozilla {
    17 class SpdyZlibReporter MOZ_FINAL : public nsIMemoryReporter
    18 {
    19 public:
    20   NS_DECL_ISUPPORTS
    22   SpdyZlibReporter()
    23   {
    24 #ifdef DEBUG
    25     // There must be only one instance of this class, due to |sAmount|
    26     // being static.
    27     static bool hasRun = false;
    28     MOZ_ASSERT(!hasRun);
    29     hasRun = true;
    30 #endif
    31     sAmount = 0;
    32   }
    34   static void* Alloc(void*, uInt items, uInt size);
    35   static void Free(void*, void* p);
    37 private:
    38   // |sAmount| can be (implicitly) accessed by multiple threads, so it
    39   // must be thread-safe.
    40   static Atomic<size_t> sAmount;
    42   MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
    43   MOZ_DEFINE_MALLOC_SIZE_OF_ON_ALLOC(MallocSizeOfOnAlloc)
    44   MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(MallocSizeOfOnFree)
    46   NS_IMETHODIMP
    47   CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData);
    48 };
    50 } // namespace mozilla

mercurial