Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/systemservices/MediaSystemResourceClient.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
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 file,
5
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/Monitor.h"
8
#include "mozilla/ReentrantMonitor.h"
9
10
#include "MediaSystemResourceClient.h"
11
12
namespace mozilla {
13
14
Atomic<uint32_t> MediaSystemResourceClient::sSerialCounter(0);
15
16
MediaSystemResourceClient::MediaSystemResourceClient(MediaSystemResourceType aReourceType)
17
  : mResourceType(aReourceType)
18
  , mId(++sSerialCounter)
19
  , mListener(nullptr)
20
  , mResourceState(RESOURCE_STATE_START)
21
  , mIsSync(false)
22
  , mAcquireSyncWaitMonitor(nullptr)
23
  , mAcquireSyncWaitDone(nullptr)
24
0
{
25
0
  mManager = MediaSystemResourceManager::Get();
26
0
  if (mManager) {
27
0
    mManager->Register(this);
28
0
  }
29
0
}
30
31
MediaSystemResourceClient::~MediaSystemResourceClient()
32
0
{
33
0
  ReleaseResource();
34
0
  if (mManager) {
35
0
    mManager->Unregister(this);
36
0
  }
37
0
}
38
39
bool
40
MediaSystemResourceClient::SetListener(MediaSystemResourceReservationListener* aListener)
41
0
{
42
0
  if (!mManager) {
43
0
    return false;
44
0
  }
45
0
  return mManager->SetListener(this, aListener);
46
0
}
47
48
void
49
MediaSystemResourceClient::Acquire()
50
0
{
51
0
  if (!mManager) {
52
0
    return;
53
0
  }
54
0
  mManager->Acquire(this);
55
0
}
56
57
bool
58
MediaSystemResourceClient::AcquireSyncNoWait()
59
0
{
60
0
  if (!mManager) {
61
0
    return false;
62
0
  }
63
0
  return mManager->AcquireSyncNoWait(this);
64
0
}
65
66
void
67
MediaSystemResourceClient::ReleaseResource()
68
0
{
69
0
  if (!mManager) {
70
0
    return;
71
0
  }
72
0
  mManager->ReleaseResource(this);
73
0
}
74
75
} // namespace mozilla