Re: Finalizer for WebIDL object backed by JS impl of an XPCOM interface

2017-08-11 Thread Boris Zbarsky

On 8/11/17 5:59 AM, Henri Sivonen wrote:

The action is decrementing a counter on the inner window, so it's
sufficient if the C++ destructor knows if it needs to decrement the
counter and knows which window.

The concrete situation is described in
https://bugzilla.mozilla.org/show_bug.cgi?id=1378123#c9


Ah, ok.  Yeah, in this case the "have it own a C++ object" approach is 
reasonable.  And PeerConnectionImpl definitely fits the bill in your 
specific use case.


-Boris


___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Finalizer for WebIDL object backed by JS impl of an XPCOM interface

2017-08-11 Thread Henri Sivonen
On Wed, Aug 9, 2017 at 9:39 PM, Boris Zbarsky  wrote:
> On 8/9/17 1:55 PM, Henri Sivonen wrote:
>>
>> I'm thinking of introducing a C++-implemented XPCOM object that the
>> JS-implemented XPCOM object can hold a reference to and that has a C++
>> destructor that does what I want.
>
>
> Does that mean your action doesn't depend on which exact JS object got
> collected, or that you can encode that information in some way without
> referencing the JS object?

The action is decrementing a counter on the inner window, so it's
sufficient if the C++ destructor knows if it needs to decrement the
counter and knows which window.

The concrete situation is described in
https://bugzilla.mozilla.org/show_bug.cgi?id=1378123#c9

-- 
Henri Sivonen
hsivo...@hsivonen.fi
https://hsivonen.fi/
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Finalizer for WebIDL object backed by JS impl of an XPCOM interface

2017-08-09 Thread Boris Zbarsky

On 8/9/17 1:55 PM, Henri Sivonen wrote:

I'm thinking of introducing a C++-implemented XPCOM object that the
JS-implemented XPCOM object can hold a reference to and that has a C++
destructor that does what I want.


Does that mean your action doesn't depend on which exact JS object got 
collected, or that you can encode that information in some way without 
referencing the JS object?


-Boris
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Finalizer for WebIDL object backed by JS impl of an XPCOM interface

2017-08-09 Thread Henri Sivonen
On Tue, Aug 8, 2017 at 1:26 PM, Henri Sivonen  wrote:
> What's the correct way to take an action right before a JS-implemented
> XPCOM object that acts as the implementation for a WebIDL interface
> gets garbage collected?

Taking action soon after GC would work for me as well.

I'm thinking of introducing a C++-implemented XPCOM object that the
JS-implemented XPCOM object can hold a reference to and that has a C++
destructor that does what I want.

But is there a simpler way?

-- 
Henri Sivonen
hsivo...@hsivonen.fi
https://hsivonen.fi/
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform