Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * vim: sw=2 ts=8 et :
3 : */
4 : /* This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 :
8 : #ifndef MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
9 : #define MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
10 :
11 : #include <stdint.h> // for uint32_t
12 : #include "mozilla/Attributes.h" // for override
13 : #include "mozilla/ipc/ProtocolUtils.h"
14 : #include "mozilla/layers/PLayerTransactionChild.h"
15 : #include "mozilla/RefPtr.h"
16 :
17 : namespace mozilla {
18 :
19 : namespace layout {
20 : class RenderFrameChild;
21 : } // namespace layout
22 :
23 : namespace layers {
24 :
25 : class ShadowLayerForwarder;
26 :
27 : class LayerTransactionChild : public PLayerTransactionChild
28 : {
29 : public:
30 4 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(LayerTransactionChild)
31 : /**
32 : * Clean this up, finishing with SendShutDown() which will cause __delete__
33 : * to be sent from the parent side.
34 : *
35 : * It is expected (checked with an assert) that all shadow layers
36 : * created by this have already been destroyed and
37 : * Send__delete__()d by the time this method is called.
38 : */
39 : void Destroy();
40 :
41 211 : bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
42 : bool IsDestroyed() const { return mDestroyed; }
43 :
44 2 : void SetForwarder(ShadowLayerForwarder* aForwarder)
45 : {
46 2 : mForwarder = aForwarder;
47 2 : }
48 :
49 2 : uint64_t GetId() const { return mId; }
50 :
51 0 : void MarkDestroyed() {
52 0 : mDestroyed = true;
53 0 : }
54 :
55 : protected:
56 2 : explicit LayerTransactionChild(const uint64_t& aId)
57 2 : : mForwarder(nullptr)
58 : , mIPCOpen(false)
59 : , mDestroyed(false)
60 2 : , mId(aId)
61 2 : {}
62 0 : ~LayerTransactionChild() { }
63 :
64 : virtual void ActorDestroy(ActorDestroyReason why) override;
65 :
66 2 : void AddIPDLReference() {
67 2 : MOZ_ASSERT(mIPCOpen == false);
68 2 : mIPCOpen = true;
69 2 : AddRef();
70 2 : }
71 0 : void ReleaseIPDLReference() {
72 0 : MOZ_ASSERT(mIPCOpen == true);
73 0 : mIPCOpen = false;
74 0 : Release();
75 0 : }
76 : friend class CompositorBridgeChild;
77 : friend class layout::RenderFrameChild;
78 :
79 : ShadowLayerForwarder* mForwarder;
80 : bool mIPCOpen;
81 : bool mDestroyed;
82 : uint64_t mId;
83 : };
84 :
85 : } // namespace layers
86 : } // namespace mozilla
87 :
88 : #endif // MOZILLA_LAYERS_LAYERTRANSACTIONCHILD_H
|