Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
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 : #ifndef ScriptCache_h
7 : #define ScriptCache_h
8 :
9 : #include "mozilla/ScriptPreloader.h"
10 : #include "mozilla/loader/PScriptCacheChild.h"
11 : #include "mozilla/loader/PScriptCacheParent.h"
12 :
13 : namespace mozilla {
14 : namespace ipc {
15 : class FileDescriptor;
16 : }
17 :
18 :
19 : namespace loader {
20 :
21 : using mozilla::ipc::FileDescriptor;
22 : using mozilla::ipc::IPCResult;
23 :
24 3 : class ScriptCacheParent final : public PScriptCacheParent
25 : {
26 : public:
27 2 : explicit ScriptCacheParent(bool wantCacheData)
28 2 : : mWantCacheData(wantCacheData)
29 2 : {}
30 :
31 : protected:
32 : virtual IPCResult Recv__delete__(nsTArray<ScriptData>&& scripts) override;
33 :
34 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
35 :
36 : private:
37 : bool mWantCacheData;
38 : };
39 :
40 6 : class ScriptCacheChild final : public PScriptCacheChild
41 : {
42 : friend class mozilla::ScriptPreloader;
43 :
44 : public:
45 2 : ScriptCacheChild() = default;
46 :
47 : void Init(const Maybe<FileDescriptor>& cacheFile, bool wantCacheData);
48 :
49 : protected:
50 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
51 :
52 : void SendScriptsAndFinalize(ScriptPreloader::ScriptHash& scripts);
53 :
54 : private:
55 : bool mWantCacheData = false;
56 : };
57 :
58 :
59 : } // namespace loader
60 : } // namespace mozilla
61 :
62 : #endif // ScriptCache_h
|