Closed Bug 1323248 Opened 7 years ago Closed 5 years ago

Avoid using statics and struct Singleton model for our database references

Categories

(Firefox for iOS :: Sync, defect, P3)

Other
iOS
defect

Tracking

()

RESOLVED INACTIVE
Tracking Status
fxios + ---

People

(Reporter: sleroux, Unassigned)

Details

Follow up for https://github.com/mozilla-mobile/firefox-ios/pull/2273

We currently use static variables to keep track of our DB open/closed states across (potentially) multiple profiles and use an older singleton model. We should revise how we maintain our references to these database models and try to not use statics if we can. We should also investigate options around memoizing disk access such as opening up our files reference for the DB.
To flesh this out a little:

The reason we use singleton DB references is to ensure that we don't accidentally open the DB twice. This might happen when triggering the share extension from inside Firefox itself. Multiple DB connections leads to occasional hard-to-fix bugs around concurrent writes.

It's conceptually neater to have the profile hold a reference to the DB, eliminating the singleton, but of course if we then instantiate the profile more than once, we'll open the DB more than once.

The fix for this is probably to do something a little like we do on Android: a static map from directory to profile, memoizing the profile itself. The share extensions and the main app would have a reference to the same profile instance.

The trouble there is that we'd have to get the closing lifecycle right again…
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.