Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp NTT's force-compatiblity feature. Fixes #52. #82

Closed

Conversation

xabolcs
Copy link
Collaborator

@xabolcs xabolcs commented Jun 6, 2012

Please note the following:

@@ -493,14 +493,22 @@ openPushlog: function() {

toggleCompatibility: function() {
var forceCompat = nightly.preferences.getBoolPref("disableCheckCompatibility");
nightly.preferences.setBoolPref("disableCheckCompatibility", !forceCompat);
var os = Components.classes["@mozilla.org/observer-service;1"].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been named obs across the Firefox codebase. I would propose we do the same here, which makes it easier for us later to replace the instances with Services.obs.

- renamed 'os' to 'obs'
- moved observer code to an object
- shortened Components.*
- formatted foreign code
- renamed preference constants
- moved version()
@xabolcs
Copy link
Collaborator Author

xabolcs commented Aug 14, 2012

Added commit 392a9b8 - Addressing comments, round 1.

self.obs.notifyObservers(null, "nttACS", null);
}
}
AddonManager.getAddonsByTypes(null, countPendingAddonsAndNotifyToRestartCallback);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of characters in function name countPendingAddonsAndNotifyToRestartCallback is too damn high.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we move the callback inline. There is no reason to have it separate given that it is only used once.

@whimboo
Copy link
Contributor

whimboo commented Mar 7, 2013

Would you mind to update the pull for the latest version of the NTT code? We really missed that in the 3.4 release. :/

@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 7, 2013

whimboo wrote:

Would you mind to update the pull for the latest version of the NTT code? We really missed that in the 3.4 release. :/

Sure! :)
Thank you for picking up.

@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 8, 2013

This pull request can be automatically merged. Again. :)

let startCount = count();
self.setCompatPrefs();
if (startCount != count()) {
self.obs.notifyObservers(null, "nttACS", "restartNeeded");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we send an object like { restart: true } which will make it easier to extend the observer data later if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we send an object ...

Are you sure? Please check notifyObservers() documentation again! ;)

void notifyObservers(
  in nsISupports aSubject,
  in string aTopic,
  in wstring someData 
);

I could use JSON.parse() here on the other side, if you really want to pass an object.

- JSONed observer data
- version is now a property
- space nits
- Songbird exclusion note
- filtering addons
- not inlining long name function yet
@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 14, 2013

@whimboo
All your comments addressed.
While in-lining the long named function I restructured a little bit.

@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 14, 2013

@whimboo
You could review now, but please don't land it for a while.
Let me consult Gerv about crediting Kris for his original work before landing.

obs.removeObserver(restartObserver, "nttACS");
var parsedData = JSON.parse(data);
if (parsedData && parsedData.restart) {
nightlyApp.openNotification("nightly-compatibility-restart",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we had if (nightlyApp.openNotification). Isn't that necessary anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we had if (nightlyApp.openNotification). Isn't that necessary anymore?
It's still around here! :)

The restartObserver above is activated only if nightlyApp.openNotification exists. See L491!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this if in here, so that we always send an observer notification. Other extensions may want to rely on the notification and then could benefit from.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this if in here, so that we always send an observer notification. ...

?!
The nttAddonCompatibilityService sends the notification in all case. See the other, sendNotification(), notifyObject related threads near at line L54 and L73/L83!

The restartObserver here isn't always activated.
For example Songbird doesn't have nightlyApp.openNotification implemented yet,
therefore nightly.toggleCompatibility doesn't register for the restart notification.
It simply discards. :)
But in Firefox case it will register the observer, and the PopupNotification/NotificationBox could open if restart would be needed after pref change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter which application has openNotification available or not. If a restart is necessary we should fire the observer anyway. If the notification cannot be handled in observe because the above method is not available, we can always skip it. But we should not stop sending the observer notification due to that reason. As I have mentioned above others may be very well interested in our notification too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should over-engineer it at this point. When we really only want to have it available internally, why can't we call it directly through it's object/instance? If the prompt has to happen async we can use setTimeout(fun, 0) to trigger it, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the component should find the most recent Tb, SM, Fx, ... window - if any - then it could call nightly.openNotification.

But I'm still voting for drop this demand stuff from this pull, and let it born as a follow-up issue. Or simply leave it as is - a public interface.
And I still can't imagine what do you think how should I implement this interface privately. :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so lets rename the observer topic to _nttACS which should make it clear it's somewhat private. Please file a follow-up where we can discuss another (better) solution. Thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so lets rename the observer topic to _nttACS ...

Renamed, but not tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until this private interface doesn't get implemented (should file a follow-up issue) I move this obs and restartObserver into if (nightlyApp.openNotification) section:

  • to avoid confusion, because they belongs there
  • due to performance :)

