diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/GroupedSHistory.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/GroupedSHistory.h')
-rw-r--r-- | dom/base/GroupedSHistory.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/dom/base/GroupedSHistory.h b/dom/base/GroupedSHistory.h new file mode 100644 index 000000000..8c88a0aaf --- /dev/null +++ b/dom/base/GroupedSHistory.h @@ -0,0 +1,105 @@ +/* -*- 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 GroupedSHistory_h +#define GroupedSHistory_h + +#include "nsIFrameLoader.h" +#include "nsIGroupedSHistory.h" +#include "nsIPartialSHistory.h" +#include "nsTArray.h" +#include "nsWeakReference.h" + +namespace mozilla { +namespace dom { + + +/** + * GroupedSHistory connects session histories across multiple frameloaders. + * Each frameloader has a PartialSHistory, and GroupedSHistory has an array + * refering to all participating PartialSHistory(s). + * + * The following figure illustrates the idea. In this case, the GroupedSHistory + * is composed of 3 frameloaders, and the active one is frameloader 1. + * GroupedSHistory is always attached to the active frameloader. + * + * +----------------------------------------------------+ + * | | + * | v + * +------------------+ +-------------------+ +-----------------+ + * | FrameLoader 1 | | PartialSHistory 1 | | GroupedSHistory | + * | (active) |----->| (active) |<--+---| | + * +------------------+ +-------------------+ | +-----------------+ + * | + * +------------------+ +-------------------+ | + * | FrameLoader 2 | | PartialSHistory 2 | | + * | (inactive) |----->| (inactive) |<--+ + * +------------------+ +-------------------+ | + * | + * +------------------+ +-------------------+ | + * | FrameLoader 3 | | PartialSHistory 3 | | + * | (inactive) |----->| (inactive) |<--+ + * +------------------+ +-------------------+ + * + * If a history navigation leads to frameloader 3, it becomes the active one, + * and GroupedSHistory is re-attached to frameloader 3. + * + * +------------------+ +-------------------+ + * | FrameLoader 1 | | PartialSHistory 1 | + * | (inactive) |----->| (inactive) |<--+ + * +------------------+ +-------------------+ | + * | + * +------------------+ +-------------------+ | + * | FrameLoader 2 | | PartialSHistory 2 | | + * | (inactive) |----->| (inactive) |<--+ + * +------------------+ +-------------------+ | + * | + * +------------------+ +-------------------+ | +-----------------+ + * | FrameLoader 3 | | PartialSHistory 3 | | | GroupedSHistory | + * | (active) |----->| (active) |<--+---| | + * +------------------+ +-------------------+ +-----------------+ + * | ^ + * | | + * +----------------------------------------------------+ + */ +class GroupedSHistory final : public nsIGroupedSHistory +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(GroupedSHistory) + NS_DECL_NSIGROUPEDSHISTORY + GroupedSHistory(); + + /** + * Get the value of preference "browser.groupedhistory.enabled" to determine + * if grouped session history should be enabled. + */ + static bool GroupedHistoryEnabled(); + +private: + ~GroupedSHistory() {} + + /** + * Remove all partial histories and close tabs after the given index (of + * mPartialHistories, not the index of session history entries). + */ + void PurgePartialHistories(uint32_t aLastPartialIndexToKeep); + + // The total number of entries in all partial histories. + uint32_t mCount; + + // The index of currently active partial history in mPartialHistories. + // Use int32_t as we have invalid index and nsCOMArray also uses int32_t. + int32_t mIndexOfActivePartialHistory; + + // All participating nsIPartialSHistory objects. + nsCOMArray<nsIPartialSHistory> mPartialHistories; +}; + +} // namespace dom +} // namespace mozilla + +#endif /* GroupedSHistory_h */ |