Bug 118266

Summary: [WK2] Clean up private browsing session tracking
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: Page LoadingAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch beidson: review+

Description Alexey Proskuryakov 2013-07-01 16:08:33 PDT
Currently, WebContext counts how many times API for enabling/disabling private browsing was called. This is unnecessarily roundabout - we can watch actual WebPreferences objects instead.

<rdar://problem/13078036>
Comment 1 Alexey Proskuryakov 2013-07-01 16:47:43 PDT
Created attachment 205844 [details]
proposed patch
Comment 2 WebKit Commit Bot 2013-07-01 16:50:25 PDT
Attachment 205844 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit2/UIProcess/API/C/WKPreferences.cpp', u'Source/WebKit2/UIProcess/WebContext.cpp', u'Source/WebKit2/UIProcess/WebContext.h', u'Source/WebKit2/UIProcess/WebPreferences.cpp', u'Source/WebKit2/UIProcess/WebPreferences.h', u'Source/WebKit2/WebProcess/WebPage/WebPage.cpp']" exit_code: 1
Source/WebKit2/UIProcess/WebContext.cpp:53:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Brady Eidson 2013-07-01 17:01:14 PDT
Comment on attachment 205844 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=205844&action=review

> Source/WebKit2/ChangeLog:17
> +        API was called, rely on WebPrefences tracking.

typo WebPreferences*

> Source/WebKit2/ChangeLog:36
> +        WebContext to know when any page groups are in provate brosing mode.

provate brosing!!!

> Source/WebKit2/UIProcess/WebPreferences.cpp:67
> +    if (privateBrowsingEnabled()) {
> +        if (!privateBrowsingPageGroupCount++)
> +            WebContext::willStartUsingPrivateBrowsing();
> +    }

I think doing a compare with the postincrement makes this less readable than:
if (privateBrowsingEnabled()) {
    if (!privateBrowsingPageGroupCount)
        WebContext::willStartUsingPrivateBrowsing();
    ++privateBrowsingPageGroupCount;
}

> Source/WebKit2/UIProcess/WebPreferences.cpp:76
> +    if (privateBrowsingEnabled()) {
> +        if (!--privateBrowsingPageGroupCount)
> +            WebContext::willStopUsingPrivateBrowsing();
> +    }

I think doing a compare with the preincrement makes this less readable than:

if (privateBrowsingEnabled()) {
    --privateBrowsingPageGroupCount;
    if (!privateBrowsingPageGroupCount)
        WebContext::willStopUsingPrivateBrowsing();
}
Comment 4 Alexey Proskuryakov 2013-07-01 17:10:25 PDT
Committed <http://trac.webkit.org/changeset/152273>.

In addition to addressing review feedback, made one more change - in WebPreferences::addPageGroup and WebPreferences::removePageGroup, I check that the group is actually added or removed.