| 1 | package main |
| 2 | |
| 3 | import "net/http" |
| 4 | |
| 5 | // A rejection is one publication transaction: observers of its error must |
| 6 | // already see the restored identity. The route fence also prevents a newer |
| 7 | // selection or authoritative frame from being overwritten by the old failure. |
| 8 | func (a *App) completeRemoteTabResumeFailure(tabID string, tab *remoteTab, client *http.Client, gen uint64, route remoteTabProvisionalResume, message string) bool { |
| 9 | tab.routeEventMu.Lock() |
| 10 | defer tab.routeEventMu.Unlock() |
| 11 | a.remoteTabMu.Lock() |
| 12 | current := a.remoteTabs[tabID] |
| 13 | if current != tab || current.client != client || current.gen != gen || current.state != "ready" || |
| 14 | current.selectionRevision != route.selectionRevision || current.routing.currentPath != route.targetPath || |
| 15 | route.active && (current.routing.rehydratingPath != route.targetPath || current.routing.pathRevision != route.pathRevision+1) || |
| 16 | !route.active && current.routing.pathRevision != route.pathRevision || |
| 17 | route.previousSelection != nil && current.selectionRevision != route.previousSelection.revision { |
| 18 | a.remoteTabMu.Unlock() |
| 19 | return true |
| 20 | } |
| 21 | if route.previousSelection != nil { |
| 22 | restoreRemoteTabOpenSelectionLocked(current, route.previousSelection) |
| 23 | } else if route.active { |
| 24 | restoreRemoteTabProvisionalRouteLocked(current, route) |
| 25 | } |
| 26 | current.err = message |
| 27 | meta := remoteTabMetaLocked(current) |
| 28 | a.remoteTabMu.Unlock() |
| 29 | if route.previousSelection != nil { |
| 30 | a.emitRemoteEvent("remote-tab:updated", meta) |
| 31 | a.saveTabsFromRemote() |
| 32 | } |
| 33 | a.publishRemoteTabState(tabID, RemoteTabStateView{State: "ready", Error: message}) |
| 34 | return false |
| 35 | } |
| 36 |