Closed Bug 720632 Opened 13 years ago Closed 13 years ago

WebSMS: Expose SmsRequestManager as a scriptable XPCOM service

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: philikon, Assigned: philikon)

References

Details

Attachments

(4 files, 4 obsolete files)

This is needed for the JS-based implementation of nsISmsDatabaseService (bug 712809).
Blocks: 720643
Attached patch Part 1 (v1): IDL (obsolete) (deleted) — Splinter Review
I'm taking a shot at this since it blocks some important SMS fixes. Here's the IDL, I'm working through the implementation right now.
Assignee: nobody → philipp
Attachment #592179 - Flags: review?(mounir)
OS: Linux → All
Hardware: x86_64 → All
Version: unspecified → Trunk
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL I would prefer to look at the entire patch at the same time if you don't mind. This said, I can really do that this week (I was in the DOM Binding work week last week so I hadn't much time). Do you still want to work on this?
Attachment #592179 - Flags: review?(mounir)
(In reply to Mounir Lamouri (:volkmar) (:mounir) from comment #2) > I would prefer to look at the entire patch at the same time if you don't > mind. Fair enough. Let me see how far I can get it on Monday. If I get stuck somewhere, you're welcome to take it over. :)
(In reply to Philipp von Weitershausen [:philikon] from comment #3) > Fair enough. Let me see how far I can get it on Monday. If I get stuck > somewhere, you're welcome to take it over. :) I'm putting this on hold until we decide whether WebSMS will adopt DOMRequest (bug 722626) or not. If so, this bug becomes obsolete. If not, then we can pick it up again.
Target Milestone: --- → mozilla12
Attached patch Part 2 (WIP 1): XPCOMtaminate SmsRequestManager (obsolete) (deleted) — Splinter Review
Posting this here for posterity's sake. Grossly incomplete.
Attached patch Part 2 (v1): XPCOMtaminate SmsRequestManager (obsolete) (deleted) — Splinter Review
I ended up finishing this real quick, seeing that DOMRequest might take a bit longer.
Attachment #593170 - Attachment is obsolete: true
Attachment #596215 - Flags: review?(mounir)
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL Re-requesting review now that part 2 is up :)
Attachment #592179 - Flags: review?(mounir)
Attached patch Part 3 (v1): XPCOM turds (deleted) — Splinter Review
PCOM registration bits.
Attachment #596233 - Flags: review?(mounir)
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL mounir is swamped and this is blocking the compmletion of WebSMS on Gonk, so over to cjones!
Attachment #592179 - Flags: review?(mounir) → review?(jones.chris.g)
Attachment #596215 - Flags: review?(mounir) → review?(jones.chris.g)
Attachment #596233 - Flags: review?(mounir) → review?(jones.chris.g)
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL >diff --git a/dom/sms/interfaces/nsISmsRequestManager.idl b/dom/sms/interfaces/nsISmsRequestManager.idl >+[scriptable, uuid(1638b963-3a45-4937-b6a9-280c1bfb166c)] >+interface nsISmsRequestManager : nsISupports >+{ >+ >+ const unsigned short eNoError = 0; >+ const unsigned short eNoSignalError = 1; >+ const unsigned short eNotFoundError = 2; >+ const unsigned short eUnknownError = 3; >+ const unsigned short eInternalError = 4; I've mostly seen NO_ERROR for enum-alikes in IDL. Deferring this call to someone who knows IDL style. >+ long createRequest(in nsPIDOMWindow aWindow, >+ in nsIScriptContext aScriptContext, I don't know what this is for. Need to defer this part of the review. >+ /** >+ * Track an already existing request object. >+ * >+ * @return the request ID. >+ */ >+ long addRequest(in nsIDOMMozSmsRequest aRequest); >+ Why are there separate createRequest/addRequest methods? How can a request be created outside the purview of SmsRequestManager? --> gal for IDL style and nsIScriptContext
Attachment #592179 - Flags: review?(gal)
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL >diff --git a/dom/sms/interfaces/nsISmsRequestManager.idl b/dom/sms/interfaces/nsISmsRequestManager.idl >+ const unsigned short eNoError = 0; >+ const unsigned short eNoSignalError = 1; >+ const unsigned short eNotFoundError = 2; >+ const unsigned short eUnknownError = 3; >+ const unsigned short eInternalError = 4; >+ Also, we need to keep this comment here /** * All SMS related errors that could apply to SmsRequest objects. * Make sure to keep this list in sync with the list in: * embedding/android/GeckoSmsManager.java */
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL I understand addRequest now. I don't like it, but it's not your design. r=me with comment update above
Attachment #592179 - Flags: review?(jones.chris.g) → review+
Attachment #592179 - Flags: review?(gal) → review+
Comment on attachment 596215 [details] [diff] [review] Part 2 (v1): XPCOMtaminate SmsRequestManager Should the request id be long? (for sanity). There is some commented out dead code in SmsRequestManager.h
Comment on attachment 592179 [details] [diff] [review] Part 1 (v1): IDL >+ void notifySmsSendFailed(in long aRequestId, >+ in unsigned short aError); >+ One more issue here: all these |unsigned short| params should be |long|.
Comment on attachment 596215 [details] [diff] [review] Part 2 (v1): XPCOMtaminate SmsRequestManager Shame on you ;). >diff --git a/dom/sms/src/SmsManager.cpp b/dom/sms/src/SmsManager.cpp >+ nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); >+ int requestId; IDL |long| is |PRInt32|. > NS_IMETHODIMP > SmsManager::GetMessageMoz(PRInt32 aId, nsIDOMMozSmsRequest** aRequest) >+ nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); >+ int requestId; And here. >+ nsresult rv = requestManager->CreateRequest(mOwner, mScriptContext, aRequest, >+ &requestId); >+ if (NS_FAILED(rv)) { >+ NS_ERROR("Failed to create the request!"); >+ return rv; >+ } > If I had reviewed this originally, I would have requested that all this gunk be factored out into a helper method. But I won't make you do that for a mechanical rewrite. > nsresult > SmsManager::Delete(PRInt32 aId, nsIDOMMozSmsRequest** aRequest) >- NS_ASSERTION(*aRequest, "The request object must have been created!"); >+ nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); >+ int requestId; And here. >+ nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); >+ int requestId; And here. >diff --git a/dom/sms/src/SmsRequestManager.cpp b/dom/sms/src/SmsRequestManager.cpp >+NS_IMETHODIMP >+SmsRequestManager::AddRequest(nsIDOMMozSmsRequest* aRequest, >+ PRInt32* aRequestId) > { > // TODO: merge with CreateRequest > PRInt32 size = mRequests.Count(); > > // Look for empty slots. > for (PRInt32 i=0; i<size; ++i) { > if (mRequests[i]) { > continue; > } > > mRequests.ReplaceObjectAt(aRequest, i); > return i; Bzzzrt. >+NS_IMETHODIMP > SmsRequestManager::CreateRequest(nsPIDOMWindow* aWindow, > nsIScriptContext* aScriptContext, >- nsIDOMMozSmsRequest** aRequest) >+ nsIDOMMozSmsRequest** aRequest, >+ PRInt32* aRequestId) > { > nsCOMPtr<nsIDOMMozSmsRequest> request = > new SmsRequest(aWindow, aScriptContext); > > PRInt32 size = mRequests.Count(); > > // Look for empty slots. > for (PRInt32 i=0; i<size; ++i) { >@@ -114,17 +95,18 @@ SmsRequestManager::CreateRequest(nsPIDOM > > mRequests.ReplaceObjectAt(request, i); > NS_ADDREF(*aRequest = request); > return i; And here. >+NS_IMETHODIMP >+SmsRequestManager::NotifySmsSendFailed(PRInt32 aRequestId, PRUint16 aError) PRInt32 aError and everywhere below. >diff --git a/dom/sms/src/SmsRequestManager.h b/dom/sms/src/SmsRequestManager.h >+/* > class nsIDOMMozSmsRequest; > class nsPIDOMWindow; > class nsIScriptContext; > class nsIDOMMozSmsMessage; >+*/ > Kill this. r=me with those fixes
Attachment #596215 - Flags: review?(jones.chris.g) → review+
Attachment #596233 - Flags: review?(jones.chris.g) → review+
Comment on attachment 596215 [details] [diff] [review] Part 2 (v1): XPCOMtaminate SmsRequestManager Review of attachment 596215 [details] [diff] [review]: ----------------------------------------------------------------- Removing the ErrorType enum makes me sad :( Seems good to go though. ::: dom/sms/src/SmsCursor.cpp @@ +115,5 @@ > mMessage = nsnull; > static_cast<SmsRequest*>(mRequest.get())->Reset(); > > + nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > + PRInt32 requestId; nit: leave a blank line between those two lines ::: dom/sms/src/SmsManager.cpp @@ +146,5 @@ > > nsCOMPtr<nsIDOMMozSmsRequest> request; > > + nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > + int requestId; nit: blank line between those two lines @@ +222,5 @@ > NS_IMETHODIMP > SmsManager::GetMessageMoz(PRInt32 aId, nsIDOMMozSmsRequest** aRequest) > { > + nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > + int requestId; nit: ditto @@ +243,5 @@ > nsresult > SmsManager::Delete(PRInt32 aId, nsIDOMMozSmsRequest** aRequest) > { > + nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > + int requestId; nit: ditto @@ +293,5 @@ > filter = new SmsFilter(); > } > > + nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > + int requestId; nit: ditto ::: dom/sms/src/SmsRequest.cpp @@ +264,2 @@ > aError.AssignLiteral("InternalError"); > break; Please add a |default| statement with a MOZ_ASSERT. ::: dom/sms/src/SmsRequestManager.h @@ +47,5 @@ > class nsIDOMMozSmsRequest; > class nsPIDOMWindow; > class nsIScriptContext; > class nsIDOMMozSmsMessage; > +*/ Please, remove this block if not needed. Don't keep it commented. ::: embedding/android/GeckoSmsManager.java @@ +328,5 @@ > > /* > + * Make sure that the following error codes are in sync with the ones > + * defined in dom/sms/interfaces/nsISmsRequestManager.idl. They are owned > + * owned by the DOM. s/DOM/interface/
Blocks: 727319
Attached patch Part 1 (v2): IDL (deleted) — Splinter Review
Addressed review comments.
Attachment #592179 - Attachment is obsolete: true
Attached patch Part 2 (v2): XPCOMtaminate SmsRequestManager (obsolete) (deleted) — Splinter Review
Addressed review comments.
Attachment #596215 - Attachment is obsolete: true
Target Milestone: mozilla12 → ---
> Push backed out for build failures on Android: Also later failed on Windows.
Attached patch Part 4 (v1): Android bits (deleted) — Splinter Review
Yeah, so, I kinda forgot to change Android's usage of SmsRequestManager. Pretty mechanical, just like the rest. In the old fashion r?cjones with potential fallback to mounir.
Attachment #598450 - Flags: review?(jones.chris.g)
I had to change the NO_ERROR constant to SUCCESS_NO_ERROR to avoid breakage on Windows (where apparently there's a #define NO_ERROR that breaks things in unexpected ways.) Stoopid Windoze.
Attachment #597276 - Attachment is obsolete: true
Attachment #598450 - Flags: review?(jones.chris.g) → review+
Comment on attachment 598450 [details] [diff] [review] Part 4 (v1): Android bits Review of attachment 598450 [details] [diff] [review]: ----------------------------------------------------------------- ::: widget/android/AndroidJNI.cpp @@ +344,5 @@ > obs->NotifyObservers(message, kSmsSentObserverTopic, nsnull); > > if (mProcessId == 0) { // Parent process. > + nsCOMPtr<nsISmsRequestManager> requestManager; > + = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); You probably want: nsCOMPtr<nsISmsRequestManager> requestManager = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); I assume you do. In addition, |do_GetService| can return |nsnull| so you should check the result. You are doing this mistake in a lot of places after. I will not point all of them.
Try run for eb9207c37e3a is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=eb9207c37e3a Results (out of 14 total builds): success: 11 failure: 3 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/pweitershausen@mozilla.com-eb9207c37e3a
(In reply to Mounir Lamouri (:volkmar) (:mounir) from comment #24) > Comment on attachment 598450 [details] [diff] [review] > Part 4 (v1): Android bits > > Review of attachment 598450 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: widget/android/AndroidJNI.cpp > @@ +344,5 @@ > > obs->NotifyObservers(message, kSmsSentObserverTopic, nsnull); > > > > if (mProcessId == 0) { // Parent process. > > + nsCOMPtr<nsISmsRequestManager> requestManager; > > + = do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > > You probably want: > nsCOMPtr<nsISmsRequestManager> requestManager = > do_GetService(SMS_REQUEST_MANAGER_CONTRACTID); > > I assume you do. *cough* yes. Thanks for noticing... It was late. :) > In addition, |do_GetService| can return |nsnull| so you should check the > result. Good point. I will do that.
Try run for 02a950d519e7 is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=02a950d519e7 Results (out of 14 total builds): success: 11 failure: 3 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/pweitershausen@mozilla.com-02a950d519e7
Try run for f8c7bb9ad347 is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=f8c7bb9ad347 Results (out of 3 total builds): success: 3 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/pweitershausen@mozilla.com-f8c7bb9ad347
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: