Closed Bug 587027 Opened 14 years ago Closed 14 years ago

Use as little memory as possible

Categories

(Firefox :: Sync, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: philikon, Assigned: philikon)

References

Details

Attachments

(5 files, 6 obsolete files)

Sync should do as little as possible on startup, especially when it's not configured:

* Move the Weave object to a separate file (main.js)
* Make properties lazy getters that import only when accessed (incl. service.js)
* Move startup related status stuff (_checkSetup etc.) to status.js so service.js doesn't have to be imported if the client isn't configured.
Attached patch part1 v1 (obsolete) — Splinter Review
Part 1: Move the Weave object out of service.js
Assignee: nobody → philipp
Attachment #465860 - Flags: review?(mconnor)
Attached patch part2 v1 (obsolete) — Splinter Review
Part 2: Fix tests after Weave relocation
Attachment #465861 - Flags: review?(mconnor)
Attached patch part3 v1Splinter Review
Part 3: Fix up add-on UI to import main.js to get the Weave object.
Attachment #465862 - Flags: review?(mconnor)
Attached patch part4 v1 (obsolete) — Splinter Review
Refactor Service._checkSetup() to Status.checkSetup().

Also move the test fixture for WeaveCryptoID to the individual tests that need it.
Attachment #465863 - Flags: review?(mconnor)
Attached patch part5 v1 (obsolete) — Splinter Review
Avoid accessing Weave.Service (=importing service.js) at all cost.
Attachment #465916 - Flags: review?(mconnor)
Comment on attachment 465916 [details] [diff] [review]
part5 v1

Clearing r? flag from WIP patch... muscle memory ;)
Attachment #465916 - Flags: review?(mconnor)
Comment on attachment 465860 [details] [diff] [review]
part1 v1


>+let Weave = {};
>+Components.utils.import("resource://services-sync/constants.js", Weave);
>+lazyImport("resource://services-sync/auth.js", Weave,
>+           ['Auth', 'BrokenBasicAuthenticator', 'BasicAuthenticator',
>+            'NoOpAuthenticator']);
>+lazyImport("resource://services-sync/base_records/keys.js", Weave,
>+           ['PubKey', 'PrivKey', 'PubKeys', 'PrivKeys']);
>+lazyImport("resource://services-sync/engines.js", Weave,
>+           ['Engines', 'Engine', 'SyncEngine']);
...etc 

for the sake of readability, can we do:

let imports = {
  "auth.js":              ['Auth', 'BrokenBasicAuthenticator', 
                           'BasicAuthenticator', 'NoOpAuthenticator'],
  "base_records/keys.js": ['PubKey', 'PrivKey', 'PubKeys', 'PrivKeys'],
  etc
};

for (let i in imports)
  lazyImport("resource://services-sync/" + i, Weave, imports[i])

Just makes it more explicitly mapping file -> symbols and removes a lot of text duplication 

r=me with that change
Attachment #465860 - Flags: review?(mconnor) → review+
Attachment #465861 - Flags: review?(mconnor) → review+
Attachment #465862 - Flags: review?(mconnor) → review+
Attachment #465863 - Flags: review?(mconnor) → review+
Attached patch part1 v2 (obsolete) — Splinter Review
Addressed review comments.
Attachment #465860 - Attachment is obsolete: true
Attached patch part2 v2Splinter Review
Fix up new test that was committed in the mean time.
Attachment #465861 - Attachment is obsolete: true
Attached patch part4 v2Splinter Review
Fix bug in Weave.Status.checkSetup(): We need to create the Identity objects if they don't exist yet before being able to check the password.
Attachment #465863 - Attachment is obsolete: true
Comment on attachment 465916 [details] [diff] [review]
part5 v1

Turns out that part 5 (avoiding accessing Weave.Service in the UI code) was working, there was just a small bug in part 3 (Weave.Service.checkSetup()). Requesting r?
Attachment #465916 - Attachment description: part5 WIP → part5 v1
Attachment #465916 - Flags: review?(mconnor)
(In reply to comment #11)
> bug in part 3 (Weave.Service.checkSetup()).

Of course I meant part 4.
Attached patch part5 v2 (obsolete) — Splinter Review
Don't explicitly access Weave.Service, wait for Weave.js to import service.js.
Attachment #465916 - Attachment is obsolete: true
Attachment #468792 - Flags: review?(mconnor)
Attachment #465916 - Flags: review?(mconnor)
Attached patch part5 v3Splinter Review
Also avoid accessing Weave.Service in Fennec UI and Weave.js when not necessary.
Attachment #468792 - Attachment is obsolete: true
Attachment #469091 - Flags: review?(mconnor)
Attachment #468792 - Flags: review?(mconnor)
Attached patch part1 v3Splinter Review
Continue to export the "Weave" object from service.js for backwards compatibility with the Firefox 4.0b4 UI.
Attachment #468294 - Attachment is obsolete: true
Attachment #469110 - Flags: review?(mconnor)
Blocks: 590613
Blocks: 590615
Blocks: 590633
Attachment #469110 - Flags: review?(mconnor) → review+
Comment on attachment 469091 [details] [diff] [review]
part5 v3


>diff --git a/ui/fennec/content/overlay.js b/ui/fennec/content/overlay.js
>     // Generating keypairs is expensive on mobile, so disable it
>-    Weave.Service.keyGenEnabled = false;
>+    if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED)
>+      Weave.Service.keyGenEnabled = false;

this feels like something we should have as a pref-based property, and not set it on every startup.  Then we don't need this call here, and it's just a pref for fennec trunk.
Attachment #469091 - Flags: review?(mconnor) → review+
(In reply to comment #16)
> this feels like something we should have as a pref-based property, and not set
> it on every startup.  Then we don't need this call here, and it's just a pref
> for fennec trunk.

Filed follow-up bug 590743
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.

Attachment

General

Created:
Updated:
Size: