Perhaps we should document this in the coding style guidelines. I like 
consistency and static member function seems like a good way to go, 
particularly since it matches the Class::create() pattern we often use for 
non-singletons.

> On Jan 28, 2015, at 12:10 PM, Ryosuke Niwa <rn...@webkit.org> wrote:
> 
> Class::shared() pattern seems good to me.
> 
> - R. Niwa
> 
> On Wed, Jan 28, 2015 at 11:38 AM, Benjamin Poulain <benja...@webkit.org 
> <mailto:benja...@webkit.org>> wrote:
> IMHO, scoping the function by its class is cleaner.
> http://trac.webkit.org/changeset/179247 
> <http://trac.webkit.org/changeset/179247> looks like an improvement to me.
> 
> Benjamin
> 
> 
> On 1/28/15 11:30 AM, Chris Dumez wrote:
>> Hi,
>> 
>> I noticed that we are currently not very consistent in WebKit in the way we 
>> implement singleton classes instance getters.
>> - Some classes use free functions (like MemoryCache, and PageCache until I 
>> updated it yesterday). e.g. memoryCache().xxx()
>> - Some classes are using static functions in the class (e.g. 
>> DatabaseProcess::shared(), PluginProcess::shared()).
>> 
>> As I said, I landed a patch yesterday so that the global page cache is now 
>> accessed via PageCache::shared() because I thought this was the currently 
>> preferred pattern (given it seems very common in WebKit2 code).
>> However, I thought I would email webkit-dev to make sure this is actually 
>> the case and make sure we agree on a given pattern (one way or another) for 
>> current and future code. We could then maybe document this
>> as part of our coding style.
>> 
>> Any feedback on this matter?
>> 
>> Kr,
>> --
>> Chris Dumez - Apple Inc.
>> Cupertino, CA
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org <mailto:webkit-dev@lists.webkit.org>
>> https://lists.webkit.org/mailman/listinfo/webkit-dev 
>> <https://lists.webkit.org/mailman/listinfo/webkit-dev>
> 
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev@lists.webkit.org <mailto:webkit-dev@lists.webkit.org>
> https://lists.webkit.org/mailman/listinfo/webkit-dev 
> <https://lists.webkit.org/mailman/listinfo/webkit-dev>
> 
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to