<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>136613</bug_id>
          
          <creation_ts>2014-09-07 14:33:24 -0700</creation_ts>
          <short_desc>Make OSObjectPtr a bit more like RefPtr</short_desc>
          <delta_ts>2014-10-03 17:37:46 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>136636</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sam Weinig">sam</reporter>
          <assigned_to name="Sam Weinig">sam</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>koivisto</cc>
    
    <cc>mitz</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1033752</commentid>
    <comment_count>0</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-07 14:33:24 -0700</bug_when>
    <thetext>Make OSObjectPtr a bit more like RefPtr</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033753</commentid>
    <comment_count>1</comment_count>
      <attachid>237757</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-07 14:35:49 -0700</bug_when>
    <thetext>Created attachment 237757
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033755</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-07 14:36:56 -0700</bug_when>
    <thetext>This bug is for addressing the feedback in https://bugs.webkit.org/show_bug.cgi?id=136613.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033756</commentid>
    <comment_count>3</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-07 14:39:27 -0700</bug_when>
    <thetext>Two things I didn&apos;t do were:
- Remove the specialization for nullptr as I don&apos;t trust compilers :).
- Made it share code with RefPtr, as that would be a much bigger task.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033764</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2014-09-07 18:01:07 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; - Remove the specialization for nullptr as I don&apos;t trust compilers :).

But you didn’t add one for RefPtr. You trust compilers only with a class that we use extensively across the entire project, not with a class that’s far less often used?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033766</commentid>
    <comment_count>5</comment_count>
      <attachid>237757</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2014-09-07 18:03:08 -0700</bug_when>
    <thetext>Comment on attachment 237757
Patch

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

&gt; Source/WTF/wtf/OSObjectPtr.h:52
&gt;  struct AdoptOSObject { };

Now that this is not part of the public API of OSObjectPtr, could make this struct a private member of the OSObjectPtr class. Would be tidier.

&gt; Source/WTF/wtf/OSObjectPtr.h:122
&gt; +    OSObjectPtr&amp; operator=(const OSObjectPtr&amp;&amp; other)

Unwanted const here prevents the patch from compiling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033882</commentid>
    <comment_count>6</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-08 10:15:26 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; - Remove the specialization for nullptr as I don&apos;t trust compilers :).
&gt; 
&gt; But you didn’t add one for RefPtr. You trust compilers only with a class that we use extensively across the entire project, not with a class that’s far less often used?

