Expose Region.getRegion as a (idl exposed) Service
Categories
(Firefox :: Search, task, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: daleharvey, Assigned: daleharvey)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
Hi Mossop
We are looking to replace consumers of the browser.search.region pref to call a JS module instead as part of (https://bugzilla.mozilla.org/show_bug.cgi?id=1617907). Most consumers are in JS, but we have one caller in C++ @ https://searchfox.org/mozilla-central/source/dom/payments/PaymentRequest.cpp#79, I just wanted to check if the best way is to be creating a standard idl (like the SearchService itself) or if there is a better way these days
Cheers
Comment 2•4 years ago
|
||
Yes, a singleton in a JSM is preferred for JS access and C++ can only talk to JS code via an idl (without doing direct spidermonkey API calls which ... don't).
The C++ caller is a bit annoying as you'll have to have a bunch of boilerplate in the JSM to support it. Worth considering whether you already have an XPCOM component defined in JS that you could add this property to for the C++ to use. Otherwise your JSM will need to export both the singleton object that JS will use and a XPCOM component constructor for the C++ to use.
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 4•4 years ago
|
||
Hey Dave, I was wondering if you were able to give me a hand again. I have this mostly working @ https://phabricator.services.mozilla.com/D79914, the compiles fine however GetHome
is returning "", you mentioned some boilerplate needed in the .jsm but I cant find any examples of what I need, been using https://searchfox.org/mozilla-central/source/netwerk/ipc/DocumentLoadListener.cpp#1282 as an example to copy from but cant see anything that does anything to hook it up any pointers as to whats missing here? Thanks so much
Comment 5•4 years ago
|
||
(In reply to Dale Harvey (:daleharvey) from comment #4)
Hey Dave, I was wondering if you were able to give me a hand again. I have this mostly working @ https://phabricator.services.mozilla.com/D79914, the compiles fine however
GetHome
is returning "", you mentioned some boilerplate needed in the .jsm but I cant find any examples of what I need, been using https://searchfox.org/mozilla-central/source/netwerk/ipc/DocumentLoadListener.cpp#1282 as an example to copy from but cant see anything that does anything to hook it up any pointers as to whats missing here? Thanks so much
Looks like you're missing the second argument to go_ImportModule: https://searchfox.org/mozilla-central/rev/2c1092dc68c63f7bad6da6a03c5883a5ab5ff2ca/js/xpconnect/loader/nsImportModule.h#71-87. I'm sort of surprised that that isn't crashing or returning a failure rv, might be a bug there.
Pushed by dharvey@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/07c5e9aa2686 Add an IDL for Region.jsm so it can be accessed via C++ r=mossop
Comment 7•4 years ago
|
||
bugherder |
Description
•