SHEntryParent.h 8.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/* -*- 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_SHistoryEntry_h
#define mozilla_dom_SHistoryEntry_h

#include "mozilla/dom/PSHEntryParent.h"
11
#include "mozilla/dom/MaybeNewPSHEntry.h"
12
13
14
15
16
17
18
#include "mozilla/WeakPtr.h"
#include "nsSHEntry.h"
#include "nsSHEntryShared.h"

namespace mozilla {
namespace dom {

19
class LegacySHistory;
20
21
22
23
24
25
26
27
28
class PContentParent;
class SHEntryParent;

/**
 * Implementation of the shared state for session history entries in the parent
 * process.
 */
class SHEntrySharedParent : public SHEntrySharedParentState {
 public:
29
30
31
32
33
34
35
36
37
  SHEntrySharedParent(PContentParent* aContentParent, LegacySHistory* aSHistory,
                      uint64_t aSharedID);

  already_AddRefed<SHEntrySharedParent> Duplicate(uint64_t aNewSharedID) {
    RefPtr<SHEntrySharedParent> shared =
        new SHEntrySharedParent(this, aNewSharedID);
    shared->CopyFrom(this);
    return shared.forget();
  }
38
39
40

  PContentParent* GetContentParent() { return mContentParent.get(); }

41
42
43
44
45
46
47
 protected:
  SHEntrySharedParent(SHEntrySharedParent* aDuplicate, uint64_t aSharedID)
      : SHEntrySharedParentState(aDuplicate, aSharedID),
        mContentParent(aDuplicate->mContentParent) {}

  void Destroy() override;

48
49
50
51
52
53
54
55
56
57
58
 private:
  mozilla::WeakPtr<PContentParent> mContentParent;
};

/**
 * Session history entry implementation based on the legacy implementation that
 * used to live in the child process. Ideally this wouldn't implement nsISHEntry
 * (it should only ever be accessed by SHEntryParent and LegacySHistory).
 * The actor is (re)created as needed, whenever we need to return an entry to
 * the child process. The lifetime is determined by the child side.
 */
59
class LegacySHEntry final : public nsSHEntry, public CrossProcessSHEntry {
60
 public:
61
62
  LegacySHEntry(PContentParent* aContentParent, LegacySHistory* aSHistory,
                uint64_t aSharedID);
63
64
65
  explicit LegacySHEntry(const LegacySHEntry& aEntry)
      : nsSHEntry(aEntry), mActor(nullptr) {}

66
67
68
  NS_DECL_ISUPPORTS_INHERITED

  MaybeNewPSHEntryParent GetOrCreateActor(PContentParent* aContentParent);
69
70
71

  using nsSHEntry::AbandonBFCacheEntry;
  void AbandonBFCacheEntry(uint64_t aNewSharedID);
72
  NS_IMETHODIMP GetBfcacheID(uint64_t* aBFCacheID) override;
73
74
75

  uint64_t GetSharedStateID() const { return mShared->GetID(); }

76
77
78
79
  dom::SHEntrySharedParentState* GetSharedState() const {
    return mShared.get();
  }

80
81
 private:
  friend class SHEntryParent;
82
  friend class SHistoryParent;
83

84
85
  ~LegacySHEntry() {}

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  SHEntryParent* CreateActor();

  SHEntryParent* mActor;
};

/**
 * Session history entry actor for the parent process. Forwards to the legacy
 * implementation that used to live in the child process (see LegacySHEntry).
 */
class SHEntryParent final : public PSHEntryParent {
  friend class PSHEntryParent;
  friend class SHistoryParent;
  friend class ContentParent;

 public:
  explicit SHEntryParent(LegacySHEntry* aEntry)
      : PSHEntryParent(), mEntry(aEntry) {}

104
105
  LegacySHEntry* GetSHEntry() { return mEntry; }

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 protected:
  void ActorDestroy(ActorDestroyReason aWhy) override;

