content/base/src/nsCCUncollectableMarker.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/nsCCUncollectableMarker.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsCCUncollectableMarker_h_
    1.10 +#define nsCCUncollectableMarker_h_
    1.11 +
    1.12 +#include "js/TracingAPI.h"
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "nsIObserver.h"
    1.15 +
    1.16 +class nsCCUncollectableMarker MOZ_FINAL : public nsIObserver
    1.17 +{
    1.18 +  NS_DECL_ISUPPORTS
    1.19 +  NS_DECL_NSIOBSERVER
    1.20 +
    1.21 +  /**
    1.22 +   * Inits a global nsCCUncollectableMarker. Should only be called once.
    1.23 +   */
    1.24 +  static nsresult Init();
    1.25 +
    1.26 +  /**
    1.27 +   * Checks if we're collecting during a given generation
    1.28 +   */
    1.29 +  static bool InGeneration(uint32_t aGeneration)
    1.30 +  {
    1.31 +    return aGeneration && aGeneration == sGeneration;
    1.32 +  }
    1.33 +
    1.34 +  template <class CCCallback>
    1.35 +  static bool InGeneration(CCCallback& aCb, uint32_t aGeneration)
    1.36 +  {
    1.37 +    return InGeneration(aGeneration) && !aCb.WantAllTraces();
    1.38 +  }
    1.39 +
    1.40 +  static uint32_t sGeneration;
    1.41 +
    1.42 +private:
    1.43 +  nsCCUncollectableMarker() {}
    1.44 +
    1.45 +};
    1.46 +
    1.47 +namespace mozilla {
    1.48 +namespace dom {
    1.49 +void TraceBlackJS(JSTracer* aTrc, uint32_t aGCNumber, bool aIsShutdownGC);
    1.50 +}
    1.51 +}
    1.52 +
    1.53 +#endif

mercurial