Closed
Bug 506116
Opened 15 years ago
Closed 15 years ago
speed up makeURI(str) and use it in browser.js
Categories
(Firefox :: General, defect)
Firefox
General
Tracking
()
RESOLVED
FIXED
Firefox 3.6a1
People
(Reporter: dietrich, Assigned: Natch)
References
Details
(Keywords: perf, Whiteboard: [ts])
Attachments
(1 file, 5 obsolete files)
10.91 KB,
patch
|
Details | Diff | Splinter Review |
right now there are of intanciations of ioservice all over the place
Reporter | ||
Updated•15 years ago
|
Whiteboard: [ts]
Comment 1•15 years ago
|
||
We already have makeURI from contentAreaUtils.js used in a few places, but it doesn't keep a reference to the IO service. We should fix that and then convert other places to use it.
Assignee | ||
Comment 2•15 years ago
|
||
Taking. Patch up in a few.
Assignee: nobody → highmind63
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•15 years ago
|
||
So, just adding a variable in an external helper js file seemed wrong to me, so I wrapped it in an object. IMO the whole file should be wrapped in that object, but that requires updating the whole tree and isn't necessary for this bug. I'd be willing to do it though, so feel free to file a bug and assign it to me if there's an interest.
This contains the changes to browser.js and contentAreaUtils.js.
Attachment #390678 -
Flags: review?(dietrich)
Comment 4•15 years ago
|
||
I don't know whether or not it is recommended practice, but the other callers of makeURI seem to be happy not passing the trailing null parameters as the undefined values will become null when passed on in
> return ContentAreaUtils.ioService.newURI(aURL, aOriginCharset, aBaseURI);
Reporter | ||
Comment 5•15 years ago
|
||
Thanks for the quick patch Natch! I agree w/ comment #4 - change makeURI so that the subsequent arguments are optional, making it more caller-friendly.
Reporter | ||
Comment 6•15 years ago
|
||
Comment on attachment 390678 [details] [diff] [review]
patch
clarified on irc, fixup the function if needed. please fix callers to not pass null arguments where not necessary. r=me otherwise. please get second review from a browser peer and a toolkit peer, as i'm neither. (get gavin to review, and you'll get both!)
Attachment #390678 -
Flags: review?(dietrich) → review+
Assignee | ||
Updated•15 years ago
|
Attachment #390678 -
Flags: review?(gavin.sharp)
Assignee | ||
Updated•15 years ago
|
Attachment #390678 -
Flags: review?(neil)
Attachment #390678 -
Flags: review?(gavin.sharp)
Attachment #390678 -
Flags: review?(dao)
Assignee | ||
Comment 7•15 years ago
|
||
Comment on attachment 390678 [details] [diff] [review]
patch
Actually, I'll try to get two other reviewers seeing as gavin is pretty swamped with reviews.
Assignee | ||
Comment 8•15 years ago
|
||
Silly mistake, could've sworn I had changed it...
Attachment #390678 -
Attachment is obsolete: true
Attachment #390971 -
Flags: review?(dao)
Attachment #390678 -
Flags: review?(neil)
Attachment #390678 -
Flags: review?(dao)
Assignee | ||
Updated•15 years ago
|
Attachment #390971 -
Flags: review?(neil)
Comment 9•15 years ago
|
||
Comment on attachment 390971 [details] [diff] [review]
patch ver. 2
>diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
A couple of places you explicitly pass null, null for the last two arguments to makeURI - common practice is to just omit them and let xpconnect do the conversion, but I don't feel strongly about that.
> _getManifestURI: function(aWindow) {
>- var ios = Cc["@mozilla.org/network/io-service;1"].
>- getService(Ci.nsIIOService);
>-
>- var contentURI = ios.newURI(aWindow.location.href, null, null);
>- return ios.newURI(attr, aWindow.document.characterSet, contentURI);
>+ var contentURI = makeURI(aWindow.location.href, null, null);
>+ return makeURI(attr, aWindow.document.characterSet, contentURI);
This method should really be using aWindow.document.documentURIObject as the baseURI, rather than creating its own URI. Can do that in a followup, I guess, if you want to avoid scope creeping this patch.
> // XXX: duplicated in preferences/advanced.js
> _getOfflineAppUsage: function (host, groups)
Probably worth avoiding this change just to keep these two methods in sync. This isn't a particularly perf-sensitive code path.
> observe: function (aSubject, aTopic, aState)
> {
>- var uri = Cc["@mozilla.org/network/io-service;1"].
>- getService(Ci.nsIIOService).
>- newURI(aSubject.location.href, null, null);
>+ var uri = makeURI(aSubject.location.href, null, null);
Same here: aSubject.document.documentURIObject.
r=me, but I think the new policy requires sr on this patch...
Attachment #390971 -
Flags: review?(neil)
Attachment #390971 -
Flags: review?(dao)
Attachment #390971 -
Flags: review+
Assignee | ||
Comment 10•15 years ago
|
||
Thanks Gavin. I addressed all the comments, including the change from makeURI to documentURIObject.
I ran all the browser-chrome tests and the mochitest-plain offline tests under dom/ and all is well, so this should be fine.
Attachment #390971 -
Attachment is obsolete: true
Attachment #390990 -
Flags: superreview?(vladimir)
Comment on attachment 390990 [details] [diff] [review]
comments addressed
Looks great to me.
Attachment #390990 -
Flags: superreview?(vladimir) → superreview+
Though I should ask -- why did the io service move to ContentAreaUtils? That seems odd, especially in light of bug 506111.
Assignee | ||
Comment 13•15 years ago
|
||
This file needs it and it can be used in any file that wants it. Previously this file would call getService every time this function was called. Now there's a smart getter for it, I just figured it wasn't right to declare a global variable in a shared js file. See comment 3.
Thanks.
Keywords: checkin-needed
Updated•15 years ago
|
Summary: add utility function for newURI(str) in browser.js → speed up makeURI(str) and use it in browser.js
Comment 14•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3.6a1
Updated•15 years ago
|
Comment 15•15 years ago
|
||
Comment on attachment 390990 [details] [diff] [review]
comments addressed
>diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
> _getManifestURI: function(aWindow) {
>- if (!attr) return null;
>-
>- try {
>- var ios = Cc["@mozilla.org/network/io-service;1"].
>- getService(Ci.nsIIOService);
>-
>- var contentURI = ios.newURI(aWindow.location.href, null, null);
>- return ios.newURI(attr, aWindow.document.characterSet, contentURI);
>- } catch (e) {
>- return null;
>- }
>+ return attr ? aWindow.document.documentURIObject : null;
This is wrong - you need to use the "attr" value still - the documentURIObject is only useful as the baseURI (i.e. the third argument to makeURI).
I'm surprised we don't have a test that breaks because of this... we really should.
Attachment #390990 -
Flags: review-
Comment 16•15 years ago
|
||
Backed that out: https://hg.mozilla.org/mozilla-central/rev/4ef37aa4511d
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 17•15 years ago
|
||
Comment on attachment 390990 [details] [diff] [review]
comments addressed
>--- a/toolkit/content/contentAreaUtils.js
>+++ b/toolkit/content/contentAreaUtils.js
> function openURL(aURL)
> {
>- var ios = Components.classes["@mozilla.org/network/io-service;1"]
>- .getService(Components.interfaces.nsIIOService);
>- var uri = ios.newURI(aURL, null, null);
>+ var uri = makeURI(aURL, null, null);
You missed this one when removing the trailing null parameters.
Comment 18•15 years ago
|
||
See also bug 506111 comment 12.
Comment 19•15 years ago
|
||
Comment on attachment 390990 [details] [diff] [review]
comments addressed
>--- a/toolkit/content/contentAreaUtils.js
>+++ b/toolkit/content/contentAreaUtils.js
> function openURL(aURL)
> {
>- var ios = Components.classes["@mozilla.org/network/io-service;1"]
>- .getService(Components.interfaces.nsIIOService);
>- var uri = ios.newURI(aURL, null, null);
>+ var uri = makeURI(aURL, null, null);
ios is still used in that function.
Assignee | ||
Comment 20•15 years ago
|
||
Right, sorry about that. I ran the tests and nothing came up, and I misunderstood what gavin had said earlier, I'll make both changes.
For the openURL issue (that it still uses ios) I'll use ContentAreaUtils.ioService.
Assignee | ||
Comment 21•15 years ago
|
||
OK, all the comments were addressed. Sorry for the confusion, if someone could point me out to how and when _getManifestURI works I'll try to create a test.
Attachment #390990 -
Attachment is obsolete: true
Attachment #391098 -
Flags: review?(gavin.sharp)
Assignee | ||
Updated•15 years ago
|
Attachment #391098 -
Attachment is patch: true
Attachment #391098 -
Attachment mime type: application/octet-stream → text/plain
Assignee | ||
Updated•15 years ago
|
Status: REOPENED → ASSIGNED
Flags: in-testsuite?
Comment 22•15 years ago
|
||
Comment on attachment 391098 [details] [diff] [review]
patch
>diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
> _getManifestURI: function(aWindow) {
> if (!aWindow.document.documentElement) return null;
> var attr = aWindow.document.documentElement.getAttribute("manifest");
> if (!attr) return null;
>-
>- try {
>- var ios = Cc["@mozilla.org/network/io-service;1"].
>- getService(Ci.nsIIOService);
>-
>- var contentURI = ios.newURI(aWindow.location.href, null, null);
>- return ios.newURI(attr, aWindow.document.characterSet, contentURI);
>- } catch (e) {
>- return null;
>- }
>+ return makeURI(attr,
>+ aWindow.document.characterSet,
>+ aWindow.document.documentURIObject);
Don't think you can get rid of the try/catch, since the "attr" may be bogus.
This method only seems to be used in response to "offline-cache-update-completed", which doesn't seem to be covered by existing tests. Perhaps test_offlineNotification.html could be modified to cover that case? I'm not an expert on that offline cache code, so perhaps we should just defer the documentURIObject changes to a followup to reduce the risk/churn here.
Assignee | ||
Comment 23•15 years ago
|
||
Ok, fair enough.
Attachment #391098 -
Attachment is obsolete: true
Attachment #391122 -
Flags: review?(gavin.sharp)
Attachment #391098 -
Flags: review?(gavin.sharp)
Comment 24•15 years ago
|
||
Comment on attachment 391122 [details] [diff] [review]
patch
>diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
> observe: function (aSubject, aTopic, aState)
>- var uri = Cc["@mozilla.org/network/io-service;1"].
>- getService(Ci.nsIIOService).
>- newURI(aSubject.location.href, null, null);
>+ var uri = aSubject.document.documentURIObject;
Defer this change to the followup as well and just use makeURI(aSubject.location.href)?
Attachment #391122 -
Flags: review?(gavin.sharp) → review+
Assignee | ||
Comment 25•15 years ago
|
||
Does this need re-super-review? Remove checkin-needed if it doesn.
Attachment #391122 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 26•15 years ago
|
||
Tests will come in the followup for the two changes skipped in this bug. Those are the only functional changes here.
Flags: in-testsuite? → in-testsuite-
Comment 27•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago → 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•