Closed
Bug 1053732
Opened 10 years ago
Closed 10 years ago
B2G NFC: Use dictionary in MozNDEFRecord Constructor
Categories
(Firefox OS Graveyard :: NFC, defect)
Tracking
(b2g-v2.2 fixed)
RESOLVED
FIXED
2.1 S4 (12sep)
Tracking | Status | |
---|---|---|
b2g-v2.2 | --- | fixed |
People
(Reporter: allstars.chh, Assigned: allstars.chh)
References
Details
Attachments
(4 files, 2 obsolete files)
6.13 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
8.84 KB,
patch
|
dimi
:
review+
|
Details | Diff | Splinter Review |
46 bytes,
text/x-github-pull-request
|
benfrancis
:
review+
arcturus
:
review+
alive
:
review+
|
Details | Review |
5.73 KB,
patch
|
allstars.chh
:
review+
|
Details | Diff | Splinter Review |
In Bug 960510 we make the type, id and payload parameters optional in MozNDEFRecord Constructor, part of this also because W3C NFC API also make them optional [1].
So we could simply call 'new MozNDEFRecord(tnf)' for the the EMPTY NDEFREcord.
However in most cases the 'id' paramter is null, so many developers will do
new MozNDEFRecord(tnf, typeArray, undefined, payloadArray) or
new MozNDEFREcord(tnf, typeArray, new Uint8Array(0), payloadArray).
But the better way is to make it nullable, so we can do
new MozNDEFRecord(tnf, typeArray, null, payloadArray);
So I am wondering should we make these parameters Optional and Nullable?
[Constructor(octet tnf, optional Uint8Array? type, optional Uint8Array? id, optional Uint8Array? payload)]
interface MozNDEFRecord
Or simply Nullable is enough?
[Constructor(octet tnf, Uint8Array? type, Uint8Array? id, Uint8Array? payload)]
interface MozNDEFRecord
Request feedback from smuag for this,
@smaug, can you provide some suggestions for us?
Thank you.
[1]: http://w3c.github.io/nfc/proposals/common/nfc.html#ndefrecord-interface
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(bugs)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → allstars.chh
Comment 1•10 years ago
|
||
I would put all the optional stuff to a dictionary.
dictionary NDEFRecordOptions {
optional Uint8Array? type,
optional Uint8Array? id,
optional Uint8Array? payload
}
[Constructor(TNF tfn, optional NDEFRecordOptions options)]
interface MozNDEFRecord {
...
}
then one could say: new MozNDEFRecord(some_tnf);
or: new MozNDEFRecord(some_tnf, { palyload: some_array})
etc.
Flags: needinfo?(bugs)
Comment 2•10 years ago
|
||
Oh, those properties in the dictionary don't need to be nullable, I think, so drop '?'.
Properties in the dictionary are optional by default.
Assignee | ||
Comment 3•10 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #1)
> I would put all the optional stuff to a dictionary.
>
> dictionary NDEFRecordOptions {
> optional Uint8Array? type,
> optional Uint8Array? id,
> optional Uint8Array? payload
> }
>
> [Constructor(TNF tfn, optional NDEFRecordOptions options)]
> interface MozNDEFRecord {
> ...
> }
>
> then one could say: new MozNDEFRecord(some_tnf);
> or: new MozNDEFRecord(some_tnf, { palyload: some_array})
> etc.
Thanks smaug, this is even better.
I'd work on this proposal.
But maybe I will move tnf into the dict as well, and let it have default value.
dictionary NDEFRecordOptions {
octet tnf = 0; // default to tnf_empty
optional Uint8Array type;
optional Uint8Array id;
optional Uint8Array payload;
};
Also I noticed you used 'TNF' in the constructor, I'd check if we should use use enum for 'tnf' and file another bug for this.
Assignee | ||
Updated•10 years ago
|
Summary: B2G NFC: Make type, id and payload null in MozNDEFRecord Constructor → B2G NFC: Use dictionary in MozNDEFRecord Constructor
Assignee | ||
Comment 4•10 years ago
|
||
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Comment 6•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Attachment #8475726 -
Flags: review?(bugs)
Assignee | ||
Updated•10 years ago
|
Attachment #8475727 -
Flags: review?(bugs)
Assignee | ||
Updated•10 years ago
|
Attachment #8475728 -
Flags: review?(dlee)
Assignee | ||
Comment 7•10 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=e40b11ba22e7
Will send Gaia PR once Gecko patches are r+.
Updated•10 years ago
|
Attachment #8475728 -
Flags: review?(dlee) → review+
Assignee | ||
Comment 8•10 years ago
|
||
(In reply to Yoshi Huang[:allstars.chh] from comment #3)
> Also I noticed you used 'TNF' in the constructor, I'd check if we should use
> use enum for 'tnf' and file another bug for this.
Filed Bug 1055560
Updated•10 years ago
|
Attachment #8475726 -
Flags: review?(bugs) → review+
Comment 9•10 years ago
|
||
Comment on attachment 8475727 [details] [diff] [review]
Part 2: NfcService update
Oh, wait, why we need both
MozNDEFRecordOptions and NDEFRecord dictionaries?
which both have the same properties, just a bit different types
(some nullable)
We should be able to have just one, which works in all the needed cases.
Attachment #8475727 -
Flags: review?(bugs) → review-
Assignee | ||
Comment 10•10 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #9)
> We should be able to have just one, which works in all the needed cases.
Hi Smaug,
Yeah, Kyle also asked this when he reviewed it.
https://bugzilla.mozilla.org/show_bug.cgi?id=933588#c32
=== Quoted from Kyle ===
::: dom/system/gonk/NfcOptions.h
@@ +8,5 @@
> +#include "mozilla/dom/NfcOptionsBinding.h"
> +
> +namespace mozilla {
> +
> +struct NDEFRecordStruct
Why can't we just use the generated DOM dictionaries here? Is it because of the JS values?
=== End of Quote. ===
However I tried in https://bugzilla.mozilla.org/show_bug.cgi?id=933588#c37
Because the constructor of generated DOM dict is private, to pass it to nsRunnable I have to construct it manually again.
Or there's any suggestion to pass it to nsRunnable?
Thanks
Assignee | ||
Comment 11•10 years ago
|
||
Kyle is asking in the header file but Smaug is asking on the WebIDL.
I'll file another bug for removing NDEFRecord from NfcOptions.webidl.
Assignee | ||
Comment 12•10 years ago
|
||
Also updated NfcContentHelper as record.id could be null, and the value in our dict cannot be nullable.
Attachment #8475727 -
Attachment is obsolete: true
Assignee | ||
Comment 13•10 years ago
|
||
Comment on attachment 8479695 [details] [diff] [review]
Part 2: NfcService update v2.
Review of attachment 8479695 [details] [diff] [review]:
-----------------------------------------------------------------
Hi, Smaug
Sorry for asking wrong question to you before.
Now this patch has addressed your Comment 9.
Could you help to review this again for me ?
Thank you.
Attachment #8479695 -
Flags: review?(bugs)
Updated•10 years ago
|
Attachment #8479695 -
Flags: review?(bugs) → review+
Assignee | ||
Updated•10 years ago
|
Blocks: b2g-nfc-privilege
Assignee | ||
Comment 14•10 years ago
|
||
Assignee | ||
Comment 15•10 years ago
|
||
Comment on attachment 8480419 [details] [review]
Gaia Pull Request
Gaia PR for updating MozNDEFRecord.
@Ben, could you help review Part 1: Browser app change for me?
@Francisco, could you help to review Part 2: Contacts app change ?
And
@Alive, could you help to review Part 3: System app change ?
Thank you
Attachment #8480419 -
Flags: review?(francisco)
Attachment #8480419 -
Flags: review?(bfrancis)
Attachment #8480419 -
Flags: review?(alive)
Comment 16•10 years ago
|
||
Comment on attachment 8480419 [details] [review]
Gaia Pull Request
Is this for 2.0? The browser app is being deleted in 2.1.
Attachment #8480419 -
Flags: review?(bfrancis) → review+
Assignee | ||
Comment 17•10 years ago
|
||
(In reply to Ben Francis [:benfrancis] from comment #16)
> Comment on attachment 8480419 [details] [review]
> Gaia Pull Request
>
> Is this for 2.0? The browser app is being deleted in 2.1.
No, not for 2.0. It's should be landed on the master(currently it's 2.1)
I don't know when the browser app will be removed, if it's removed when I try to merge this, I'll remove this commit.
Thanks
Updated•10 years ago
|
Attachment #8480419 -
Flags: review?(alive) → review+
Comment 18•10 years ago
|
||
Comment on attachment 8480419 [details] [review]
Gaia Pull Request
Contact change looking good, thx!
Attachment #8480419 -
Flags: review?(francisco) → review+
Assignee | ||
Comment 19•10 years ago
|
||
rebase
Attachment #8479695 -
Attachment is obsolete: true
Attachment #8484755 -
Flags: review+
Assignee | ||
Comment 20•10 years ago
|
||
Assignee | ||
Comment 21•10 years ago
|
||
Update Gaia PR
Gaia Try result
https://tbpl.mozilla.org/?rev=52f361805243167c3b79838074e0d7448b063f68&tree=Gaia-Try
Assignee | ||
Comment 22•10 years ago
|
||
Add checkin-needed for Gaia commit since I'd like to land Gaia part only when Gecko part lands in m-c.
Thanks
Keywords: checkin-needed
Comment 23•10 years ago
|
||
Comment 24•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/f7dd432d3702
https://hg.mozilla.org/mozilla-central/rev/524bf2f003b0
https://hg.mozilla.org/mozilla-central/rev/443b75b59926
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Assignee | ||
Updated•10 years ago
|
No longer blocks: b2g-nfc-privilege
Assignee | ||
Updated•10 years ago
|
Blocks: b2g-nfc-privilege
You need to log in
before you can comment on or make changes to this bug.
Description
•