Bug 140983 - Rename pageCache() to PageCache::shared() and return a reference
Summary: Rename pageCache() to PageCache::shared() and return a reference
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-27 20:31 PST by Chris Dumez
Modified: 2015-01-28 10:02 PST (History)
5 users (show)

See Also:


Attachments
Patch (32.69 KB, patch)
2015-01-27 21:04 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.68 KB, patch)
2015-01-28 00:48 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-01-27 20:31:42 PST
Rename pageCache() to PageCache::shared() as this is a singleton class and have it return a reference instead of a pointer.
Comment 1 Chris Dumez 2015-01-27 21:04:18 PST
Created attachment 245515 [details]
Patch
Comment 2 Andreas Kling 2015-01-27 21:41:44 PST
Comment on attachment 245515 [details]
Patch

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

r=me

> Source/WebCore/history/PageCache.h:81
> +        PageCache(); // Use instance() instead.

You mean use shared() instead :-)
Comment 3 Chris Dumez 2015-01-28 00:48:26 PST
Created attachment 245522 [details]
Patch
Comment 4 WebKit Commit Bot 2015-01-28 01:33:55 PST
Comment on attachment 245522 [details]
Patch

Clearing flags on attachment: 245522

Committed r179247: <http://trac.webkit.org/changeset/179247>
Comment 5 WebKit Commit Bot 2015-01-28 01:33:58 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Csaba Osztrogonác 2015-01-28 03:23:03 PST
(In reply to comment #4)
> Comment on attachment 245522 [details]
> Patch
> 
> Clearing flags on attachment: 245522
> 
> Committed r179247: <http://trac.webkit.org/changeset/179247>

It broke the Windows build, as the EWS noticed it in time.

     1>C:\cygwin\home\buildbot\slave\win-release\build\WebKitBuild\Release\include\private\wtf/NeverDestroyed.h(53): error C2248: 'WebCore::PageCache::PageCache' : cannot access private member declared in class 'WebCore::PageCache' (..\history\PageCache.cpp)
                 c:\cygwin\home\buildbot\slave\win-release\build\source\webcore\history\PageCache.h(81) : see declaration of 'WebCore::PageCache::PageCache'
                 c:\cygwin\home\buildbot\slave\win-release\build\source\webcore\history\PageCache.h(43) : see declaration of 'WebCore::PageCache'
                 ..\history\PageCache.cpp(297) : see reference to function template instantiation 'WTF::NeverDestroyed<WebCore::PageCache>::NeverDestroyed<>(void)' being compiled
                 ..\history\PageCache.cpp(297) : see reference to function template instantiation 'WTF::NeverDestroyed<WebCore::PageCache>::NeverDestroyed<>(void)' being compiled
Comment 7 Darin Adler 2015-01-28 07:27:40 PST
Changing to a reference is fantastic. However, changing from a free function to a member function isn’t something I’m so happy about. I don’t think that PageCache::shared() is a better name than pageCache(), and generally I don’t think that singletons need to use member functions.
Comment 8 Chris Dumez 2015-01-28 08:47:10 PST
(In reply to comment #7)
> Changing to a reference is fantastic. However, changing from a free function
> to a member function isn’t something I’m so happy about. I don’t think that
> PageCache::shared() is a better name than pageCache(), and generally I don’t
> think that singletons need to use member functions.

Ok, I have no strong feelings about this. I made this change because I think this is more consistent with our recent code (e.g. In WK2). I'll upload a partial revert today.
Comment 9 Darin Adler 2015-01-28 09:08:12 PST
(In reply to comment #8)
> (In reply to comment #7)
> > Changing to a reference is fantastic. However, changing from a free function
> > to a member function isn’t something I’m so happy about. I don’t think that
> > PageCache::shared() is a better name than pageCache(), and generally I don’t
> > think that singletons need to use member functions.
> 
> Ok, I have no strong feelings about this. I made this change because I think
> this is more consistent with our recent code (e.g. In WK2). I'll upload a
> partial revert today.

If we are starting to go a particular direction with this, my personal taste alone should not be the driver. Maybe we should have a brief discussion.

More urgently, though, the Windows build is still broken!
Comment 10 Darin Adler 2015-01-28 09:08:29 PST
Brief discussion would be maybe on webkit-dev?
Comment 11 Brent Fulgham 2015-01-28 09:14:35 PST
This seems like a race between commit-queue and ews. The Windows bot was about 15 minutes slower than the mac ews. Once the reviewer marked it as cq+, it got applied and by the time the Windows ews noted the problem we were already sunk.
Comment 12 Csaba Osztrogonác 2015-01-28 09:20:59 PST
(In reply to comment #11)
> This seems like a race between commit-queue and ews. The Windows bot was
> about 15 minutes slower than the mac ews. Once the reviewer marked it as
> cq+, it got applied and by the time the Windows ews noted the problem we
> were already sunk.

That's why it was good to let the EWS set cq- and comment bug on failure.
But unfortunately it was stated SPAMs and disabled long time ago. :(
Now the only way to be informed about failures is polling bugzilla manually ...
Comment 13 Csaba Osztrogonác 2015-01-28 09:23:01 PST
I meant this thread: https://lists.webkit.org/pipermail/webkit-dev/2014-January/026068.html and bug127079 .
Comment 14 Brent Fulgham 2015-01-28 09:24:10 PST
Windows build fix landed in r179255. <http://trac.webkit.org/changeset/179255>
Comment 15 Chris Dumez 2015-01-28 09:43:48 PST
(In reply to comment #14)
> Windows build fix landed in r179255.
> <http://trac.webkit.org/changeset/179255>

My patch already marked NeverDestroyed<PageCache> as a friend class of PageCache. Now you added it again so it is marked twice?
Comment 16 Chris Dumez 2015-01-28 09:55:22 PST
(In reply to comment #15)
> (In reply to comment #14)
> > Windows build fix landed in r179255.
> > <http://trac.webkit.org/changeset/179255>
> 
> My patch already marked NeverDestroyed<PageCache> as a friend class of
> PageCache. Now you added it again so it is marked twice?

- Mine is public, yours is private. AFAIK, this doesn't matter for friend class statements.
- Your specifies WTF:: explicitly but this shouldn't matter either. StringImpl has the following statement for e.g. "friend class NeverDestroyed<StringImpl>;", and it builds fine on Windows.

I am not quite sure what's going on.
Comment 17 Brent Fulgham 2015-01-28 09:55:36 PST
(In reply to comment #15)
> (In reply to comment #14)
> > Windows build fix landed in r179255.
> > <http://trac.webkit.org/changeset/179255>
> 
> My patch already marked NeverDestroyed<PageCache> as a friend class of
> PageCache. Now you added it again so it is marked twice?

Oh! The problem must have been namespacing. You declared "WebCore::NeverDestroyed<PageCache>" as a friend, which is a nonexistent class.

It needed to be declared as "WTF::NeverDestroyed<PageCache>".

Can you delete the original incorrect declaration?
Comment 18 Brent Fulgham 2015-01-28 09:56:18 PST
(In reply to comment #16)
> (In reply to comment #15)
> > (In reply to comment #14)
> > > Windows build fix landed in r179255.
> > > <http://trac.webkit.org/changeset/179255>
> > 
> > My patch already marked NeverDestroyed<PageCache> as a friend class of
> > PageCache. Now you added it again so it is marked twice?
> 
> - Mine is public, yours is private. AFAIK, this doesn't matter for friend
> class statements.
> - Your specifies WTF:: explicitly but this shouldn't matter either.
> StringImpl has the following statement for e.g. "friend class
> NeverDestroyed<StringImpl>;", and it builds fine on Windows.

StringImpl is in namespace WTF.
Comment 19 Chris Dumez 2015-01-28 09:58:30 PST
(In reply to comment #18)
> (In reply to comment #16)
> > (In reply to comment #15)
> > > (In reply to comment #14)
> > > > Windows build fix landed in r179255.
> > > > <http://trac.webkit.org/changeset/179255>
> > > 
> > > My patch already marked NeverDestroyed<PageCache> as a friend class of
> > > PageCache. Now you added it again so it is marked twice?
> > 
> > - Mine is public, yours is private. AFAIK, this doesn't matter for friend
> > class statements.
> > - Your specifies WTF:: explicitly but this shouldn't matter either.
> > StringImpl has the following statement for e.g. "friend class
> > NeverDestroyed<StringImpl>;", and it builds fine on Windows.
> 
> StringImpl is in namespace WTF.

There are examples outside WTF namespace:
Source/WebKit2/NetworkProcess/NetworkProcess.h:    friend class NeverDestroyed<NetworkProcess>;

Maybe this works if wtf/NeverDestroyed.h is included in the header.
Comment 20 Brent Fulgham 2015-01-28 10:01:21 PST
(In reply to comment #19)
> > 
> > StringImpl is in namespace WTF.
> 
> There are examples outside WTF namespace:
> Source/WebKit2/NetworkProcess/NetworkProcess.h:    friend class
> NeverDestroyed<NetworkProcess>;
> 
> Maybe this works if wtf/NeverDestroyed.h is included in the header.

Right. Because wtf/NeverDestroyed.h provides a using declaration:

        } // namespace WTF;

        using WTF::LazyNeverDestroyed;
        using WTF::NeverDestroyed;

        #endif // NeverDestroyed_h

So anyone including this header can just say NeverDestroyed, just like you don't have to say "std::string" everywhere if you say "using std::string".
Comment 21 Chris Dumez 2015-01-28 10:02:54 PST
(In reply to comment #17)
> (In reply to comment #15)
> > (In reply to comment #14)
> > > Windows build fix landed in r179255.
> > > <http://trac.webkit.org/changeset/179255>
> > 
> > My patch already marked NeverDestroyed<PageCache> as a friend class of
> > PageCache. Now you added it again so it is marked twice?
> 
> Oh! The problem must have been namespacing. You declared
> "WebCore::NeverDestroyed<PageCache>" as a friend, which is a nonexistent
> class.
> 
> It needed to be declared as "WTF::NeverDestroyed<PageCache>".
> 
> Can you delete the original incorrect declaration?

Done, <http://trac.webkit.org/changeset/179262>.