Closed Bug 758660 Opened 12 years ago Closed 12 years ago

Panorama telemetry gatherer checks global PB state

Categories

(Firefox Graveyard :: Panorama, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 16

People

(Reporter: jdm, Assigned: sawrubh)

References

()

Details

(Whiteboard: [mentor=jdm][lang=js])

Attachments

(1 file, 6 obsolete files)

We should change this check to use something like

window.getInterface(Ci.nsIWebNavigation)
             .QueryInterface(Ci.nsIDocShellTreeItem)
             .treeOwner
             .QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsIXULWindow)
             .docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing;

to determine if the window is private or not.
Whiteboard: [mentor=jdm][lang=js]
OS: Mac OS X → All
Hardware: x86 → All
Attached patch Patch v1 (obsolete) — Splinter Review
Why has Josh advised to use the QI goop he says and not             

let temp = window.QueryInterface(Ci.nsIInterfaceRequestor)
                 .getInterface(Ci.nsIWebNavigation)
                 .QueryInterface(Ci.nsIDocShellTreeItem)
                 .rootTreeItem
                 .QueryInterface(Ci.nsIInterfaceRequestor)
                 .getInterface(Ci.nsIDOMWindow)
                 .wrappedJSObject;
and then just accesing |temp.gPrivateBrowsingUI.privateWindow|. Is there any difference in what I propose (although I feel both will give the same result) ?
Assignee: nobody → saurabhanandiit
Status: NEW → ASSIGNED
Attachment #633912 - Flags: feedback?(ttaubert)
Attachment #633912 - Flags: feedback?(ehsan)
I think Josh's suggestion predates the privateWindow API.  Have you run this through the try server?
Comment on attachment 633912 [details] [diff] [review]
Patch v1

Please use the privateWindow API.
Attachment #633912 - Flags: feedback?(ttaubert)
Attachment #633912 - Flags: feedback?(ehsan)
Attachment #633912 - Flags: feedback-
Rereading the code now, I can't imagine that using window works here. I think we need to modify the collection code to avoid private browsing windows and remove the check from the observe method.
@Ehsan, one silly question :P, is the privateWindow API something special that I don't know about or is it just the process that I have written in my comment ?

@Josh, do you mean that the QI goop that I've said in my comment(which uses window to QI and get chrome window) will not work ?

@Both, for the try run should I do |try: -b do -p all -u all -t none| or all the talos suites also ?
Attached patch Patch v2 (obsolete) — Splinter Review
Tried to combine Ehsan's and Josh's comments. Still have a doubt(as Josh said) that using window might not work. So please check if the QI goop that I used is correct or not.
Attachment #633912 - Attachment is obsolete: true
Attachment #633953 - Flags: feedback?(ehsan)
Comment on attachment 633953 [details] [diff] [review]
Patch v2

This still won't work, since there's no window object to manipulate. http://mxr.mozilla.org/mozilla-central/source/browser/components/tabview/groupitems.js defines the groupItems that is being manipulated in _collect - we should iterate through the result of groupItem.getChildren and obtain window objects from each one, and only then can we do the QI dance. We'll also want to have counter values that hold the totals of non-private windows we encounter.
Attachment #633953 - Flags: feedback?(ehsan) → feedback-
With regards to tests, running mochitest-browser-chrome should cover it.
Use gWindow.gPrivateBrowsingUI.privateWindow.
(In reply to Saurabh Anand [:sawrubh] from comment #5)
> @Ehsan, one silly question :P, is the privateWindow API something special
> that I don't know about or is it just the process that I have written in my
> comment ?

What you wrote in your comment.

> @Both, for the try run should I do |try: -b do -p all -u all -t none| or all
> the talos suites also ?

No, you generally don't need to run talos tests, unless you're trying to measure performance.
@Josh, About the counter that you say is needed , what do you want me to do with it, set up a telemetry attribute for it or just return it ?
Please disregard comment 7, you don't need a counter. Your patch is on the right track, except that it should use gWindow.gPrivateBrowsingUI.privateWindow.
Attached patch Patch v3 (obsolete) — Splinter Review
Is there anything else that needs to be done in this patch ?
Attachment #633953 - Attachment is obsolete: true
Attachment #637300 - Flags: feedback?(ehsan)
Comment on attachment 637300 [details] [diff] [review]
Patch v3

Review of attachment 637300 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good with the nit below.  Please ask Tim Taubert to review this, though, since it's been a while since I've looked at the Panorama code.

::: browser/components/tabview/telemetry.js
@@ +30,5 @@
>      let childCounts = [];
> +    // Assuming the default state is Normal mode
> +    let pbFlag = false;
> +    if (gWindow && ("gPrivateBrowsingUI" in gWindow))
> +      pbFlag = gWindow.gPrivateBrowsingUI.privateWindow;

Nit: instead of storing the result in pbFlag, just move this code down and check directly in the if condition.
Attachment #637300 - Flags: feedback?(ehsan) → feedback+
Attached patch Patch v4 (obsolete) — Splinter Review
Fixed the nit pointed by Ehsan.
Attachment #637300 - Attachment is obsolete: true
Comment on attachment 637632 [details] [diff] [review]
Patch v4

The tree is green.
Attachment #637632 - Flags: review?(ttaubert)
Comment on attachment 637632 [details] [diff] [review]
Patch v4

Review of attachment 637632 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks Saurabh, that looks good.

::: browser/components/tabview/telemetry.js
@@ +28,4 @@
>    _collect: function Telemetry_collect() {
>      let stackedGroupsCount = 0;
>      let childCounts = [];
> +    

Nit: please just revert this change.

@@ +46,5 @@
>        let middle = Math.floor(aChildCounts.length / 2);
>        return aChildCounts[middle];
>      }
> +    
> +    if (gWindow && ("gPrivateBrowsingUI" in gWindow) && !gWindow.gPrivateBrowsingUI.privateWindow) {

You don't need to check for 'gWindow', that'll always exist. Please move this check back to its original position - the observe method.
Attachment #637632 - Flags: review?(ttaubert) → feedback+
Attached patch Patch v5 (obsolete) — Splinter Review
Fixed the nits and comments.
Attachment #637632 - Attachment is obsolete: true
Attachment #637830 - Flags: review?(ttaubert)
Comment on attachment 637830 [details] [diff] [review]
Patch v5

Review of attachment 637830 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/components/tabview/telemetry.js
@@ +56,4 @@
>     * Observes for gather telemetry topic.
>     */
>    observe: function Telemetry_observe(aSubject, aTopic, aData) {
> +    if (("gPrivateBrowsingUI" in gWindow) && !gWindow.gPrivateBrowsingUI.privateWindow)

This must be:

> if (!("gPrivateBrowsingUI" in gWindow) || !gWindow.gPrivateBrowsingUI.privateWindow)

because we'll want to collect when there's no private browsing UI.
Attached patch Patch v6 (obsolete) — Splinter Review
Sorry for the wrong logic.
Attachment #637830 - Attachment is obsolete: true
Attachment #637830 - Flags: review?(ttaubert)
Attachment #637834 - Flags: review?(ttaubert)
Comment on attachment 637834 [details] [diff] [review]
Patch v6

Review of attachment 637834 [details] [diff] [review]:
-----------------------------------------------------------------

Please also remove the 'gPrivateBrowsing' getter defined in browser/components/tabview/tabview.js, it's not used anymore. r=me with that change. Thank you!
Attachment #637834 - Flags: review?(ttaubert) → review+
Attached patch Patch v7Splinter Review
Attachment #637834 - Attachment is obsolete: true
Attachment #637837 - Flags: review?(ttaubert)
Comment on attachment 637837 [details] [diff] [review]
Patch v7

Review of attachment 637837 [details] [diff] [review]:
-----------------------------------------------------------------

That should be r++ now. Can you please push it to try before we land it?
Attachment #637837 - Flags: review?(ttaubert) → review+
https://hg.mozilla.org/mozilla-central/rev/6ad21d37ab91
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
(In reply to Tim Taubert [:ttaubert] from comment #20)
> Comment on attachment 637830 [details] [diff] [review]
> Patch v5
> 
> Review of attachment 637830 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: browser/components/tabview/telemetry.js
> @@ +56,4 @@
> >     * Observes for gather telemetry topic.
> >     */
> >    observe: function Telemetry_observe(aSubject, aTopic, aData) {
> > +    if (("gPrivateBrowsingUI" in gWindow) && !gWindow.gPrivateBrowsingUI.privateWindow)
> 
> This must be:
> 
> > if (!("gPrivateBrowsingUI" in gWindow) || !gWindow.gPrivateBrowsingUI.privateWindow)
> 
> because we'll want to collect when there's no private browsing UI.

gPrivateBrowsingUI must exist here. What's the point of the check?
(In reply to Dão Gottwald [:dao] from comment #28)
> > > if (!("gPrivateBrowsingUI" in gWindow) || !gWindow.gPrivateBrowsingUI.privateWindow)
> > 
> > because we'll want to collect when there's no private browsing UI.
> 
> gPrivateBrowsingUI must exist here. What's the point of the check?

Yeah, in retrospect, that's unnecessary. Panorama is of course active in browser windows only. Doesn't really hurt but can be removed in the future.
Product: Firefox → Firefox Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: