<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [Curl] WebSocket platform part is not implemented."
   href="https://bugs.webkit.org/show_bug.cgi?id=144628#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [Curl] WebSocket platform part is not implemented."
   href="https://bugs.webkit.org/show_bug.cgi?id=144628">bug 144628</a>
              from <span class="vcard"><a class="email" href="mailto:peavo&#64;outlook.com" title="peavo&#64;outlook.com">peavo&#64;outlook.com</a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=144628#c10">comment #10</a>)
<span class="quote">&gt; Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=252729&amp;action=diff" name="attach_252729" title="Patch">attachment 252729</a> <a href="attachment.cgi?id=252729&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; </span >

Thank you for your patience :)

<span class="quote">&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=252729&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=252729&amp;action=review</a>
&gt; 
&gt; lets not use this unnecessary std::unique_ptr
&gt; 
&gt; &gt; Source/WebCore/platform/network/curl/SocketStreamHandle.h:48
&gt; &gt; +#if PLATFORM(WIN)
&gt; &gt; +#include &lt;windows.h&gt;
&gt; &gt; +#include &lt;winsock2.h&gt;
&gt; &gt; +#endif
&gt; &gt; +
&gt; &gt; +#include &lt;curl/curl.h&gt;
&gt; &gt; +
&gt; &gt; +#include &lt;mutex&gt;
&gt; &gt; +
&gt; &gt; +#include &lt;wtf/Deque.h&gt;
&gt; &gt;  #include &lt;wtf/RefCounted.h&gt;
&gt; &gt; +#include &lt;wtf/Threading.h&gt;
&gt; 
&gt; These aren’t sorted in the normal WebKit project way.
&gt; </span >

winsock2.h is needed before curl.h is included, so I kept this.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp:51
&gt; &gt; +    startThread();
&gt; 
&gt; Should probably ASSERT(isMainThread()) here.
&gt; 
&gt; But also, why do we need to start the thread? I don’t think we do.
&gt; </span >

startThread() seems to be needed here, many tests timed out without it.

<span class="quote">&gt; 
&gt; &gt; Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp:70
&gt; &gt; +    std::unique_ptr&lt;const char[]&gt; copy(new const char[length]);
&gt; &gt; +    memcpy(const_cast&lt;char*&gt;(copy.get()), data, length);
&gt; 
&gt; Should be able to allocate a std::unique_ptr&lt;char[]&gt; and then pass it to a
&gt; function expecting a std::unique_ptr&lt;const char[]&gt; and have it be converted.
&gt; We’d avoid a const_cast that way.</span >
&gt;

MSVC didn't want to convert this, I got the error:

error C2664: 'std::unique_ptr&lt;const char [],std::default_delete&lt;_Ty&gt;&gt;::unique_ptr(const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' : 
cannot convert argument 1 from 'std::unique_ptr&lt;char [],std::default_delete&lt;_Ty&gt;&gt;' to 'std::unique_ptr&lt;const char [],std::default_delete&lt;_Ty&gt;&gt; &amp;&amp;'


<span class="quote">&gt; 
&gt; &gt; Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp:200
&gt; &gt; +            if (refCount() &gt; 1)
&gt; &gt; +                didOpenSocket();
&gt; 
&gt; This check of refCount is peculiar. Is this an important optimization?
&gt; </span >

I'm also not too happy with this :) I added it to fix a crash where the call was invoked on the main thread after all other references were released, and the SocketStreamClient was deleted. Accessing the SocketStreamClient in didOpenSocket() then caused a crash.

I had to add a SocketData constructor since m_sendData.append(SocketData { WTF::move(copy), length }) didn't compile with MSVC. The error I got was:

error C2440 : '&lt;function-style-cast&gt;' : cannot convert from 'initializer-list' to 'WebCore::SocketStreamHandle::SocketData'
1&gt;          No constructor could take the source type, or constructor overload resolution was ambiguous

I also had to add a move constructor, otherwise I got an error stating that 
Deque.h (line 422) was trying to reference the deleted unique_ptr copy constructor.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>