Closed Bug 952084 Opened 11 years ago Closed 11 years ago

Porting nsIDOMMozConnection to WebIDL

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: baku, Assigned: baku)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 4 obsolete files)

      No description provided.
Attached patch mozconnection.patch (obsolete) (deleted) — Splinter Review
Attachment #8350016 - Flags: review?(Ms2ger)
Attached patch mozconnection.patch (obsolete) (deleted) — Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=fdb8357759e3

I had to use: 
NS_IMPL_ADDREF_INHERITED(network::Connection, nsDOMEventTargetHelper)

because otherwise the hashtable used by GetBloatEntry gets confused.
Attachment #8350016 - Attachment is obsolete: true
Attachment #8350016 - Flags: review?(Ms2ger)
Attachment #8350022 - Flags: review?(Ms2ger)
Comment on attachment 8350022 [details] [diff] [review]
mozconnection.patch

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

Same comment about namespacing.

f- for the unrestricted double bit; please write a test that would have asserted in the case that returns infinity. (If we don't assert in that case, please make sure to make us assert.)

::: dom/base/Navigator.cpp
@@ +1269,4 @@
>  {
> +  nsRefPtr<network::Connection> connection = GetMozConnection();
> +  nsCOMPtr<nsINetworkProperties> properties =
> +    static_cast<nsINetworkProperties*>(connection.get());

Shouldn't need the cast, and you should be able to directly assign the result of GetMozConnection() into this.

::: dom/network/src/Connection.cpp
@@ +30,5 @@
>  
>  // Don't use |Connection| alone, since that confuses nsTraceRefcnt since
>  // we're not the only class with that name.
> +NS_IMPL_ADDREF_INHERITED(network::Connection, nsDOMEventTargetHelper)
> +NS_IMPL_RELEASE_INHERITED(network::Connection, nsDOMEventTargetHelper)

Why change this?

::: dom/webidl/MozConnection.webidl
@@ +2,5 @@
> + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
> + * You can obtain one at http://mozilla.org/MPL/2.0/.
> + */
> +
> +interface MozConnection : EventTarget {

Do we want to pref this on dom.network.enabled?

@@ +3,5 @@
> + * You can obtain one at http://mozilla.org/MPL/2.0/.
> + */
> +
> +interface MozConnection : EventTarget {
> +  readonly attribute double  bandwidth;

Needs to be 'unrestricted double'
Attachment #8350022 - Flags: review?(Ms2ger) → feedback-
(In reply to :Ms2ger from comment #4)
> ::: dom/webidl/MozConnection.webidl
> @@ +2,5 @@
> > + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
> > + * You can obtain one at http://mozilla.org/MPL/2.0/.
> > + */
> > +
> > +interface MozConnection : EventTarget {
> 
> Do we want to pref this on dom.network.enabled?

Yes. We shouldn't pollute the global name space blindly.
Blocks: stdglobal
Attached patch mozconnection.patch (obsolete) (deleted) — Splinter Review
I don't understand what you meant with the assertion for bandwidth value when infinity. Infinity is an acceptable value for this property.
Is the test we have good enough?
Attachment #8350022 - Attachment is obsolete: true
Attachment #8355181 - Flags: review?(Ms2ger)
Comment on attachment 8355181 [details] [diff] [review]
mozconnection.patch

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

Looks good, I think, but I don't have time for a full review, sorry.

::: dom/base/Navigator.cpp
@@ +1269,3 @@
>  {
> +  nsRefPtr<network::Connection> connection = GetMozConnection();
> +  nsCOMPtr<nsINetworkProperties> properties = connection.get();

Should be able to just assign GetMozConnection() into this
Attachment #8355181 - Flags: review?(Ms2ger) → feedback+
Attached patch mozconnection.patch (obsolete) (deleted) — Splinter Review
Ehsan, can you review this patch?
Attachment #8355181 - Attachment is obsolete: true
Attachment #8359711 - Flags: review?(ehsan)
Comment on attachment 8359711 [details] [diff] [review]
mozconnection.patch

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

r=me

::: dom/network/src/Connection.cpp
@@ +4,5 @@
>   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
>  
>  #include <limits>
>  #include "mozilla/Hal.h"
>  #include "Connection.h"

Nit: mozilla/dom/network/Connection.h

::: dom/webidl/MozConnection.webidl
@@ +2,5 @@
> + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
> + * You can obtain one at http://mozilla.org/MPL/2.0/.
> + */
> +
> +[Pref="dom.network.enabled"]

Because of this change, you need to modify the MozConnection entry in test_interfaces.html and get r+ from a DOM peer on that.
Attachment #8359711 - Flags: review?(ehsan) → review+
Attached patch mozconnection.patch (deleted) — Splinter Review
https://tbpl.mozilla.org/?tree=Try&rev=09dfdff4250f

Green on try.
Attachment #8359711 - Attachment is obsolete: true
Attachment #8360054 - Flags: review?(bzbarsky)
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #9)
> Because of this change, you need to modify the MozConnection entry in
> test_interfaces.html and get r+ from a DOM peer on that.

Actually it will not be needed because dom.network.enabled is enabled everywhere.
(In reply to comment #12)
> (In reply to :Ehsan Akhgari (needinfo? me!) from comment #9)
> > Because of this change, you need to modify the MozConnection entry in
> > test_interfaces.html and get r+ from a DOM peer on that.
> 
> Actually it will not be needed because dom.network.enabled is enabled
> everywhere.

That is probably a bug.  We should disable it on non-b2g I think.  Filed bug 959845 for that.
Comment on attachment 8360054 [details] [diff] [review]
mozconnection.patch

r=me
Attachment #8360054 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/5302ee051b86
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
I think I missed this before in the review, but the spec says that the Connection interface should be [NoInterfaceObject].  Andrea, can you please do that in a follow-up?  Thanks!
(In reply to :Ehsan Akhgari (needinfo? me!) from comment #17)
> I think I missed this before in the review, but the spec says that the
> Connection interface should be [NoInterfaceObject].  Andrea, can you please
> do that in a follow-up?  Thanks!

See the duped bug 916606.  Mounir (the spec editor of the Network Information API) said that the spec is simply wrong.
Blocks: 960945
emk, so can I just close bug 960945 as invalid?
BTW: sorry for this patch, I didn't see your patches when I started.
(In reply to Andrea Marchesini (:baku) from comment #19)
> emk, so can I just close bug 960945 as invalid?
> BTW: sorry for this patch, I didn't see your patches when I started.

Please ask Mounir. I just passed on a message.
Jonas?
Flags: needinfo?(jonas)
What happened to the assertion I requested in comment #4?
Flags: needinfo?(amarchesini)
(In reply to :Ms2ger from comment #22)
> What happened to the assertion I requested in comment #4?

Almost forgot. follow up bug 964041.
Blocks: 964041
Flags: needinfo?(amarchesini)
I think I'd prefer to make this a [NoInterfaceObject] on this interface. Simply because this API is heavily in flux and the less we expose to the web the better.

However I don't think it's particularly important. This API is only implemented on Android and should be completely disabled everywhere else (that's a separate bug), so no matter what it won't have a large effect what we do here.
Flags: needinfo?(jonas)
Disabling this API on non-Android platforms is bug 959845.
Blocks: 960426
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: