Closed Bug 1079198 Opened 5 years ago Closed 3 years ago

Refactor MozLoopService.jsm

Categories

(Hello (Loop) :: Client, defect, P4)

defect
Points:
3

Tracking

(Not tracked)

RESOLVED INCOMPLETE
Blocking Flags:
backlog tech-debt

People

(Reporter: mikedeboer, Unassigned)

References

Details

(Whiteboard: [tech-debt])

It's starting to look like a monstrous beast with a scary head and a loooooooong tail.

So why not chop it into smaller pieces and perhaps - even - document _at least_ the public API?

Who's with me?

Ps.: consistent code formatting and moar use of Task.async() would make me yay even more!
Flags: firefox-backlog+
Flags: qe-verify?
Flags: qe-verify? → qe-verify-
OS: Mac OS X → All
Hardware: x86 → All
My main complaints with MozLoopService.jsm are: 
* the globals e.g. gHawkClient which should be members on an object e.g. MozLoopServiceInternal so they're easier to access from tests
* the separation between MozLoopService and MozLoopServiceInternal is a footgun because people get |this| mixed up (e.g. bug 1071835), makes things harder to test and doesn't actually prevent access to internal state. Properties on the current *Internal can be prefixed with an underscore instead.

Note that more files == more compartments so we shouldn't split it too much.

I think it would be okay to do this once we're done development on 35 (i.e. 36+) including all uplifts otherwise it will cause uplift hell and slow us down.
The various bits of registration code need to be cleaned up (at least renamed) as they are quite confusing:
register => promiseRegisteredWithServers => onPushRegistered => registerWithLoopServer

The middle two above are related to the push server but the 2nd doesn't mention push in the name, the last is for the loop server and the first is a talking about Loop in general I guess.

Then there is also gRegisteredDeferred which is created in promiseRegisteredWithServers (for push registration) but gets resolved when loop registration completes. I don't think onPushRegistered should call registerWithLoopServer directly so we can properly fix bug 1076428 since right now it doesn't know whether to do a Guest or FxA registration.

The way some of the mock objects are passed around multiple levels is also messy IMO. I would rather those are set as a global or a property.
Whiteboard: [tech-debt]
backlog: --- → Fx36+
backlog: Fx36+ → Fx37+
Depends on: 1102193
backlog: Fx37+ → Fx38?
Moving these to blocking-loop="tech-debt" so they can be triaged against other tech debt bugs.  When we take a tech-debt bug to work on - just mark it "firefox-backlog"+ and give priority.  Then we'll pull it during iteration planning (or factor it into workload if someone is already working on).
backlog: Fx38? → tech-debt
Rank: 45
Priority: -- → P4
Mike: does this bug still seem valid?
Flags: needinfo?(mdeboer)
Yes, MozLoopService is still a mess, sort of.
Flags: needinfo?(mdeboer)
Support for Hello/Loop has been discontinued.

https://support.mozilla.org/kb/hello-status

Hence closing the old bugs. Thank you for your support.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.