 private:
  bool RecvGetURI(RefPtr<nsIURI>* aURI);
  bool RecvSetURI(nsIURI* aURI);
  bool RecvGetOriginalURI(RefPtr<nsIURI>* aOriginalURI);
  bool RecvSetOriginalURI(nsIURI* aOriginalURI);
  bool RecvGetResultPrincipalURI(RefPtr<nsIURI>* aResultPrincipalURI);
  bool RecvSetResultPrincipalURI(nsIURI* aResultPrincipalURI);
  bool RecvGetLoadReplace(bool* aLoadReplace);
  bool RecvSetLoadReplace(const bool& aLoadReplace);
  bool RecvGetTitle(nsString* aTitle);
  bool RecvSetTitle(const nsString& aTitle);
  bool RecvGetIsSubFrame(bool* aIsSubFrame);
  bool RecvSetIsSubFrame(const bool& aIsSubFrame);
  bool RecvGetReferrerInfo(RefPtr<nsIReferrerInfo>* aReferrerInfo);
  bool RecvSetReferrerInfo(nsIReferrerInfo* aReferrerInfo);
  bool RecvGetSticky(bool* aSticky);
  bool RecvSetSticky(const bool& aSticky);
  bool RecvGetPostData(RefPtr<nsIInputStream>* aPostData);
  bool RecvSetPostData(nsIInputStream* aPostData);
128
  bool RecvGetParent(RefPtr<CrossProcessSHEntry>* aParentEntry);
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  bool RecvSetParent(PSHEntryParent* aParentEntry);
  bool RecvGetLoadType(uint32_t* aLoadType);
  bool RecvSetLoadType(const uint32_t& aLoadType);
  bool RecvGetID(uint32_t* aID);
  bool RecvSetID(const uint32_t& aID);
  bool RecvGetCacheKey(uint32_t* aCacheKey);
  bool RecvSetCacheKey(const uint32_t& aCacheKey);
  bool RecvGetExpirationStatus(bool* aExpirationStatus);
  bool RecvSetExpirationStatus(const bool& aExpirationStatus);
  bool RecvGetContentType(nsCString* aContentType);
  bool RecvSetContentType(const nsCString& aContentType);
  bool RecvGetURIWasModified(bool* aURIWasModified);
  bool RecvSetURIWasModified(const bool& aURIWasModified);
  bool RecvGetTriggeringPrincipal(RefPtr<nsIPrincipal>* aTriggeringPrincipal);
  bool RecvSetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
  bool RecvGetPrincipalToInherit(RefPtr<nsIPrincipal>* aPrincipalToInherit);
  bool RecvSetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit);
  bool RecvGetStoragePrincipalToInherit(
      RefPtr<nsIPrincipal>* aStoragePrincipalToInherit);
  bool RecvSetStoragePrincipalToInherit(
      nsIPrincipal* aStoragePrincipalToInherit);
  bool RecvGetCsp(RefPtr<nsIContentSecurityPolicy>* aCsp);
  bool RecvSetCsp(nsIContentSecurityPolicy* aCsp);
  bool RecvGetStateData(ClonedMessageData* aData);
  bool RecvSetStateData(ClonedMessageData&& aData);
  bool RecvGetDocshellID(nsID* aDocshellID);
  bool RecvSetDocshellID(const nsID& aDocshellID);
  bool RecvGetIsSrcdocEntry(bool* aIsSrcdocEntry);
  bool RecvGetSrcdocData(nsString* aSrcdocData);
  bool RecvSetSrcdocData(const nsString& aSrcdocData);
  bool RecvGetBaseURI(RefPtr<nsIURI>* aBaseURI);
  bool RecvSetBaseURI(nsIURI* aBaseURI);
  bool RecvGetScrollRestorationIsManual(bool* aScrollRestorationIsManual);
  bool RecvSetScrollRestorationIsManual(const bool& aScrollRestorationIsManual);
  bool RecvGetLoadedInThisProcess(bool* aLoadedInThisProcess);
  bool RecvGetLastTouched(uint32_t* aLastTouched);
  bool RecvSetLastTouched(const uint32_t& aLastTouched);
  bool RecvGetChildCount(int32_t* aChildCount);
  bool RecvGetPersist(bool* aPersist);
  bool RecvSetPersist(const bool& aPersist);
  bool RecvGetScrollPosition(int32_t* aX, int32_t* aY);
  bool RecvSetScrollPosition(const int32_t& aX, const int32_t& aY);
  bool RecvGetViewerBounds(nsIntRect* aBounds);
  bool RecvSetViewerBounds(const nsIntRect& aBounds);
  bool RecvCreate(nsIURI* aURI, const nsString& aTitle,
                  nsIInputStream* aInputStream, const uint32_t& aCacheKey,
                  const nsCString& aContentType,
                  nsIPrincipal* aTriggeringPrincipal,
                  nsIPrincipal* aPrincipalToInherit,
178
                  nsIPrincipal* aStoragePrincipalToInherit,
179
                  nsIContentSecurityPolicy* aCsp, const nsID& aDocshellID,
180
181
182
183
184
185
                  const bool& aDynamicCreation, nsIURI* aOriginalURI,
                  nsIURI* aResultPrincipalURI, const bool& aLoadReplace,
                  nsIReferrerInfo* aReferrerInfo, const nsAString& srcdoc,
                  const bool& srcdocEntry, nsIURI* aBaseURI,
                  const bool& aSaveLayoutState, const bool& aExpired);
  bool RecvClone(PSHEntryParent** aCloneEntry);
186
187
188
189
190
191
192
193
194
195
196
197
  bool RecvHasDetachedEditor(bool* aHasDetachedEditor);
  bool RecvIsDynamicallyAdded(bool* aIsDynamicallyAdded);
  bool RecvHasDynamicallyAddedChild(bool* aHasDynamicallyAddedChild);
  bool RecvDocshellID(nsID* aDocshellID);
  bool RecvAdoptBFCacheEntry(PSHEntryParent* aEntry, nsresult* aResult);
  bool RecvAbandonBFCacheEntry(const uint64_t& aNewSharedID);
  bool RecvSharesDocumentWith(PSHEntryParent* aEntry, bool* aSharesDocumentWith,
                              nsresult* aResult);
  bool RecvSetLoadTypeAsHistory();
  bool RecvAddChild(PSHEntryParent* aChild, const int32_t& aOffset,
                    const bool& aUseRemoteSubframes, nsresult* aResult);
  bool RecvRemoveChild(PSHEntryParent* aChild, nsresult* aResult);
198
199
  bool RecvGetChildAt(const int32_t& aIndex,
                      RefPtr<CrossProcessSHEntry>* aChild);
200
  bool RecvGetChildSHEntryIfHasNoDynamicallyAddedChild(
201
      const int32_t& aChildOffset, RefPtr<CrossProcessSHEntry>* aChild);
202
  bool RecvReplaceChild(PSHEntryParent* aNewChild, nsresult* aResult);
203
  bool RecvClearEntry(const uint64_t& aNewSharedID);
204

205
  bool RecvCreateLoadInfo(RefPtr<nsDocShellLoadState>* aLoadState);
206

207
208
209
210
  bool RecvUpdateLayoutHistoryState(const bool& aScrollPositionOnly,
                                    nsTArray<nsCString>&& aKeys,
                                    nsTArray<PresState>&& aStates);

211
212
213
214
215
216
217
  RefPtr<LegacySHEntry> mEntry;
};

}  // namespace dom
}  // namespace mozilla

#endif /* mozilla_dom_SHEntryParent_h */