<?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>55334</bug_id>
          
          <creation_ts>2011-02-27 15:23:31 -0800</creation_ts>
          <short_desc>Add a handler class for Win32 HANDLE</short_desc>
          <delta_ts>2011-03-01 14:38:35 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</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>
          
          <blocked>55336</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick R. Gansterer">paroga</reporter>
          <assigned_to name="Patrick R. Gansterer">paroga</assigned_to>
          <cc>aroben</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>358802</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick R. Gansterer">paroga</who>
    <bug_when>2011-02-27 15:23:31 -0800</bug_when>
    <thetext>see patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>358805</commentid>
    <comment_count>1</comment_count>
      <attachid>83998</attachid>
    <who name="Patrick R. Gansterer">paroga</who>
    <bug_when>2011-02-27 15:28:39 -0800</bug_when>
    <thetext>Created attachment 83998
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>358987</commentid>
    <comment_count>2</comment_count>
      <attachid>83998</attachid>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2011-02-28 05:10:46 -0800</bug_when>
    <thetext>Comment on attachment 83998
Patch

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

r=me, but I&apos;m not marking it cq+ because I think you should make a few changes.

&gt; Source/WebCore/platform/win/Win32Handle.h:36
&gt; +    explicit Win32Handle(HANDLE handle) : m_handle(handle) { }

It would be nice if we could be more explicit that this function adopts the passed-in HANDLE.

&gt; Source/WebCore/platform/win/Win32Handle.h:44
&gt; +        CloseHandle(m_handle);

Is it OK to call CloseHandle(0)?

&gt; Source/WebCore/platform/win/Win32Handle.h:50
&gt; +    operator HANDLE() const { return m_handle; }

I don&apos;t think we need this. We can just use .get() instead. That would match our WTF smart pointers better.

&gt; Source/WebCore/platform/win/Win32Handle.h:59
&gt; +    Win32Handle&amp; operator=(Win32Handle&amp; other) { swap(other); }

This is surprising behavior. I think it would make more sense just to make Win32Handle be non-copyable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>359016</commentid>
    <comment_count>3</comment_count>
      <attachid>83998</attachid>
    <who name="Patrick R. Gansterer">paroga</who>
    <bug_when>2011-02-28 06:13:20 -0800</bug_when>
    <thetext>Comment on attachment 83998
Patch

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

&gt;&gt; Source/WebCore/platform/win/Win32Handle.h:36
&gt;&gt; +    explicit Win32Handle(HANDLE handle) : m_handle(handle) { }
&gt; 
&gt; It would be nice if we could be more explicit that this function adopts the passed-in HANDLE.

Should I create a adoptWin32Handle ?!? Then this class can&apos;t be non-copyable or we need PassWin32Handle too?

&gt;&gt; Source/WebCore/platform/win/Win32Handle.h:44
&gt;&gt; +        CloseHandle(m_handle);
&gt; 
&gt; Is it OK to call CloseHandle(0)?

When will m_handle become 0?

&gt;&gt; Source/WebCore/platform/win/Win32Handle.h:50
&gt;&gt; +    operator HANDLE() const { return m_handle; }
&gt; 
&gt; I don&apos;t think we need this. We can just use .get() instead. That would match our WTF smart pointers better.

I don&apos;t like to use .get() all the time, but it makes sense to match the OwnPtr interface.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>359029</commentid>
    <comment_count>4</comment_count>
      <attachid>83998</attachid>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2011-02-28 07:11:16 -0800</bug_when>
    <thetext>Comment on attachment 83998
Patch

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

&gt;&gt;&gt; Source/WebCore/platform/win/Win32Handle.h:36
&gt;&gt;&gt; +    explicit Win32Handle(HANDLE handle) : m_handle(handle) { }
&gt;&gt; 
&gt;&gt; It would be nice if we could be more explicit that this function adopts the passed-in HANDLE.
&gt; 
&gt; Should I create a adoptWin32Handle ?!? Then this class can&apos;t be non-copyable or we need PassWin32Handle too?

Yeah, I&apos;m not sure what the best idiom here is. I think what you have now is fine.

&gt;&gt;&gt; Source/WebCore/platform/win/Win32Handle.h:44
&gt;&gt;&gt; +        CloseHandle(m_handle);
&gt;&gt; 
&gt;&gt; Is it OK to call CloseHandle(0)?
&gt; 
&gt; When will m_handle become 0?

