Closed Bug 787477 Opened 13 years ago Closed 13 years ago

B2G RIL: Add error handling for getICCContacts

Categories

(Core :: DOM: Device Interfaces, defect)

All
Symbian
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla18

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

Attachments

(3 files, 6 obsolete files)

1.66 KB, patch
philikon
: review+
sicking
: superreview+
Details | Diff | Splinter Review
3.57 KB, patch
gwagner
: review+
Details | Diff | Splinter Review
4.13 KB, patch
Details | Diff | Splinter Review
Currently in nsIRadioInterfaceLayer.getICCContacts, there's no way to tell error happens, we need to revise this.
update error message
Attachment #659198 - Attachment is obsolete: true
Attachment #659198 - Flags: review?(philipp)
remove trailing ws
Attachment #659203 - Attachment is obsolete: true
Comment on attachment 659195 [details] [diff] [review] Part 1: Update IDL of getICCContacts. Review of attachment 659195 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/system/gonk/nsIRadioInterfaceLayer.idl @@ +310,4 @@ > */ > + void getICCContacts(in DOMString contactType, > + in nsIRILContactCallback callback, > + in nsIRILContactErrorCallback errorCallback); Do we really need an extra callback for errors? Why not follow the node.js convention of (error, result) in the callback signature? Or in this case, (error, contactType, contacts). Use `null` when values don't apply.
Attachment #659195 - Flags: review?(philipp)
Comment on attachment 659204 [details] [diff] [review] Part 3: Update RIL implementations. v2 Review of attachment 659204 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/system/gonk/RadioInterfaceLayer.js @@ +439,5 @@ > + > + delete this._contactsCallbacks[message.requestId]; > + if (message.success) { > + cbObj.callback.receiveContactsList(message.contactType, > + message.contacts); You can just call `cbObj.callback()` since you declared nsIRILContactCallback to be a [function] interface. ::: dom/system/gonk/ril_worker.js @@ +1498,5 @@ > delete options.callback; > delete options.onerror; > options.rilMessageType = "icccontacts"; > + options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; > + options.success = false; You can also do options.success = options.rilRequestError == ERROR_SUCCESS; before we invoke the success/error callbacks. That way you don't have to set `options.success` in every place.
Attachment #659204 - Flags: review?(philipp)
(In reply to Philipp von Weitershausen [:philikon] from comment #6) > Comment on attachment 659195 [details] [diff] [review] > Part 1: Update IDL of getICCContacts. > > Review of attachment 659195 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/system/gonk/nsIRadioInterfaceLayer.idl > @@ +310,4 @@ > > */ > > + void getICCContacts(in DOMString contactType, > > + in nsIRILContactCallback callback, > > + in nsIRILContactErrorCallback errorCallback); > > Do we really need an extra callback for errors? Why not follow the node.js > convention of (error, result) in the callback signature? Or in this case, > (error, contactType, contacts). Use `null` when values don't apply. Yeah we could handle the error case in the regular callback. But I guess most of our new function have successCB and errorCB. If we want to fire the errorcallback from multiple locations it would make more sense to use a dedicated argument for it.
(In reply to Philipp von Weitershausen [:philikon] from comment #6) > Comment on attachment 659195 [details] [diff] [review] > Part 1: Update IDL of getICCContacts. > > Review of attachment 659195 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: dom/system/gonk/nsIRadioInterfaceLayer.idl > @@ +310,4 @@ > > */ > > + void getICCContacts(in DOMString contactType, > > + in nsIRILContactCallback callback, > > + in nsIRILContactErrorCallback errorCallback); > > Do we really need an extra callback for errors? Why not follow the node.js > convention of (error, result) in the callback signature? Or in this case, > (error, contactType, contacts). Use `null` when values don't apply. Hi philikon, Since this function is used in ContactService, so I use the same style in ContactService and ContactDB. Which style do you prefer? node.js or the one in ContactService ? Thanks
The convention used in ContactsDB (and other IndexedDB consumers) has different reasons. I'd prefer a simple callback interface for the RIL here.
(In reply to Philipp von Weitershausen [:philikon] from comment #10) > The convention used in ContactsDB (and other IndexedDB consumers) has > different reasons. I'd prefer a simple callback interface for the RIL here. Thanks, then I'll use the (error, contactType, contacts) style here.
With philikon's comments addressed, Didn't introduce another error callback and use node.js style for error notification.
Attachment #659195 - Attachment is obsolete: true
Accommodated to IDL's update.
Attachment #659196 - Attachment is obsolete: true
Comment on attachment 660773 [details] [diff] [review] Part 1: Update IDL of getICCContacts. v2 Hi, philikon I added another parameter errorMsg according to your suggestions, would you help to review this? Thanks
Attachment #660773 - Flags: review?(philipp)
Comment on attachment 660776 [details] [diff] [review] Part 2: Update ContactManager and ContactService v2 Hi, gwagner Could you review this patch for error handling of importing SIM contact? Thanks
Attachment #660776 - Flags: review?(anygregor)
Comment on attachment 660777 [details] [diff] [review] Part 3: Update RIL implementations. v3 Hi, philikon Since now ril_worker will report the error message to RadioInterfaceLayer, so I didn't introduction another property 'success' in options here. Also I noticed that when I call the callback in RadioInterfaceLayer.js, I still have to use callback.receiveContactsList here as I found its type is still object, not function. Thanks
Attachment #660777 - Flags: review?(philipp)
Comment on attachment 660776 [details] [diff] [review] Part 2: Update ContactManager and ContactService v2 >+ mRIL.getICCContacts( >+ msg.options.contactType, >+ function (aErrorMsg, aType, aContacts) { >+ if (aErrorMsg) { >+ mm.sendAsyncMessage("Contacts:GetSimContacts:Return:KO", >+ {requestID: msg.requestID, >+ errorMsg: aErrorMsg}); >+ } else { >+ mm.sendAsyncMessage("Contacts:GetSimContacts:Return:OK", >+ {requestID: msg.requestID, >+ contacts: aContacts}); >+ } >+ }.bind(this)); Huh I am not a big fan of this style but it works.
Attachment #660776 - Flags: review?(anygregor) → review+
(In reply to Yoshi Huang[:yoshi][:allstars.chh] from comment #17) > Since now ril_worker will report the error message to RadioInterfaceLayer, > so I didn't introduction another property 'success' in options here. Sounds good. > Also I noticed that when I call the callback in RadioInterfaceLayer.js, I > still have to use callback.receiveContactsList here as I found its type is > still object, not function. Ah, looks like I got confused a little then. Thanks for verifying.
Attachment #660773 - Flags: review?(philipp) → review+
Attachment #660777 - Flags: review?(philipp) → review+
Comment on attachment 660773 [details] [diff] [review] Part 1: Update IDL of getICCContacts. v2 Hi, sicking Currently in ContactDB, there is no way to tell error cause when importing SIM contact, (i.e. SIM absent) So this patch is about adding error message in getting SIM contact, as philikon suggested in comment 6 and comment 10. Would you review this for me? Thanks
Attachment #660773 - Flags: superreview?(jonas)
Attachment #660773 - Flags: superreview?(jonas) → superreview+
Blocks: 1157082
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: