Make the CalDAV provider async safe

RESOLVED FIXED in 3.6

Status

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: anderson, Assigned: anderson)

Tracking

(Blocks: 1 bug)

Trunk
x86_64
Linux
Dependency tree / graph

Details

Attachments

(1 attachment, 3 obsolete attachments)

(Assignee)

Description

4 years ago
Currently CalDAV assumes some storage calendar functions are synchronous, which will no longer be the case.
(Assignee)

Comment 1

4 years ago
Created attachment 8460305 [details] [diff] [review]
AsyncCalDAV
Attachment #8460305 - Flags: review?(philipp)
(Assignee)

Comment 2

4 years ago
Created attachment 8460307 [details] [diff] [review]
AsyncCalDAV
Attachment #8460305 - Attachment is obsolete: true
Attachment #8460305 - Flags: review?(philipp)
Attachment #8460307 - Flags: review?(philipp)
Comment on attachment 8460307 [details] [diff] [review]
AsyncCalDAV

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

Code looks good, r=philipp. I will give this a test run after my rebuild finishes. I'd appreciate if you could upload a new patch with the below comments fixed.

Please pull the latest changes from comm-central, there are some minor conflicts in the first chunk of calDavCalendar.js after bug 1021684.

::: calendar/base/modules/calAsyncUtils.jsm
@@ +3,5 @@
> +     * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
> +     
> +    Components.utils.import("resource://calendar/modules/calUtils.jsm");
> +    Components.utils.import("resource://gre/modules/Promise.jsm");
> +     

Looks like I left a few redundant whitespaces in this file, could you remove them?

::: calendar/providers/caldav/calDavCalendar.js
@@ +1036,2 @@
>  
> +        Task.spawn(function() {

function*() {

@@ +1103,5 @@
>       * @param path Path of the item to delete, must not be encoded
>       */
>      deleteTargetCalendarItem: function caldav_deleteTargetCalendarItem(path) {
> +        let self = this;
> +        return Task.spawn(function*() {

I just found a pretty cool feature of Task.jsm thats not documented on MDN. Its very useful for functions like this where all that is run is a Task. It also saves us the let self = this crutch.


deleteTargetCalendaItem: Task.async(function*() {
    let pcal = promisifyCalendar(this.mOfflineStorage);
    ....

}),

See here for more details:
http://mxr.mozilla.org/comm-central/source/mozilla/toolkit/modules/Task.jsm#168


On a side note, you should also use this in the async storage patch.
Attachment #8460307 - Flags: review?(philipp) → review+
Comment on attachment 8460307 [details] [diff] [review]
AsyncCalDAV

As discussed via IRC, there are still some issues with the patch. First of all the missing cal.async prefix, then the item is not removed from the calendar. Setting r- to reflect this, looking forward to the new patch.
Attachment #8460307 - Flags: review+ → review-
(Assignee)

Comment 5

4 years ago
Created attachment 8460765 [details] [diff] [review]
AsyncCalDAV
Attachment #8460307 - Attachment is obsolete: true
Attachment #8460765 - Flags: review?(philipp)
Comment on attachment 8460765 [details] [diff] [review]
AsyncCalDAV

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

Great, works as expected and code looks good. r=philipp
Attachment #8460765 - Flags: review?(philipp) → review+
Setting checkin-needed as the tree currently has APPROVAL REQUIRED. https://tbpl.mozilla.org/?tree=Thunderbird-Trunk
Keywords: checkin-needed
Target Milestone: --- → 3.6
Created attachment 8460807 [details] [diff] [review]
AsyncCalDAV

Ah I found a minor issue with calAsyncUtils.jsm. First of all it was indented by one level, then we forgot to change this.itemStatus when the onGetResult fails. This patch fixes both issues.
Attachment #8460765 - Attachment is obsolete: true
Attachment #8460807 - Flags: review+
https://hg.mozilla.org/comm-central/rev/74269aa54a84
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.