I&apos;m writing some test code to figure out if it really is the same. When I finish that experiment, I will either add the code to RefPtr, or remove it from OSObjectPtr.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033883</commentid>
    <comment_count>7</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-08 10:16:09 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (From update of attachment 237757 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=237757&amp;action=review
&gt; 
&gt; &gt; Source/WTF/wtf/OSObjectPtr.h:52
&gt; &gt;  struct AdoptOSObject { };
&gt; 
&gt; Now that this is not part of the public API of OSObjectPtr, could make this struct a private member of the OSObjectPtr class. Would be tidier.

Will fix.

&gt; 
&gt; &gt; Source/WTF/wtf/OSObjectPtr.h:122
&gt; &gt; +    OSObjectPtr&amp; operator=(const OSObjectPtr&amp;&amp; other)
&gt; 
&gt; Unwanted const here prevents the patch from compiling.

Do&apos;h.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033888</commentid>
    <comment_count>8</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-08 10:26:44 -0700</bug_when>
    <thetext>Committed r173383: &lt;http://trac.webkit.org/changeset/173383&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033893</commentid>
    <comment_count>9</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2014-09-08 10:38:20 -0700</bug_when>
    <thetext>Hopeful build fix in http://trac.webkit.org/changeset/173384</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033896</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2014-09-08 11:00:50 -0700</bug_when>
    <thetext>Re-opened since this is blocked by bug 136636</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1037483</commentid>
    <comment_count>11</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2014-09-26 08:25:13 -0700</bug_when>
    <thetext>How is this better than just having adoptOSObject() function for RetainPtr? That&apos;s what I was doing before discovering this and it seemed to work fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1037549</commentid>
    <comment_count>12</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-09-26 13:44:36 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; How is this better than just having adoptOSObject() function for RetainPtr? That&apos;s what I was doing before discovering this and it seemed to work fine.

It&apos;s not. And I will be rolling this out pretty soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1037645</commentid>
    <comment_count>13</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2014-09-27 00:10:03 -0700</bug_when>
    <thetext>This seemed to work on all platforms:

+    template&lt;typename T&gt; inline RetainPtr&lt;T&gt; adoptSystem(T ptr)
+    {
+#if OS_OBJECT_USE_OBJC
+        return adoptNS(ptr);
+#else
+        return adoptCF(ptr);
+#endif
+    }
+</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1039420</commentid>
    <comment_count>14</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2014-10-03 17:37:46 -0700</bug_when>
    <thetext>(In reply to comment #13)
&gt; This seemed to work on all platforms:
&gt; 
&gt; +    template&lt;typename T&gt; inline RetainPtr&lt;T&gt; adoptSystem(T ptr)
&gt; +    {
&gt; +#if OS_OBJECT_USE_OBJC
&gt; +        return adoptNS(ptr);
&gt; +#else
&gt; +        return adoptCF(ptr);
&gt; +#endif
&gt; +    }
&gt; +

Actually, I don&apos;t believe this actually works.  In 32-bit, OS-objects are not objective-c objects, but also not CFObjects, so they can&apos;t be CFRetain()/CFReleased().  I think we are going to need to stick with OSObjectPtr for now.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>237757</attachid>
            <date>2014-09-07 14:35:49 -0700</date>
            <delta_ts>2014-09-07 18:03:07 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-136613-20140907143544.patch</filename>
            <type>text/plain</type>
            <size>2372</size>
            <attacher name="Sam Weinig">sam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XVEYvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJjZS9XVEYvQ2hh
bmdlTG9nCShyZXZpc2lvbiAxNzMzNjgpCisrKyBTb3VyY2UvV1RGL0NoYW5nZUxvZwkod29ya2lu
ZyBjb3B5KQpAQCAtMSwzICsxLDIwIEBACisyMDE0LTA5LTA3ICBTYW0gV2VpbmlnICA8c2FtQHdl
YmtpdC5vcmc+CisKKyAgICAgICAgTWFrZSBPU09iamVjdFB0ciBhIGJpdCBtb3JlIGxpa2UgUmVm
UHRyCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xMzY2
MTMKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBBZGRy
ZXNzIHNvbWUgb2YgRGFyaW4ncyBmZWVkYmFjayBieToKKyAgICAgICAgLSBNYWtpbmcgdGhlIGFk
b3B0aW5nIGNvbnN0cnVjdG9yIHByaXZhdGUgYW5kIGZyaWVuZGluZyBhZG9wdE9TT2JqZWN0KCku
CisgICAgICAgIC0gSW1wbGVtZW50aW5nIHRoZSBhc3NpZ25tZW50IG9wZXJhdG9yIHVzaW5nIHN3
YXAuCisgICAgICAgIC0gQWRkaW5nIGEgbW92ZSBhc3NpZ25tZW50IG9wZXJhdG9yLgorCisgICAg
ICAgICogd3RmL09TT2JqZWN0UHRyLmg6CisgICAgICAgIChXVEY6Ok9TT2JqZWN0UHRyOjpvcGVy
YXRvcj0pOgorICAgICAgICAoV1RGOjpPU09iamVjdFB0cjo6c3dhcCk6CisgICAgICAgIChXVEY6
Ok9TT2JqZWN0UHRyOjpPU09iamVjdFB0cik6CisKIDIwMTQtMDktMDYgIFNhbSBXZWluaWcgIDxz
YW1Ad2Via2l0Lm9yZz4KIAogICAgICAgICBYUENQdHIgc2hvdWxkIGJlIGNvbnZlcnRlZCBpbnRv
IGFuIGFsbCBwdXJwb3NlIHNtYXJ0IHBvaW50ZXIgZm9yIG9zX29iamVjdHMKSW5kZXg6IFNvdXJj
ZS9XVEYvd3RmL09TT2JqZWN0UHRyLmgKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291cmNlL1dURi93dGYvT1NP
YmplY3RQdHIuaAkocmV2aXNpb24gMTczMzY3KQorKysgU291cmNlL1dURi93dGYvT1NPYmplY3RQ
dHIuaAkod29ya2luZyBjb3B5KQpAQCAtNTAsNiArNTAsOCBAQCBleHRlcm4gIkMiIHZvaWQgX29z
X29iamVjdF9yZWxlYXNlKF9vc19vCiBuYW1lc3BhY2UgV1RGIHsKIAogc3RydWN0IEFkb3B0T1NP
YmplY3QgeyB9OwordGVtcGxhdGU8dHlwZW5hbWUgVD4gY2xhc3MgT1NPYmplY3RQdHI7Cit0ZW1w
bGF0ZTx0eXBlbmFtZSBUPiBPU09iamVjdFB0cjxUPiBhZG9wdE9TT2JqZWN0KFQpOwogCiB0ZW1w
bGF0ZTx0eXBlbmFtZSBUPgogc3RhdGljIGlubGluZSB2b2lkIHJldGFpbk9TT2JqZWN0KFQgcHRy
KQpAQCAtODYsMTEgKzg4LDYgQEAgcHVibGljOgogICAgIHsKICAgICB9CiAKLSAgICBPU09iamVj
dFB0cihBZG9wdE9TT2JqZWN0LCBUIHB0cikKLSAgICAgICAgOiBtX3B0cihwdHIpCi0gICAgewot
ICAgIH0KLQogICAgIH5PU09iamVjdFB0cigpCiAgICAgewogICAgICAgICBpZiAobV9wdHIpCkBA
IC0xMTcsMTYgKzExNCwxNSBAQCBwdWJsaWM6CiAKICAgICBPU09iamVjdFB0ciYgb3BlcmF0b3I9
KGNvbnN0IE9TT2JqZWN0UHRyJiBvdGhlcikKICAgICB7Ci0gICAgICAgIFQgb3B0ciA9IG90aGVy
LmdldCgpOwotICAgICAgICBpZiAob3B0cikKLSAgICAgICAgICAgIHJldGFpbk9TT2JqZWN0KG9w
dHIpOwotCi0gICAgICAgIFQgcHRyID0gbV9wdHI7Ci0gICAgICAgIG1fcHRyID0gb3B0cjsKLQot
ICAgICAgICBpZiAocHRyKQotICAgICAgICAgICAgcmVsZWFzZU9TT2JqZWN0KHB0cik7CisgICAg
ICAgIE9TT2JqZWN0UHRyIHB0ciA9IG90aGVyOworICAgICAgICBzd2FwKHB0cik7CisgICAgICAg
IHJldHVybiAqdGhpczsKKyAgICB9CiAKKyAgICBPU09iamVjdFB0ciYgb3BlcmF0b3I9KGNvbnN0
IE9TT2JqZWN0UHRyJiYgb3RoZXIpCisgICAgeworICAgICAgICBPU09iamVjdFB0ciBwdHIgPSBX
VEY6Om1vdmUob3RoZXIpOworICAgICAgICBzd2FwKHB0cik7CiAgICAgICAgIHJldHVybiAqdGhp
czsKICAgICB9CiAKQEAgLTEzOCw3ICsxMzQsMjAgQEAgcHVibGljOgogCiAgICAgICAgIHJldHVy
biAqdGhpczsKICAgICB9CisKKyAgICB2b2lkIHN3YXAoT1NPYmplY3RQdHImIG90aGVyKQorICAg
IHsKKyAgICAgICAgc3RkOjpzd2FwKG1fcHRyLCBvdGhlci5tX3B0cik7CisgICAgfQorCisgICAg
ZnJpZW5kIE9TT2JqZWN0UHRyIGFkb3B0T1NPYmplY3Q8VD4oVCk7CisKIHByaXZhdGU6CisgICAg
T1NPYmplY3RQdHIoQWRvcHRPU09iamVjdCwgVCBwdHIpCisgICAgICAgIDogbV9wdHIocHRyKQor
ICAgIHsKKyAgICB9CisKICAgICBUIG1fcHRyOwogfTsKIAo=
</data>
<flag name="review"
          id="262495"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>