Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/worklet/WorkletPrincipal.cpp
Line
Count
Source (jump to first uncovered line)
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 "WorkletPrincipal.h"
8
#include "jsapi.h"
9
#include "mozilla/Assertions.h"
10
11
namespace mozilla {
12
namespace dom {
13
namespace WorkletPrincipal {
14
15
struct WorkletPrincipal final : public JSPrincipals
16
{
17
  bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override
18
0
  {
19
0
    MOZ_CRASH("WorkletPrincipal::write not implemented");
20
0
    return false;
21
0
  }
22
};
23
24
JSPrincipals*
25
GetWorkletPrincipal()
26
0
{
27
0
  static WorkletPrincipal sPrincipal;
28
0
29
0
  /*
30
0
   * To make sure the the principals refcount is initialized to one, atomically
31
0
   * increment it on every pass though this function. If we discover this wasn't
32
0
   * the first time, decrement it again. This avoids the need for
33
0
   * synchronization.
34
0
   */
35
0
  int32_t prevRefcount = sPrincipal.refcount++;
36
0
  if (prevRefcount > 0) {
37
0
    --sPrincipal.refcount;
38
0
  } else {
39
#ifdef DEBUG
40
    sPrincipal.debugToken = kJSPrincipalsDebugToken;
41
#endif
42
  }
43
0
44
0
  return &sPrincipal;
45
0
}
46
47
} // namespace WorkletPrincipal
48
} // namespace dom
49
} // namespace mozilla