It could be 0 if someone passed 0 to the constructor.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>360219</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2011-03-01 14:13:33 -0800</bug_when>
    <thetext>The version of this patch that landed in r80034 has neither a copy constructor nor the WTF_MAKE_NONCOPYABLE macro. This means the compiler will generate a default copy constructor, which will do the wrong thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>360220</commentid>
    <comment_count>6</comment_count>
    <who name="Patrick R. Gansterer">paroga</who>
    <bug_when>2011-03-01 14:14:42 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; The version of this patch that landed in r80034 has neither a copy constructor nor the WTF_MAKE_NONCOPYABLE macro. This means the compiler will generate a default copy constructor, which will do the wrong thing.
Argh! Missed to add the macro :-(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>360245</commentid>
    <comment_count>7</comment_count>
    <who name="Patrick R. Gansterer">paroga</who>
    <bug_when>2011-03-01 14:37:48 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; The version of this patch that landed in r80034 has neither a copy constructor nor the WTF_MAKE_NONCOPYABLE macro. This means the compiler will generate a default copy constructor, which will do the wrong thing.

Sorry again, committed r80042: &lt;http://trac.webkit.org/changeset/80042&gt;


(In reply to comment #4)
&gt; &gt;&gt; Is it OK to call CloseHandle(0)?
&gt; &gt; 
&gt; &gt; When will m_handle become 0?
&gt; 
&gt; It could be 0 if someone passed 0 to the constructor.

IMHO passing 0 is not right correct, but there&apos;s no problem to call CloseHandle(0). It will set GetLastError() to sth like &quot;called with invalid handle&quot; only.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>360246</commentid>
    <comment_count>8</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2011-03-01 14:38:35 -0800</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #4)
&gt; &gt; &gt;&gt; Is it OK to call CloseHandle(0)?
&gt; &gt; &gt; 
&gt; &gt; &gt; When will m_handle become 0?
&gt; &gt; 
&gt; &gt; It could be 0 if someone passed 0 to the constructor.
&gt; 
&gt; IMHO passing 0 is not right correct, but there&apos;s no problem to call CloseHandle(0). It will set GetLastError() to sth like &quot;called with invalid handle&quot; only.

If we don&apos;t want to allow 0, we could add an assertion.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>83998</attachid>
            <date>2011-02-27 15:28:39 -0800</date>
            <delta_ts>2011-02-28 07:11:16 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-55334.patch</filename>
            <type>text/plain</type>
            <size>3227</size>
            <attacher name="Patrick R. Gansterer">paroga</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppb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zJI
YW5kbGUoKSB7IGNsZWFyKCk7IH0KKworICAgIHZvaWQgY2xlYXIoKQorICAgIHsKKyAgICAgICAg
aWYgKCFpc1ZhbGlkKCkpCisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIENsb3NlSGFuZGxl
KG1faGFuZGxlKTsKKyAgICAgICAgbV9oYW5kbGUgPSBJTlZBTElEX0hBTkRMRV9WQUxVRTsKKyAg
ICB9CisKKyAgICBib29sIGlzVmFsaWQoKSBjb25zdCB7IHJldHVybiBtX2hhbmRsZSAhPSBJTlZB
TElEX0hBTkRMRV9WQUxVRTsgfQorCisgICAgb3BlcmF0b3IgSEFORExFKCkgY29uc3QgeyByZXR1
cm4gbV9oYW5kbGU7IH0KKyAgICBIQU5ETEUgZ2V0KCkgY29uc3QgeyByZXR1cm4gbV9oYW5kbGU7
IH0KKyAgICBIQU5ETEUgcmVsZWFzZSgpIHsgSEFORExFIHJldCA9IG1faGFuZGxlOyBtX2hhbmRs
ZSA9IElOVkFMSURfSEFORExFX1ZBTFVFOyByZXR1cm4gcmV0OyB9CisKKyAgICBXaW4zMkhhbmRs
ZSYgb3BlcmF0b3I9KEhBTkRMRSBoYW5kbGUpCisgICAgeworICAgICAgICBjbGVhcigpOworICAg
ICAgICBtX2hhbmRsZSA9IGhhbmRsZTsKKyAgICB9CisgICAgV2luMzJIYW5kbGUmIG9wZXJhdG9y
PShXaW4zMkhhbmRsZSYgb3RoZXIpIHsgc3dhcChvdGhlcik7IH0KKyAgICB2b2lkIHN3YXAoV2lu
MzJIYW5kbGUmIG90aGVyKSB7IHN0ZDo6c3dhcChtX2hhbmRsZSwgb3RoZXIubV9oYW5kbGUpOyB9
CisKK3ByaXZhdGU6CisgICAgSEFORExFIG1faGFuZGxlOworfTsKKworfSAvLyBuYW1lc3BhY2Ug
V2ViQ29yZQorCisjZW5kaWYgLy8gV2luMzJIYW5kbGVfaAo=
</data>
<flag name="review"
          id="75917"
          type_id="1"
          status="+"
          setter="aroben"
    />
          </attachment>
      

    </bug>

</bugzilla>