LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - WebrtcGlobalInformationBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 306 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM WebrtcGlobalInformation.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "WebrtcGlobalInformation.h"
       5             : #include "WebrtcGlobalInformationBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/ScriptSettings.h"
      13             : #include "mozilla/dom/SimpleGlobalObject.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : #include "nsContentUtils.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : 
      21           0 : WebrtcGlobalStatisticsReport::WebrtcGlobalStatisticsReport()
      22             : {
      23             :   // Safe to pass a null context if we pass a null value
      24           0 :   Init(nullptr, JS::NullHandleValue);
      25           0 : }
      26             : 
      27             : 
      28             : 
      29             : bool
      30           0 : WebrtcGlobalStatisticsReport::InitIds(JSContext* cx, WebrtcGlobalStatisticsReportAtoms* atomsCache)
      31             : {
      32           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      33             : 
      34             :   // Initialize these in reverse order so that any failure leaves the first one
      35             :   // uninitialized.
      36           0 :   if (!atomsCache->reports_id.init(cx, "reports")) {
      37           0 :     return false;
      38             :   }
      39           0 :   return true;
      40             : }
      41             : 
      42             : bool
      43           0 : WebrtcGlobalStatisticsReport::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      44             : {
      45             :   // Passing a null JSContext is OK only if we're initing from null,
      46             :   // Since in that case we will not have to do any property gets
      47             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      48             :   // checkers by static analysis tools
      49           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      50           0 :   WebrtcGlobalStatisticsReportAtoms* atomsCache = nullptr;
      51           0 :   if (cx) {
      52           0 :     atomsCache = GetAtomCache<WebrtcGlobalStatisticsReportAtoms>(cx);
      53           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      54           0 :       return false;
      55             :     }
      56             :   }
      57             : 
      58           0 :   if (!IsConvertibleToDictionary(val)) {
      59           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      60             :   }
      61             : 
      62           0 :   bool isNull = val.isNullOrUndefined();
      63             :   // We only need these if !isNull, in which case we have |cx|.
      64           0 :   Maybe<JS::Rooted<JSObject *> > object;
      65           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      66           0 :   if (!isNull) {
      67           0 :     MOZ_ASSERT(cx);
      68           0 :     object.emplace(cx, &val.toObject());
      69           0 :     temp.emplace(cx);
      70             :   }
      71           0 :   if (!isNull) {
      72           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->reports_id, temp.ptr())) {
      73           0 :       return false;
      74             :     }
      75             :   }
      76           0 :   if (!isNull && !temp->isUndefined()) {
      77           0 :     mReports.Construct();
      78           0 :     if (temp.ref().isObject()) {
      79           0 :       JS::ForOfIterator iter(cx);
      80           0 :       if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
      81           0 :         return false;
      82             :       }
      83           0 :       if (!iter.valueIsIterable()) {
      84           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'reports' member of WebrtcGlobalStatisticsReport");
      85           0 :         return false;
      86             :       }
      87           0 :       Sequence<RTCStatsReportInternal> &arr = (mReports.Value());
      88           0 :       JS::Rooted<JS::Value> temp(cx);
      89             :       while (true) {
      90             :         bool done;
      91           0 :         if (!iter.next(&temp, &done)) {
      92           0 :           return false;
      93             :         }
      94           0 :         if (done) {
      95           0 :           break;
      96             :         }
      97           0 :         RTCStatsReportInternal* slotPtr = arr.AppendElement(mozilla::fallible);
      98           0 :         if (!slotPtr) {
      99           0 :           JS_ReportOutOfMemory(cx);
     100           0 :           return false;
     101             :         }
     102           0 :         RTCStatsReportInternal& slot = *slotPtr;
     103           0 :         if (!slot.Init(cx, temp,  "Element of 'reports' member of WebrtcGlobalStatisticsReport", passedToJSImpl)) {
     104           0 :           return false;
     105             :         }
     106           0 :       }
     107             :     } else {
     108           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'reports' member of WebrtcGlobalStatisticsReport");
     109           0 :       return false;
     110             :     }
     111           0 :     mIsAnyMemberPresent = true;
     112             :   }
     113           0 :   return true;
     114             : }
     115             : 
     116             : bool
     117           0 : WebrtcGlobalStatisticsReport::Init(const nsAString& aJSON)
     118             : {
     119           0 :   AutoJSAPI jsapi;
     120           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     121           0 :   if (!cleanGlobal) {
     122           0 :     return false;
     123             :   }
     124           0 :   if (!jsapi.Init(cleanGlobal)) {
     125           0 :     return false;
     126             :   }
     127           0 :   JSContext* cx = jsapi.cx();
     128           0 :   JS::Rooted<JS::Value> json(cx);
     129           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     130           0 :   NS_ENSURE_TRUE(ok, false);
     131           0 :   return Init(cx, json);
     132             : }
     133             : 
     134             : bool
     135           0 : WebrtcGlobalStatisticsReport::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     136             : {
     137           0 :   WebrtcGlobalStatisticsReportAtoms* atomsCache = GetAtomCache<WebrtcGlobalStatisticsReportAtoms>(cx);
     138           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     139           0 :     return false;
     140             :   }
     141             : 
     142           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     143           0 :   if (!obj) {
     144           0 :     return false;
     145             :   }
     146           0 :   rval.set(JS::ObjectValue(*obj));
     147             : 
     148           0 :   if (mReports.WasPassed()) {
     149             :     do {
     150             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     151           0 :       JS::Rooted<JS::Value> temp(cx);
     152           0 :       Sequence<RTCStatsReportInternal> const & currentValue = mReports.InternalValue();
     153             : 
     154           0 :       uint32_t length = currentValue.Length();
     155           0 :       JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     156           0 :       if (!returnArray) {
     157           0 :         return false;
     158             :       }
     159             :       // Scope for 'tmp'
     160             :       {
     161           0 :         JS::Rooted<JS::Value> tmp(cx);
     162           0 :         for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     163             :           // Control block to let us common up the JS_DefineElement calls when there
     164             :           // are different ways to succeed at wrapping the object.
     165             :           do {
     166           0 :             if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
     167           0 :               return false;
     168             :             }
     169           0 :             break;
     170             :           } while (0);
     171           0 :           if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     172             :                                 JSPROP_ENUMERATE)) {
     173           0 :             return false;
     174             :           }
     175             :         }
     176             :       }
     177           0 :       temp.setObject(*returnArray);
     178           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->reports_id, temp, JSPROP_ENUMERATE)) {
     179           0 :         return false;
     180             :       }
     181           0 :       break;
     182             :     } while(0);
     183             :   }
     184             : 
     185           0 :   return true;
     186             : }
     187             : 
     188             : bool
     189           0 : WebrtcGlobalStatisticsReport::ToJSON(nsAString& aJSON) const
     190             : {
     191           0 :   AutoJSAPI jsapi;
     192           0 :   jsapi.Init();
     193           0 :   JSContext *cx = jsapi.cx();
     194             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     195             :   // because we'll only be creating objects, in ways that have no
     196             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     197             :   // which likewise guarantees no side-effects for the sorts of
     198             :   // things we will pass it.
     199           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     200           0 :   JS::Rooted<JS::Value> val(cx);
     201           0 :   if (!ToObjectInternal(cx, &val)) {
     202           0 :     return false;
     203             :   }
     204           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     205           0 :   return StringifyToJSON(cx, obj, aJSON);
     206             : }
     207             : 
     208             : void
     209           0 : WebrtcGlobalStatisticsReport::TraceDictionary(JSTracer* trc)
     210             : {
     211           0 : }
     212             : 
     213             : WebrtcGlobalStatisticsReport&
     214           0 : WebrtcGlobalStatisticsReport::operator=(const WebrtcGlobalStatisticsReport& aOther)
     215             : {
     216           0 :   mReports.Reset();
     217           0 :   if (aOther.mReports.WasPassed()) {
     218           0 :     mReports.Construct(aOther.mReports.Value());
     219             :   }
     220           0 :   return *this;
     221             : }
     222             : 
     223             : namespace binding_detail {
     224             : } // namespace binding_detail
     225             : 
     226             : 
     227             : void
     228           0 : WebrtcGlobalStatisticsCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const WebrtcGlobalStatisticsReport& reports, ErrorResult& aRv)
     229             : {
     230           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     231           0 :   JS::AutoValueVector argv(cx);
     232           0 :   if (!argv.resize(1)) {
     233           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     234           0 :     return;
     235             :   }
     236           0 :   unsigned argc = 1;
     237             : 
     238             :   do {
     239           0 :     if (!reports.ToObjectInternal(cx, argv[0])) {
     240           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     241           0 :       return;
     242             :     }
     243           0 :     break;
     244             :   } while (0);
     245             : 
     246           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     247           0 :   if (!JS::Call(cx, aThisVal, callable,
     248           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     249           0 :     aRv.NoteJSContextException(cx);
     250           0 :     return;
     251             :   }
     252             : }
     253             : 
     254             : 
     255             : 
     256             : void
     257           0 : WebrtcGlobalLoggingCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const Sequence<nsString>& logMessages, ErrorResult& aRv)
     258             : {
     259           0 :   JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
     260           0 :   JS::AutoValueVector argv(cx);
     261           0 :   if (!argv.resize(1)) {
     262           0 :     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     263           0 :     return;
     264             :   }
     265           0 :   unsigned argc = 1;
     266             : 
     267             :   do {
     268             : 
     269           0 :     uint32_t length = logMessages.Length();
     270           0 :     JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     271           0 :     if (!returnArray) {
     272           0 :       aRv.Throw(NS_ERROR_UNEXPECTED);
     273           0 :       return;
     274             :     }
     275             :     // Scope for 'tmp'
     276             :     {
     277           0 :       JS::Rooted<JS::Value> tmp(cx);
     278           0 :       for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     279             :         // Control block to let us common up the JS_DefineElement calls when there
     280             :         // are different ways to succeed at wrapping the object.
     281             :         do {
     282           0 :           if (!xpc::NonVoidStringToJsval(cx, logMessages[sequenceIdx0], &tmp)) {
     283           0 :             aRv.Throw(NS_ERROR_UNEXPECTED);
     284           0 :             return;
     285             :           }
     286           0 :           break;
     287             :         } while (0);
     288           0 :         if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     289             :                               JSPROP_ENUMERATE)) {
     290           0 :           aRv.Throw(NS_ERROR_UNEXPECTED);
     291           0 :           return;
     292             :         }
     293             :       }
     294             :     }
     295           0 :     argv[0].setObject(*returnArray);
     296           0 :     break;
     297             :   } while (0);
     298             : 
     299           0 :   JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
     300           0 :   if (!JS::Call(cx, aThisVal, callable,
     301           0 :                 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
     302           0 :     aRv.NoteJSContextException(cx);
     303           0 :     return;
     304             :   }
     305             : }
     306             : 
     307             : 
     308             : 
     309             : namespace binding_detail {
     310             : } // namespace binding_detail
     311             : 
     312             : 
     313             : namespace binding_detail {
     314             : } // namespace binding_detail
     315             : 
     316             : 
     317             : namespace WebrtcGlobalInformationBinding {
     318             : 
     319             : static bool
     320           0 : getAllStats(JSContext* cx, unsigned argc, JS::Value* vp)
     321             : {
     322           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     323           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     324             : 
     325           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     326           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebrtcGlobalInformation.getAllStats");
     327             :   }
     328           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     329           0 :   if (global.Failed()) {
     330           0 :     return false;
     331             :   }
     332             : 
     333           0 :   RootedCallback<OwningNonNull<binding_detail::FastWebrtcGlobalStatisticsCallback>> arg0(cx);
     334           0 :   if (args[0].isObject()) {
     335           0 :     if (JS::IsCallable(&args[0].toObject())) {
     336             :     { // scope for tempRoot
     337           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     338           0 :       arg0 = new binding_detail::FastWebrtcGlobalStatisticsCallback(tempRoot);
     339             :     }
     340             :     } else {
     341           0 :       ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of WebrtcGlobalInformation.getAllStats");
     342           0 :       return false;
     343             :     }
     344             :   } else {
     345           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of WebrtcGlobalInformation.getAllStats");
     346           0 :     return false;
     347             :   }
     348           0 :   Optional<nsAString> arg1;
     349           0 :   binding_detail::FakeString arg1_holder;
     350           0 :   if (args.hasDefined(1)) {
     351           0 :     if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1_holder)) {
     352           0 :       return false;
     353             :     }
     354           0 :     arg1 = &arg1_holder;
     355             :   }
     356           0 :   binding_detail::FastErrorResult rv;
     357           0 :   mozilla::dom::WebrtcGlobalInformation::GetAllStats(global, NonNullHelper(arg0), NonNullHelper(Constify(arg1)), rv);
     358           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     359           0 :     return false;
     360             :   }
     361           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     362           0 :   args.rval().setUndefined();
     363           0 :   return true;
     364             : }
     365             : 
     366             : static bool
     367           0 : clearAllStats(JSContext* cx, unsigned argc, JS::Value* vp)
     368             : {
     369           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     370           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     371             : 
     372           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     373           0 :   if (global.Failed()) {
     374           0 :     return false;
     375             :   }
     376             : 
     377           0 :   mozilla::dom::WebrtcGlobalInformation::ClearAllStats(global);
     378           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     379           0 :   args.rval().setUndefined();
     380           0 :   return true;
     381             : }
     382             : 
     383             : static bool
     384           0 : getLogging(JSContext* cx, unsigned argc, JS::Value* vp)
     385             : {
     386           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     387           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     388             : 
     389           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     390           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "WebrtcGlobalInformation.getLogging");
     391             :   }
     392           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     393           0 :   if (global.Failed()) {
     394           0 :     return false;
     395             :   }
     396             : 
     397           0 :   binding_detail::FakeString arg0;
     398           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     399           0 :     return false;
     400             :   }
     401           0 :   RootedCallback<OwningNonNull<binding_detail::FastWebrtcGlobalLoggingCallback>> arg1(cx);
     402           0 :   if (args[1].isObject()) {
     403           0 :     if (JS::IsCallable(&args[1].toObject())) {
     404             :     { // scope for tempRoot
     405           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[1].toObject());
     406           0 :       arg1 = new binding_detail::FastWebrtcGlobalLoggingCallback(tempRoot);
     407             :     }
     408             :     } else {
     409           0 :       ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of WebrtcGlobalInformation.getLogging");
     410           0 :       return false;
     411             :     }
     412             :   } else {
     413           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of WebrtcGlobalInformation.getLogging");
     414           0 :     return false;
     415             :   }
     416           0 :   binding_detail::FastErrorResult rv;
     417           0 :   mozilla::dom::WebrtcGlobalInformation::GetLogging(global, NonNullHelper(Constify(arg0)), NonNullHelper(arg1), rv);
     418           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     419           0 :     return false;
     420             :   }
     421           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     422           0 :   args.rval().setUndefined();
     423           0 :   return true;
     424             : }
     425             : 
     426             : static bool
     427           0 : clearLogging(JSContext* cx, unsigned argc, JS::Value* vp)
     428             : {
     429           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     430           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     431             : 
     432           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     433           0 :   if (global.Failed()) {
     434           0 :     return false;
     435             :   }
     436             : 
     437           0 :   mozilla::dom::WebrtcGlobalInformation::ClearLogging(global);
     438           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     439           0 :   args.rval().setUndefined();
     440           0 :   return true;
     441             : }
     442             : 
     443             : static bool
     444           0 : get_debugLevel(JSContext* cx, unsigned argc, JS::Value* vp)
     445             : {
     446           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     447           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     448             : 
     449           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     450           0 :   if (global.Failed()) {
     451           0 :     return false;
     452             :   }
     453             : 
     454           0 :   int32_t result(mozilla::dom::WebrtcGlobalInformation::DebugLevel(global));
     455           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     456           0 :   args.rval().setInt32(int32_t(result));
     457           0 :   return true;
     458             : }
     459             : 
     460             : static bool
     461           0 : set_debugLevel(JSContext* cx, unsigned argc, JS::Value* vp)
     462             : {
     463           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     464           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     465             : 
     466           0 :   if (args.length() == 0) {
     467           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "debugLevel setter");
     468             :   }
     469           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     470           0 :   if (global.Failed()) {
     471           0 :     return false;
     472             :   }
     473             : 
     474             :   int32_t arg0;
     475           0 :   if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0)) {
     476           0 :     return false;
     477             :   }
     478           0 :   mozilla::dom::WebrtcGlobalInformation::SetDebugLevel(global, arg0);
     479           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     480             : 
     481           0 :   return true;
     482             : }
     483             : 
     484             : static bool
     485           0 : get_aecDebug(JSContext* cx, unsigned argc, JS::Value* vp)
     486             : {
     487           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     488           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     489             : 
     490           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     491           0 :   if (global.Failed()) {
     492           0 :     return false;
     493             :   }
     494             : 
     495           0 :   bool result(mozilla::dom::WebrtcGlobalInformation::AecDebug(global));
     496           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     497           0 :   args.rval().setBoolean(result);
     498           0 :   return true;
     499             : }
     500             : 
     501             : static bool
     502           0 : set_aecDebug(JSContext* cx, unsigned argc, JS::Value* vp)
     503             : {
     504           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     505           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     506             : 
     507           0 :   if (args.length() == 0) {
     508           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "aecDebug setter");
     509             :   }
     510           0 :   GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
     511           0 :   if (global.Failed()) {
     512           0 :     return false;
     513             :   }
     514             : 
     515             :   bool arg0;
     516           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     517           0 :     return false;
     518             :   }
     519           0 :   mozilla::dom::WebrtcGlobalInformation::SetAecDebug(global, arg0);
     520           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     521             : 
     522           0 :   return true;
     523             : }
     524             : 
     525             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     526             : #if defined(__clang__)
     527             : #pragma clang diagnostic push
     528             : #pragma clang diagnostic ignored "-Wmissing-braces"
     529             : #endif
     530             : static const JSFunctionSpec sStaticMethods_specs[] = {
     531             :   JS_FNSPEC("getAllStats", getAllStats, nullptr, 1, JSPROP_ENUMERATE, nullptr),
     532             :   JS_FNSPEC("clearAllStats", clearAllStats, nullptr, 0, JSPROP_ENUMERATE, nullptr),
     533             :   JS_FNSPEC("getLogging", getLogging, nullptr, 2, JSPROP_ENUMERATE, nullptr),
     534             :   JS_FNSPEC("clearLogging", clearLogging, nullptr, 0, JSPROP_ENUMERATE, nullptr),
     535             :   JS_FS_END
     536             : };
     537             : #if defined(__clang__)
     538             : #pragma clang diagnostic pop
     539             : #endif
     540             : 
     541             : 
     542             : // Can't be const because the pref-enabled boolean needs to be writable
     543             : static Prefable<const JSFunctionSpec> sStaticMethods[] = {
     544             :   { nullptr, &sStaticMethods_specs[0] },
     545             :   { nullptr, nullptr }
     546             : };
     547             : 
     548             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     549             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     550             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     551             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     552             : 
     553             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     554             : #if defined(__clang__)
     555             : #pragma clang diagnostic push
     556             : #pragma clang diagnostic ignored "-Wmissing-braces"
     557             : #endif
     558             : static const JSPropertySpec sStaticAttributes_specs[] = {
     559             :   { "debugLevel", JSPROP_SHARED | JSPROP_ENUMERATE, get_debugLevel, nullptr, set_debugLevel, nullptr },
     560             :   { "aecDebug", JSPROP_SHARED | JSPROP_ENUMERATE, get_aecDebug, nullptr, set_aecDebug, nullptr },
     561             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     562             : };
     563             : #if defined(__clang__)
     564             : #pragma clang diagnostic pop
     565             : #endif
     566             : 
     567             : 
     568             : // Can't be const because the pref-enabled boolean needs to be writable
     569             : static Prefable<const JSPropertySpec> sStaticAttributes[] = {
     570             :   { nullptr, &sStaticAttributes_specs[0] },
     571             :   { nullptr, nullptr }
     572             : };
     573             : 
     574             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     575             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     576             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     577             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     578             : 
     579             : 
     580             : static uint16_t sNativeProperties_sortedPropertyIndices[6];
     581             : static PropertyInfo sNativeProperties_propertyInfos[6];
     582             : 
     583             : static const NativePropertiesN<2> sNativeProperties = {
     584             :   true,  0 /* sStaticMethods */,
     585             :   true,  1 /* sStaticAttributes */,
     586             :   false, 0,
     587             :   false, 0,
     588             :   false, 0,
     589             :   false, 0,
     590             :   false, 0,
     591             :   -1,
     592             :   6,
     593             :   sNativeProperties_sortedPropertyIndices,
     594             :   {
     595             :     { sStaticMethods, &sNativeProperties_propertyInfos[0] },
     596             :     { sStaticAttributes, &sNativeProperties_propertyInfos[4] }
     597             :   }
     598             : };
     599             : static_assert(6 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     600             :     "We have a property info count that is oversized");
     601             : 
     602             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     603             :   {
     604             :     "Function",
     605             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     606             :     &sBoringInterfaceObjectClassClassOps,
     607             :     JS_NULL_CLASS_SPEC,
     608             :     JS_NULL_CLASS_EXT,
     609             :     &sInterfaceObjectClassObjectOps
     610             :   },
     611             :   eInterface,
     612             :   false,
     613             :   prototypes::id::_ID_Count,
     614             :   0,
     615             :   sNativePropertyHooks,
     616             :   "function WebrtcGlobalInformation() {\n    [native code]\n}",
     617             :   JS::GetRealmFunctionPrototype
     618             : };
     619             : 
     620             : bool
     621           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     622             : {
     623           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
     624             : }
     625             : 
     626             : JSObject*
     627           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     628             : {
     629           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     630             : }
     631             : 
     632             : const NativePropertyHooks sNativePropertyHooks[] = { {
     633             :   nullptr,
     634             :   nullptr,
     635             :   nullptr,
     636             :   { sNativeProperties.Upcast(), nullptr },
     637             :   prototypes::id::_ID_Count,
     638             :   constructors::id::WebrtcGlobalInformation,
     639             :   nullptr,
     640             :   &DefaultXrayExpandoObjectClass
     641             : } };
     642             : 
     643             : void
     644           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     645             : {
     646           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     647           0 :   if (!constructorProto) {
     648           0 :     return;
     649             :   }
     650             : 
     651             :   static bool sIdsInited = false;
     652           0 :   if (!sIdsInited && NS_IsMainThread()) {
     653           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     654           0 :       return;
     655             :     }
     656           0 :     sIdsInited = true;
     657             :   }
     658             : 
     659           0 :   JS::Heap<JSObject*>* protoCache = nullptr;
     660           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WebrtcGlobalInformation);
     661           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, nullptr,
     662             :                               nullptr, protoCache,
     663             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     664             :                               interfaceCache,
     665             :                               sNativeProperties.Upcast(),
     666             :                               nullptr,
     667             :                               "WebrtcGlobalInformation", aDefineOnGlobal,
     668             :                               nullptr,
     669           0 :                               false);
     670             : }
     671             : 
     672             : JS::Handle<JSObject*>
     673           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     674             : {
     675             :   /* Get the interface object for this class.  This will create the object as
     676             :      needed. */
     677             : 
     678             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     679           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     680           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     681           0 :     return nullptr;
     682             :   }
     683             : 
     684             :   /* Check to see whether the interface objects are already installed */
     685           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     686           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::WebrtcGlobalInformation)) {
     687           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     688           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     689             :   }
     690             : 
     691             :   /*
     692             :    * The object might _still_ be null, but that's OK.
     693             :    *
     694             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     695             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     696             :    * changed after they have been set.
     697             :    *
     698             :    * Calling address() avoids the read read barrier that does gray
     699             :    * unmarking, but it's not possible for the object to be gray here.
     700             :    */
     701             : 
     702           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::WebrtcGlobalInformation);
     703           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     704           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     705             : }
     706             : 
     707             : JSObject*
     708           0 : GetConstructorObject(JSContext* aCx)
     709             : {
     710           0 :   return GetConstructorObjectHandle(aCx);
     711             : }
     712             : 
     713             : } // namespace WebrtcGlobalInformationBinding
     714             : 
     715             : 
     716             : 
     717             : } // namespace dom
     718             : } // namespace mozilla

Generated by: LCOV version 1.13