Closed
Bug 1188976
Opened 10 years ago
Closed 10 years ago
Hoist MozPromise into xpcom/
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla43
| Tracking | Status | |
|---|---|---|
| firefox43 | --- | fixed |
People
(Reporter: bholley, Assigned: bholley)
References
(Blocks 1 open bug)
Details
Attachments
(4 files, 1 obsolete file)
|
1005 bytes,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
|
21.42 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
1.22 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
8.89 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
Getting a bug on file for this task specifically.
| Assignee | ||
Comment 1•10 years ago
|
||
Nathan volunteered to have a look at dom/media/MozPromise.h in advance of the hoisting to see if there are any changes he'd like.
Flags: needinfo?(nfroyd)
Comment 2•10 years ago
|
||
Couple of thoughts:
- Are API examples reasonable? The comment here:
http://mxr.mozilla.org/mozilla-central/source/dom/media/MozPromise.h#71
does a decent job of explaining things, but there's a lot of template magic going on below that, and it's not obvious what pieces to use. I remember seeing code examples at Whistler, and those helped me get my head around this brave new promise-laden world.
Or it might be reasonable to put documentation comments on key public methods: MozPromise::Then might benefit from that, to help cut through the template goo...maybe others. It's also not obvious to me how subclassing MozPromise works--marking things as |protected| suggests that writing subclasses is a reasonable thing, yes?
- Is there a reason ProxyMediaCall (which probably needs to be renamed in the uplift) doesn't use variadic templates? We now have mozilla::Tuple, which makes the MethodCallWith*Args classes superfluous.
- Over in bug 1179451 comment 32, it looks like there are some small refcounting inefficiencies with MozPromiseRequestHolder...and maybe other things that take raw pointers and store them in nsRefPtr. Those sorts of things would be nice to clean up with nsRefPtr<>&& overloads or replacements...
Flags: needinfo?(nfroyd)
Comment 3•10 years ago
|
||
We should probably have a page on MDN documenting how to use MozPromises, similar to other key APIs such as nsHashTable, XPCOM string guide, WebIDL, etc.
| Assignee | ||
Updated•10 years ago
|
| Assignee | ||
Comment 4•10 years ago
|
||
Not sure how this didn't get fixed before.
Attachment #8648827 -
Flags: review+
| Assignee | ||
Comment 5•10 years ago
|
||
Attachment #8648828 -
Flags: review?(nfroyd)
| Assignee | ||
Comment 6•10 years ago
|
||
Note sure if there's a better way to do the ApplyAsArgs stuff.
Attachment #8648829 -
Flags: review?(nfroyd)
| Assignee | ||
Comment 7•10 years ago
|
||
Attachment #8648831 -
Flags: review?(nfroyd)
| Assignee | ||
Comment 8•10 years ago
|
||
ttps://treeherder.mozilla.org/#/jobs?repo=try&revision=fc4902297dc9
Updated•10 years ago
|
Attachment #8648828 -
Flags: review?(nfroyd) → review+
Comment 9•10 years ago
|
||
Comment on attachment 8648829 [details] [diff] [review]
Part 3 - Use mozilla::Tuple for InvokeAsync. v1
Review of attachment 8648829 [details] [diff] [review]:
-----------------------------------------------------------------
I think this is mostly right, but I'm having a hard time seeing through the stuff below.
::: dom/media/MozPromise.h
@@ +869,2 @@
> {
> + return ((*aThisVal).*aMethod)(Get<0>(aArgs), Get<1>(aArgs), Get<2>(aArgs), Get<3>(aArgs));
This is not how you want to do things with Tuple. Take a look at:
http://mxr.mozilla.org/mozilla-central/source/media/mtransport/runnable_utils.h#60
and the implementation of the WrapRunnable* classes below that.
You may also find:
http://mxr.mozilla.org/mozilla-central/source/mfbt/IndexSequence.h#11
enlightening.
@@ +897,5 @@
> + typedef nsRefPtr<PromiseType>(ThisType::*MethodType)(ArgTypes...);
> + MethodCall(MethodType aMethod, ThisType* aThisVal, Tuple<ArgTypes...> aArgs)
> + : mMethod(aMethod)
> + , mThisVal(aThisVal)
> + , mArgs(aArgs)
I think you want to make this:
MethodCall(MethodType aMethod, ThisType* aThisVal, ArgTypes... aArgs)
: mMethod(aMethod)
, mThisVal(aThisVal)
, mArgs(aArgs...)
possibly with a mozilla::Forward<> thrown in on mArgs.
@@ +945,5 @@
> {
> + typedef detail::MethodCall<PromiseType, ThisType, ArgTypes...> MethodCallType;
> + typedef detail::ProxyRunnable<PromiseType, ThisType, ArgTypes...> ProxyRunnableType;
> +
> + MethodCallType* methodCall = new MethodCallType(aMethod, aThisVal, Tuple<ArgTypes...>(aArgs...));
You can avoid leaking the internal implementation details here by just saying:
new MethodCallType(aMethod, aThisVal, aArgs...);
Attachment #8648829 -
Flags: review?(nfroyd) → feedback+
Updated•10 years ago
|
Attachment #8648831 -
Flags: review?(nfroyd) → review+
| Assignee | ||
Comment 10•10 years ago
|
||
Thanks for the quick feedback!
Attachment #8648829 -
Attachment is obsolete: true
Attachment #8648870 -
Flags: review?(nfroyd)
| Assignee | ||
Comment 11•10 years ago
|
||
Comment 12•10 years ago
|
||
Comment on attachment 8648870 [details] [diff] [review]
Part 3 - Use mozilla::Tuple for InvokeAsync. v2
Review of attachment 8648870 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/media/MozPromise.h
@@ +865,5 @@
>
> namespace detail {
>
> +template<typename ReturnType, typename ThisType, typename... ArgTypes, size_t... Indices>
> +ReturnType MethodCallInvokeHelper(ReturnType(ThisType::*aMethod)(ArgTypes...), ThisType* aThisVal,
Nit: please break this between |ReturnType| and |MethodCallInvokeHelper|.
Attachment #8648870 -
Flags: review?(nfroyd) → review+
Comment 13•10 years ago
|
||
Comment 14•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e7dacf8fabcc
https://hg.mozilla.org/mozilla-central/rev/da9889d86074
https://hg.mozilla.org/mozilla-central/rev/0cd60a14316f
https://hg.mozilla.org/mozilla-central/rev/bd4464cd4be8
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Comment 15•10 years ago
|
||
Depends on: 1332779
You need to log in
before you can comment on or make changes to this bug.
Description
•