Closed Bug 486810 Opened 15 years ago Closed 15 years ago

Engines (and their trackers) are created with every new window

Categories

(Cloud Services :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Mardak, Assigned: Mardak)

References

Details

Attachments

(1 file, 1 obsolete file)

This behavior causes a lot of tracker activity such as every page visit results in X onVisit verbose logs.. one for each tracker added (from opening a window).
Attached patch v1 (obsolete) — Splinter Review
Have Engines.register take the engine object instance of an instance so that it can grab the singleton instance of the engine. Define a singleton instance getter on the base Engine, but make Engine "virtual" while creating only one instance of the sub-engine.
Assignee: nobody → edilee
Status: NEW → ASSIGNED
Attachment #371026 - Flags: review?(thunder)
Blocks: 485277
Depends on: 487308
Comment on attachment 371026 [details] [diff] [review]
v1

We should not try to register engines on every window open, this patch doesn't fix that.

Furthermore, the .instance trick is clever, but it would be simpler to just have EngineManager error/warn when attempting to replace an engine already set.
Attachment #371026 - Flags: review?(thunder) → review-
Attached patch v2Splinter Review
Moved engine registration to onStartup
Attachment #371026 - Attachment is obsolete: true
Attachment #371683 - Flags: review?(thunder)
Attachment #371683 - Flags: review?(thunder) → review+
Comment on attachment 371683 [details] [diff] [review]
v2


>   register: function EngMgr_register(engineObject) {
>     if (Utils.isArray(engineObject))
>       return engineObject.map(this.register, this);
> 
>     try {
>-      let engine = new engineObject();
>+      let engine = engineObject.prototype.instance;
>+
>+      if (engine.name in this._engines)
>+        this._log.warn("Engine '" + engine.name + "' is already registered!");
>+
>       this._engines[engine.name] = engine;
>     }

why not do this instead?

if (engineObj.name in this._engines)
  this._log.error("Engine '" + engine.name + "' is already registered!");
else
  this._engines[engineObj.name] = new engineObj()

It's simpler and does the same thing basically.  The instance getter is unnecessary because we already have the name which must be unique.

The rest looks great, so with the change above, r+
http://hg.mozilla.org/labs/weave/rev/e75c8e36d1e3

Register the built-in engines on service start-up instead of from the overlay, and have Engines.register check if the engine has already been registered.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Blocks: 484982
Component: Weave → General
Product: Mozilla Labs → Weave
Version: Trunk → unspecified
QA Contact: weave → general
No longer blocks: 484982
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: