already_AddRefed<nsIPerformanceStats> nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& performance, const uint64_t uid, nsIPerformanceStats* parent) { if (performance.ticks == 0) { // Ignore compartments with no activity. return nullptr; } JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); if (!global) { // While it is possible for a compartment to have no global // (e.g. atoms), this compartment is not very interesting for us. return nullptr; } nsString groupId; GetGroupId(cx, uid, groupId); nsString addonId; GetAddonId(cx, global, addonId); nsString title; uint64_t windowId; GetWindowData(cx, title, &windowId); nsString name; GetName(cx, global, name); bool isSystem = GetIsSystem(cx, global); nsCOMPtr<nsIPerformanceStats> result = new nsPerformanceStats(name, parent, groupId, addonId, title, windowId, mProcessId, isSystem, performance); return result.forget(); }
already_AddRefed<nsIPerformanceStats> nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& performance, const uint64_t uid) { JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); if (!global) { // While it is possible for a compartment to have no global // (e.g. atoms), this compartment is not very interesting for us. return nullptr; } nsString groupId; GetGroupId(cx, uid, groupId); nsString addonId; GetAddonId(cx, global, addonId); nsString title; uint64_t windowId; GetWindowData(cx, title, &windowId); nsAutoString name; nsAutoCString cname; xpc::GetCurrentCompartmentName(cx, cname); name.Assign(NS_ConvertUTF8toUTF16(cname)); bool isSystem = GetIsSystem(cx, global); nsCOMPtr<nsIPerformanceStats> result = new nsPerformanceStats(name, groupId, addonId, title, windowId, isSystem, performance); return result.forget(); }
bool CLanguageResource::FindLegacyLanguage(const std::string &locale, std::string &legacyLanguage) { if (locale.empty()) return false; std::string addonId = GetAddonId(locale); AddonPtr addon; if (!CServiceBroker::GetAddonMgr().GetAddon(addonId, addon, ADDON_RESOURCE_LANGUAGE, true)) return false; legacyLanguage = addon->Name(); return true; }