There currently exists a class called RefCountedHFONT, which wraps a GDI HFONT in a reference-counted container. There is a need to reference count other GDI handles in the Windows port, so it would be useful to have a generic class that can reference count any GDI handle.
Created attachment 54003 [details]
Attachment 54003 [details] did not pass style-queue:
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebCore/platform/graphics/cairo/FontPlatformData.h:41: Alphabetical sorting problem. [build/include_order] 
Total errors found: 1 in 7 files
If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 54003 [details]
This is OK as is, but there is one thing we should improve. The hash function here should be:
Once you change it to work that way you can remove the include of StringImpl.h.
If this wasn't all inlined, I would also suggest making a base class, since the only functions in RefCountedGDIHandle that are different based on type are the create() function, the constructor, and the handle() function. But since everything is inlined anyway, I don't think there's any real benefit to doing so.
Committed revision 58045.
Using OwnPtr in the implementation of your new class template would have made things even simpler, and would allow this class template to be used for non-GDI objects.