Closed Bug 1358906 Opened 7 years ago Closed 7 years ago

Convert session store to JSONFile async apis

Categories

(Thunderbird :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 55.0

People

(Reporter: alta88, Assigned: alta88)

References

Details

Attachments

(1 file, 2 obsolete files)

      No description provided.
Attached patch sessionstore.patch (obsolete) — Splinter Review
Use JSONFile and async/await instead of sync file reads/writes. Also a bonus tweak to prevent lost session state on failed startups (primarily a dev issue).

r? for whomever has time first.
Assignee: nobody → alta88
Attachment #8860752 - Flags: review?(mkmelin+mozilla)
Attachment #8860752 - Flags: review?(acelists)
Comment on attachment 8860752 [details] [diff] [review]
sessionstore.patch

Review of attachment 8860752 [details] [diff] [review]:
-----------------------------------------------------------------

::: mail/base/content/msgMail3PaneWindow.js
@@ +695,5 @@
>   *
>   * @return true if the restoration was successful, false otherwise.
>   */
> +async function atStartupRestoreTabs(aDontRestoreFirstTab) {
> +  let state =  await sessionStoreManager.loadingWindow(window);

nit: is that two spaces after = ?

::: mail/base/modules/sessionStoreManager.js
@@ +32,5 @@
>  
> +  /**
> +   * Session restored successfully on startup; use this to test for an early
> +   * failed startup which does not restore user tab state to ensure a session
> +   * save on close will not overwrite the last good session state. 

nit: trailing space

@@ -326,5 @@
>      }
>    }
>  };
> -
> -AsyncShutdown.profileBeforeChange.addBlocker(

What is replacing this? Even with await, the application could close before completion
(In reply to Magnus Melin from comment #2)
> Comment on attachment 8860752 [details] [diff] [review]
> sessionstore.patch
> 
> Review of attachment 8860752 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> 
> @@ -326,5 @@
> >      }
> >    }
> >  };
> > -
> > -AsyncShutdown.profileBeforeChange.addBlocker(
> 
> What is replacing this? Even with await, the application could close before
> completion

JSONFile has a finalize() to do this - somehow it got lost in the patch..
Comment on attachment 8860752 [details] [diff] [review]
sessionstore.patch


Actually, finalize() and shutdown protection is a freebie with JSONFile, but it requires using saveSoon() a deferred task. But that's just a timer for _save(), which I used instead since it returns a promise and can be used with await. And I did that because otherwise tests were a fail. So either tests are rewritten or it goes back to writeAtomic; the goal was for the read part to use the api moreso than the write part anyway.
Attachment #8860752 - Flags: review?(mkmelin+mozilla)
Attachment #8860752 - Flags: review?(acelists)
Attached patch sessionstore.patch (obsolete) — Splinter Review
This goes back to using JSONFile.saveSoon() so shutdown is handled, and tests are changed to get rid of the timer hack and instead call the real thing being tested, _saveState().
Attachment #8860752 - Attachment is obsolete: true
Attachment #8860798 - Flags: review?(mkmelin+mozilla)
use FileUtils in the test, remove debug.
Attachment #8860798 - Attachment is obsolete: true
Attachment #8860798 - Flags: review?(mkmelin+mozilla)
Attachment #8860801 - Flags: review?(mkmelin+mozilla)
Comment on attachment 8860801 [details] [diff] [review]
sessionstore.patch

Review of attachment 8860801 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM! r=mkmelin
Attachment #8860801 - Flags: review?(mkmelin+mozilla) → review+
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/4bb4349aaab0e59ae5b46c7e7679595bda7d9fae
Status: NEW → RESOLVED
Closed: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 55.0
Curious if bug 929406 would be solved from this patch.
(In reply to Ulf Zibis from comment #9)
> Curious if bug 929406 would be solved from this patch.

You can find out by using the beta from http://www.mozilla.org/en-US/thunderbird/channel/
Depends on: 1484270
Comment on attachment 8860801 [details] [diff] [review]
sessionstore.patch

>-function atStartupRestoreTabs(aDontRestoreFirstTab) {
>+async function atStartupRestoreTabs(aDontRestoreFirstTab) {
Unfortunately you forgot to update the caller and they now get a promise which they mistake for a `true` value...
Depends on: 1554237
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: