forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSHistoryChild.h
88 lines (67 loc) · 2.35 KB
/
SHistoryChild.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_SHistoryChild_h
#define mozilla_dom_SHistoryChild_h
#include "mozilla/dom/PSHistoryChild.h"
#include "nsExpirationTracker.h"
#include "nsISHistory.h"
#include "nsWeakReference.h"
class nsIDocShell;
namespace mozilla {
namespace dom {
class LoadSHEntryData;
class SHEntryChildShared;
/**
* Session history actor for the child process.
*/
class SHistoryChild final : public PSHistoryChild,
public nsISHistory,
public nsSupportsWeakReference {
friend class PSHistoryChild;
public:
explicit SHistoryChild(BrowsingContext* aBrowsingContext);
NS_DECL_ISUPPORTS
NS_DECL_NSISHISTORY
protected:
void ActorDestroy(ActorDestroyReason aWhy) override {
mIPCActorDeleted = true;
}
private:
bool RecvReloadCurrentEntryFromChild() {
ReloadCurrentEntry();
return true;
}
// The timer based history tracker is used to evict bfcache on expiration.
class HistoryTracker final
: public nsExpirationTracker<SHEntryChildShared, 3> {
public:
explicit HistoryTracker(SHistoryChild* aSHistory, uint32_t aTimeout,
nsIEventTarget* aEventTarget)
: nsExpirationTracker(1000 * aTimeout / 2, "HistoryTracker",
aEventTarget),
mSHistory(aSHistory) {
MOZ_ASSERT(aSHistory);
mSHistory = aSHistory;
}
protected:
void NotifyExpired(SHEntryChildShared* aObj) override;
private:
// HistoryTracker is owned by SHistoryChild; it always outlives
// HistoryTracker so it's safe to use raw pointer here.
SHistoryChild* mSHistory;
};
~SHistoryChild() = default;
nsresult LoadURI(nsTArray<LoadSHEntryData>& aLoadData);
// Track all bfcache entries and evict on expiration.
mozilla::UniquePtr<HistoryTracker> mHistoryTracker;
// Session History listeners
nsAutoTObserverArray<nsWeakPtr, 2> mListeners;
WeakPtr<nsDocShell> mRootDocShell;
bool mIPCActorDeleted;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_SHistoryChild_h */