Refactor fake services so it's easier to add more

RESOLVED FIXED in 1.2

Status

()

RESOLVED FIXED
9 years ago
2 months ago

People

(Reporter: zpao, Assigned: zpao)

Tracking

unspecified
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Fennec doesn't have some browser specific services, so we need to fake them. Private browsing is already there, but we'll need to add more (e.g. SessionStore).

So to prevent Utils.lazySvc from becoming bloated by putting the services there, they should be elsewhere.
Created attachment 429239 [details] [diff] [review]
Patch v0.1

I put fakeServices in Utils, but it can be moved.
Attachment #429239 - Flags: review?(edilee)
Comment on attachment 429239 [details] [diff] [review]
Patch v0.1

>+++ b/source/modules/util.js
>       if (!Cc[cid]) {
>+        if (cid in fakeServices)
>+          svc = fakeServices[cid];
Eh.. I would just do svc = FakeSvc[cid]
>         if (svc == null)
>           log.warn("Component " + cid + " doesn't exist on this platform.");
And svc == null would check okay. But then it'll trigger a strict warning :p
I suppose the if check is okay.

>+  fakeServices: {
Just make this a top level FakeSvc object, but don't export it.
Attachment #429239 - Flags: review?(edilee) → review+
(In reply to comment #2)
> (From update of attachment 429239 [details] [diff] [review])
> >+++ b/source/modules/util.js
> >       if (!Cc[cid]) {
> >+        if (cid in fakeServices)
> >+          svc = fakeServices[cid];
> Eh.. I would just do svc = FakeSvc[cid]

I can do that.

> >         if (svc == null)
> >           log.warn("Component " + cid + " doesn't exist on this platform.");
> And svc == null would check okay. But then it'll trigger a strict warning :p
> I suppose the if check is okay.

So turns out that strict warnings won't show up during assignment. So I think we could do without any issues.
> svc = FakeSvc[cid];
> if (!svc)
Pushed http://hg.mozilla.org/labs/weave/rev/87f9860d8e5a
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
http://hg.mozilla.org/labs/weave/rev/9e4817ec4791
Revert svc/svc == null change from 87f9860d8e5a.
Component: Firefox Sync: Backend → Sync
Product: Cloud Services → Firefox
You need to log in before you can comment on or make changes to this bug.