js/ipc/CPOWTimer.cpp
author Wes Kocher <wkocher@mozilla.com>
Thu, 26 Feb 2015 17:55:37 -0800
changeset 231050 00ccf3b425fdd5b5a79f9af887712bdfd3494500
parent 231028 d7d9bbfa72c5b58e01aff2ba7fc524e6203889e5
child 236295 0c030f97a04f4e34c138b878c4352423f5e920f9
permissions -rw-r--r--
Backed out changeset d7d9bbfa72c5 (bug 674779) for m-bc orange on a CLOSED TREE

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=4 sw=4 et tw=80:
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "jsfriendapi.h"
#include "xpcprivate.h"
#include "CPOWTimer.h"

CPOWTimer::~CPOWTimer()
{
    /* This is a best effort to find the compartment responsible for this CPOW call */
    nsIGlobalObject *global = mozilla::dom::GetIncumbentGlobal();
    if (!global)
        return;
    JSObject *obj = global->GetGlobalJSObject();
    if (!obj)
        return;
    JSCompartment *compartment = js::GetObjectCompartment(obj);
    xpc::CompartmentPrivate *compartmentPrivate = xpc::CompartmentPrivate::Get(compartment);
    if (!compartmentPrivate)
        return;
    PRIntervalTime time = PR_IntervalNow() - startInterval;
    compartmentPrivate->CPOWTime += time;
}