2014-11-19 15:54:34 -08:00
|
|
|
/* -*- 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"
|
|
|
|
|
2014-11-25 10:04:07 -08:00
|
|
|
CPOWTimer::~CPOWTimer()
|
|
|
|
{
|
2014-11-19 15:54:34 -08:00
|
|
|
/* This is a best effort to find the compartment responsible for this CPOW call */
|
2014-11-25 10:04:07 -08:00
|
|
|
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;
|
2014-11-19 15:54:34 -08:00
|
|
|
PRIntervalTime time = PR_IntervalNow() - startInterval;
|
2014-11-25 10:04:07 -08:00
|
|
|
compartmentPrivate->CPOWTime += time;
|
2014-11-19 15:54:34 -08:00
|
|
|
}
|