Closed Bug 1627540 Opened 4 years ago Closed 4 years ago

Expose Region.getRegion as a (idl exposed) Service

Categories

(Firefox :: Search, task, P3)

task
Points:
5

Tracking

()

RESOLVED FIXED
Firefox 80
Iteration:
79.2 - June 15 - June 28
Tracking Status
firefox80 --- fixed

People

(Reporter: daleharvey, Assigned: daleharvey)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

No description provided.
Priority: -- → P3

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

Flags: needinfo?(dtownsend)

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.

Flags: needinfo?(dtownsend)
Points: --- → 5
Assignee: nobody → dharvey
Iteration: --- → 78.1 - May 4 - May 17
Iteration: 78.1 - May 4 - May 17 → 78.2 - May 18 - May 31
Iteration: 78.2 - May 18 - May 31 → 79.2 - June 15 - June 28
Attachment #9157130 - Attachment description: Bug 1627540 - Add idl for C++ access. → Bug 1627540 - Add an IDL for Region.jsm so it can be accessed via C++

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

Flags: needinfo?(dtownsend)

(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.

Flags: needinfo?(dtownsend)
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
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: