Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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