if(this.prefService.getBoolPref("nightly.disableCheckCompatibility"))
this.version = this.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/i, "$1");

if(this.prefService.getBoolPref(PREF_FORCE_COMPAT)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a blank between if and the opening bracket.

- space nits
- inline pending filter
@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 21, 2013

Pull updated for the nits.
The nightlynttAddonCompatibilityService private communication is still unclear to me.

@whimboo
Copy link
Contributor

whimboo commented Mar 26, 2013

Looks fine to me. @xabolcs can we get this tested? Do you have the time for? If not could you, @tonymec do it? I would kinda appreciate that given the lack of time on my side this week. :/

@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 26, 2013

Looks fine to me. @xabolcs can we get this tested?

Grrr!
Testing with an old Nighlty (Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20121229 Firefox/20.0 ID:20121229030919 CSet: 0bb4773db082) showed me that commit 593d77f introduced a regression in the restart-notification. :(

Seems like the inline transformation of isPendingAddon() wasn't succesful.

@tonymec
Copy link
Contributor

tonymec commented Mar 27, 2013

I'll have extremely little free time until at least Easter Monday. The two weeks after that I might have a little more slack.

- not starting a boolean in isPendingAddon()
- space nits
- not starting a boolean in isPendingAddon(), really
@xabolcs
Copy link
Collaborator Author

xabolcs commented Mar 27, 2013

Seems like the inline transformation of isPendingAddon() wasn't succesful.

Bug hunted down.
Tested with

  • Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20130327 Firefox/22.0 ID:20130327031035 CSet: 178a4a770bb1
  • Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20121229 Firefox/20.0 ID:20121229030919 CSet: 0bb4773db082
  • Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0 ID:20130116073211 CSet: eecd28b7ba09

@xabolcs
Copy link
Collaborator Author

xabolcs commented Apr 9, 2013

@whimboo
Addressing comments is done for now, feel free to review again!

@xabolcs
Copy link
Collaborator Author

xabolcs commented Apr 9, 2013

@whimboo
Commit 94e0e83 is added, now it's your turn.

@@ -473,14 +473,25 @@ openPushlogSinceCurrentBuild: function() {

toggleCompatibility: function() {
var forceCompat = nightly.preferences.getBoolPref("disableCheckCompatibility");
nightly.preferences.setBoolPref("disableCheckCompatibility", !forceCompat);
var obs = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an inconsistency here how we use Cc and Ci regarding their short and long names. If you feel fine please make it shorter here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no inconsistency here reagrding to Cx shortcuts.
Please note that nightly.js doesn't have those shortcuts!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please file a new issue which we can use to sync up all the files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have #87 already for styling. Should I file a new for code consistency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever works best for you. Is something else remaining now or can we can get this pull merged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to fix the two nits, so the pull request is not ready yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please file a new issue which we can use to sync up all the files.

Filed #128.

@whimboo
Copy link
Contributor

whimboo commented Apr 10, 2013

Except the two nits we are very close to get this landed!

- obs + restartObserver is relevant only in nightlyApp.openNotification case
- nttAddonCompatibilityService space nits
@xabolcs
Copy link
Collaborator Author

xabolcs commented Apr 13, 2013

Added commit 4bf06c6:

  • move obs, restartObserver where they belong
  • space nits

I hope you agree with that move in

@xabolcs
Copy link
Collaborator Author

xabolcs commented Apr 13, 2013

... nightly.js and we are still very close to get this landed! :)

@whimboo
Copy link
Contributor

whimboo commented Apr 15, 2013

Looks fine to me. Lets get it landed.

@xabolcs
Copy link
Collaborator Author

xabolcs commented Apr 16, 2013

Landed as ae9184f.

@xabolcs xabolcs closed this Apr 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants