Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 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 "nsCycleCollectionParticipant.h"
8 : #include "nsCOMPtr.h"
9 :
10 : NS_IMETHODIMP_(void)
11 0 : nsXPCOMCycleCollectionParticipant::Root(void* aPtr)
12 : {
13 0 : nsISupports* s = static_cast<nsISupports*>(aPtr);
14 0 : NS_ADDREF(s);
15 0 : }
16 :
17 : NS_IMETHODIMP_(void)
18 0 : nsXPCOMCycleCollectionParticipant::Unroot(void* aPtr)
19 : {
20 0 : nsISupports* s = static_cast<nsISupports*>(aPtr);
21 0 : NS_RELEASE(s);
22 0 : }
23 :
24 : // We define a default trace function because some participants don't need
25 : // to trace anything, so it is okay for them not to define one.
26 : NS_IMETHODIMP_(void)
27 1042 : nsXPCOMCycleCollectionParticipant::Trace(void* aPtr, const TraceCallbacks& aCb,
28 : void* aClosure)
29 : {
30 1042 : }
31 :
32 : bool
33 16543 : nsXPCOMCycleCollectionParticipant::CheckForRightISupports(nsISupports* aSupports)
34 : {
35 : nsISupports* foo;
36 : aSupports->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
37 16543 : reinterpret_cast<void**>(&foo));
38 16543 : return aSupports == foo;
39 : }
|