Open Bug 1602940 Opened 6 months ago Updated 4 months ago

Expose nsIUUIDGenerator on Services.jsm

Categories

(Toolkit :: General, task, P3)

task

Tracking

()

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

As per summary. Services.uuid seems like it should work.

Priority: -- → P3
See Also: → 1603144
Assignee: nobody → ato
Status: NEW → ASSIGNED
Priority: P3 → P1
Whiteboard: [puppeteer-beta-reserve]

By adding a shorthand for nsIUUIDGenerator to Services.jsm we can
avoid a lot of boilerplate code for a frequently used service.

Using nsIUUIDGenerator from JavaScript today normally looks something
like this:

const uuidGen = Cc["mozilla.org/uuid-generator;1"]
      .getService(Ci.nsIUUIDGenerator);
    uuidGen.generateUUID();

Which with this patch now be shortened to:

Services.uuid.generateUUID();

By adding a new generate() method returning a string directly from
nsIUUIDGenerator we are able to avoid many cumbersome string coercions.

In JavaScript, string representations of UUIDs are more often than
not the requirement. This is usually to ease serialisation.

We may want to consider renaming nsIUUIDGenerator.generateUUID()
in the future to generateIDPtr() or similar, but this would require
a larger refactoring due to existing usage. It would be advisable
to make JS usage move to generate() first, before attempting a
rewrite of the C++ consumers.

Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta-mvp]
Whiteboard: [puppeteer-beta-mvp] → [puppeteer-beta-reserve]

That shouldn't actually block beta.

Assignee: ato → nobody
Status: ASSIGNED → NEW
Priority: P1 → P3
Whiteboard: [puppeteer-beta-reserve]
You need to log in before you can comment on or make changes to this bug.