pub struct TabRegistry {
tabs: BTreeMap<u16, Tab>,
current: HashMap<SessionSlot, u16>,
retired: HashSet<u16>,
unresolved: HashSet<u16>,
closed: HashSet<u16>,
}Expand description
The profile’s tabs, keyed by the host’s own tab number. The registry
never mints one: the host’s numbers are what frames, mouse input and
TabClosed already carry, and a second counter would drift from them.
Fields§
§tabs: BTreeMap<u16, Tab>§current: HashMap<SessionSlot, u16>§retired: HashSet<u16>Every number this registry has ever taken. A retired number is never handed out again, so a hand-off written against it can never come to mean another tab.
unresolved: HashSet<u16>Tabs whose page a listing could not name. Their pages are not orphans: the prune closes nothing while one is unresolved, or a live document would be closed because its row could not be paired.
closed: HashSet<u16>Numbers the host has reported ended, including ones no row ever took. A birth for one of these is not waiting for a page: a popup the host gave up closed before its page existed, and a birth kept for it would be re-deferred for ever - a driver recovery on every pass.
Implementations§
Source§impl TabRegistry
impl TabRegistry
Sourcepub fn adopt(
&mut self,
number: u16,
owner: SessionSlot,
target: &str,
title: &str,
url: &str,
) -> Result<u16, String>
pub fn adopt( &mut self, number: u16, owner: SessionSlot, target: &str, title: &str, url: &str, ) -> Result<u16, String>
Take the host’s tab number for owner. A number the registry has
seen before is a refusal: the host never reuses one, so a duplicate
is a bug in the pairing, not a tab to overwrite.
Sourcepub fn create_under(
&mut self,
opener: u16,
number: u16,
target: &str,
title: &str,
url: &str,
) -> Result<u16, String>
pub fn create_under( &mut self, opener: u16, number: u16, target: &str, title: &str, url: &str, ) -> Result<u16, String>
A tab the page opened: it belongs to whoever owns opener.
Sourcepub fn close(&mut self, tab: u16) -> Option<SessionSlot>
pub fn close(&mut self, tab: u16) -> Option<SessionSlot>
Remove one tab and answer the session that owned it. The unresolved flag goes even for a row already gone: a close landing between a listing and its mark must not leave the flag on a retired number.
A popup closing hands its session back to the opener. An OAuth popup closes itself the moment it is done, and a session left with no tab would open a fresh blank page on its next call instead of the page the sign-in started from.
Sourcepub fn mark_unresolved(&mut self, tab: u16)
pub fn mark_unresolved(&mut self, tab: u16)
Remember that a listing could not name this tab’s page, so no page is pruned as an orphan while the row is unresolved. Only an open row is marked: a number with no row has no page to protect.
Sourcepub fn unresolved_tabs(&self) -> Vec<u16>
pub fn unresolved_tabs(&self) -> Vec<u16>
The tabs whose page a listing could not name.
Sourcepub fn was_closed(&self, tab: u16) -> bool
pub fn was_closed(&self, tab: u16) -> bool
Whether the host has reported this number ended. A birth for one is answered rather than kept: nothing will ever list its page.
pub fn close_owned( &mut self, session: &SessionSlot, tab: u16, ) -> Result<Option<SessionSlot>, String>
pub fn current(&self, session: &SessionSlot) -> Option<u16>
Sourcepub fn forget_current(&mut self, session: &SessionSlot)
pub fn forget_current(&mut self, session: &SessionSlot)
Forget a session’s current tab without closing it: a replacement keeps the slot but inherits none of the occupant’s place.
pub fn select(&mut self, session: &SessionSlot, tab: u16) -> Result<(), String>
pub fn target(&self, tab: u16) -> Option<&str>
Sourcepub fn number_of(&self, target: &str) -> Option<u16>
pub fn number_of(&self, target: &str) -> Option<u16>
The tab a page target names, or None when that page is gone.
The identity an open resolves: a tab number survives a host replacement in name only, and the successor’s first tab takes number 1 again.
Sourcepub fn listing(&self) -> String
pub fn listing(&self) -> String
The tabs as one line, for a refusal that names what is open now.
Sourcepub fn title_url(&self, tab: u16) -> Option<(&str, &str)>
pub fn title_url(&self, tab: u16) -> Option<(&str, &str)>
A tab’s title and url, for the listing the tools answer with.
Sourcepub fn owned_target(
&self,
session: &SessionSlot,
target: &str,
) -> Result<u16, String>
pub fn owned_target( &self, session: &SessionSlot, target: &str, ) -> Result<u16, String>
The tab whose page is target, if this session owns it. The page id
is the tab’s address: the host’s number restarts with every host, so
an id no row carries is refused rather than resolved to whatever holds
that number today.
pub fn owner(&self, tab: u16) -> Option<&SessionSlot>
Sourcepub fn other_owners(&self, except: &SessionSlot) -> Vec<(SessionSlot, Duration)>
pub fn other_owners(&self, except: &SessionSlot) -> Vec<(SessionSlot, Duration)>
The sessions other than except holding a tab, each with how long it
has held its oldest one: what a host end must not take with it.
Sourcepub fn other_owners_at(
&self,
except: &SessionSlot,
now: Instant,
) -> Vec<(SessionSlot, Duration)>
pub fn other_owners_at( &self, except: &SessionSlot, now: Instant, ) -> Vec<(SessionSlot, Duration)>
Self::other_owners against a clock the caller owns, so a test
needs no instant older than the machine’s boot.
pub fn mark_busy(&mut self, tab: u16, busy: bool)
Sourcepub fn update(&mut self, tab: u16, title: &str, url: &str) -> bool
pub fn update(&mut self, tab: u16, title: &str, url: &str) -> bool
Replace a row’s title and url, answering whether either changed.
pub(crate) fn owned( &self, session: &SessionSlot, tab: u16, ) -> Result<&Tab, String>
Sourcepub fn rows(
&self,
held: &HashSet<u16>,
controlled: &HashSet<u16>,
dialogs: &HashMap<u16, BrowserTabDialog>,
) -> Vec<BrowserTabRow>
pub fn rows( &self, held: &HashSet<u16>, controlled: &HashSet<u16>, dialogs: &HashMap<u16, BrowserTabDialog>, ) -> Vec<BrowserTabRow>
The rows the strip draws. A held tab outranks a busy one: the person is being asked about it, which is the fact worth seeing. A tab a person is driving is in use, like one a call is driving: the spec’s in-use is either.
pub fn is_empty(&self) -> bool
pub fn numbers(&self) -> Vec<u16>
Sourcepub fn popup_age(&self, now: Instant) -> Option<Duration>
pub fn popup_age(&self, now: Instant) -> Option<Duration>
The age of the youngest popup tab, or None when no popup is open.
A popup’s target hangs a fresh driver’s connect whether or not its
document has started, so the host is kept while one is inside its
window; past it, the popup is the wedge rather than a sign-in in
progress. is_popup, not opener: an opener that closes first
hands its children None, and the popup is still a popup.