/src/mozilla-central/dom/media/systemservices/MediaSystemResourceManagerParent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #include "mozilla/Unused.h" |
7 | | #include "mozilla/layers/PImageBridgeParent.h" |
8 | | |
9 | | #include "MediaSystemResourceManagerParent.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace media { |
13 | | |
14 | | using namespace ipc; |
15 | | |
16 | | MediaSystemResourceManagerParent::MediaSystemResourceManagerParent() |
17 | | : mDestroyed(false) |
18 | 0 | { |
19 | 0 | mMediaSystemResourceService = MediaSystemResourceService::Get(); |
20 | 0 | } |
21 | | |
22 | | MediaSystemResourceManagerParent::~MediaSystemResourceManagerParent() |
23 | 0 | { |
24 | 0 | MOZ_ASSERT(mDestroyed); |
25 | 0 | } |
26 | | |
27 | | mozilla::ipc::IPCResult |
28 | | MediaSystemResourceManagerParent::RecvAcquire(const uint32_t& aId, |
29 | | const MediaSystemResourceType& aResourceType, |
30 | | const bool& aWillWait) |
31 | 0 | { |
32 | 0 | MediaSystemResourceRequest* request = mResourceRequests.Get(aId); |
33 | 0 | MOZ_ASSERT(!request); |
34 | 0 | if (request) { |
35 | 0 | // Send fail response |
36 | 0 | mozilla::Unused << SendResponse(aId, false /* fail */); |
37 | 0 | return IPC_OK(); |
38 | 0 | } |
39 | 0 |
|
40 | 0 | request = new MediaSystemResourceRequest(aId, aResourceType); |
41 | 0 | mResourceRequests.Put(aId, request); |
42 | 0 | mMediaSystemResourceService->Acquire(this, aId, aResourceType, aWillWait); |
43 | 0 | return IPC_OK(); |
44 | 0 | } |
45 | | |
46 | | mozilla::ipc::IPCResult |
47 | | MediaSystemResourceManagerParent::RecvRelease(const uint32_t& aId) |
48 | 0 | { |
49 | 0 | MediaSystemResourceRequest* request = mResourceRequests.Get(aId); |
50 | 0 | if (!request) { |
51 | 0 | return IPC_OK(); |
52 | 0 | } |
53 | 0 |
|
54 | 0 | mMediaSystemResourceService->ReleaseResource(this, aId, request->mResourceType); |
55 | 0 | mResourceRequests.Remove(aId); |
56 | 0 | return IPC_OK(); |
57 | 0 | } |
58 | | |
59 | | mozilla::ipc::IPCResult |
60 | | MediaSystemResourceManagerParent::RecvRemoveResourceManager() |
61 | 0 | { |
62 | 0 | IProtocol* mgr = Manager(); |
63 | 0 | if (!PMediaSystemResourceManagerParent::Send__delete__(this)) { |
64 | 0 | return IPC_FAIL_NO_REASON(mgr); |
65 | 0 | } |
66 | 0 | return IPC_OK(); |
67 | 0 | } |
68 | | |
69 | | void |
70 | | MediaSystemResourceManagerParent::ActorDestroy(ActorDestroyReason aReason) |
71 | 0 | { |
72 | 0 | MOZ_ASSERT(!mDestroyed); |
73 | 0 |
|
74 | 0 | // Release all resource requests of the MediaSystemResourceManagerParent. |
75 | 0 | // Clears all remaining pointers to this object. |
76 | 0 | mMediaSystemResourceService->ReleaseResource(this); |
77 | 0 |
|
78 | 0 | mDestroyed = true; |
79 | 0 | } |
80 | | |
81 | | } // namespace media |
82 | | } // namespace mozilla |