netwerk/protocol/http/SpdyZlibReporter.cpp

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:46314d70e773
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/. */
6
7 #include "SpdyZlibReporter.h"
8
9 namespace mozilla {
10
11 NS_IMPL_ISUPPORTS(SpdyZlibReporter, nsIMemoryReporter)
12
13 /* static */ Atomic<size_t> SpdyZlibReporter::sAmount;
14
15 /* static */ void*
16 SpdyZlibReporter::Alloc(void*, uInt items, uInt size)
17 {
18 void* p = moz_xmalloc(items * size);
19 sAmount += MallocSizeOfOnAlloc(p);
20 return p;
21 }
22
23 /* static */ void
24 SpdyZlibReporter::Free(void*, void* p)
25 {
26 sAmount -= MallocSizeOfOnFree(p);
27 moz_free(p);
28 }
29
30 NS_IMETHODIMP
31 SpdyZlibReporter::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
32 {
33 return MOZ_COLLECT_REPORT(
34 "explicit/network/spdy-zlib-buffers", KIND_HEAP, UNITS_BYTES, sAmount,
35 "Memory allocated for SPDY zlib send and receive buffers.");
36 }
37
38 } // namespace mozilla

mercurial