Changeset 95176 in webkit


Ignore:
Timestamp:
Sep 15, 2011 12:41:02 AM (13 years ago)
Author:
yutak@chromium.org
Message:

ThreadableWebSocketChannelClientWrapper shouldn't have a String in it.
https://bugs.webkit.org/show_bug.cgi?id=67908

Reviewed by David Levin.

Replace a String member variable in ThreadableWebSocketChannelClientWrapper with Vector<UChar>.

ThreadableWebSocketChannelClientWrapper is derived from ThreadSafeRefCounted. It may be
destroyed on different threads, which will affect String's refcounting. Therefore, classes
derived from ThreadSafeRefCounted must not have a String member variable.

No change in functionality, thus no new tests. WebSocket worker tests
(tests under http/tests/websocket/tests/{hixie76,hybi}/workers/) should keep passing.

  • websockets/ThreadableWebSocketChannelClientWrapper.cpp:

(WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
(WebCore::ThreadableWebSocketChannelClientWrapper::subprotocol):
Create a String from Vector<UChar>. Note that String constructor taking an empty vector returns
a null string, not an empty string. We want an empty string in that case, so I had to add
special-case handling for an empty vector.
(WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol):
Copy the content of the given String into Vector.

  • websockets/ThreadableWebSocketChannelClientWrapper.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95174 r95176  
     12011-09-15  Yuta Kitamura  <yutak@chromium.org>
     2
     3        ThreadableWebSocketChannelClientWrapper shouldn't have a String in it.
     4        https://bugs.webkit.org/show_bug.cgi?id=67908
     5
     6        Reviewed by David Levin.
     7
     8        Replace a String member variable in ThreadableWebSocketChannelClientWrapper with Vector<UChar>.
     9
     10        ThreadableWebSocketChannelClientWrapper is derived from ThreadSafeRefCounted. It may be
     11        destroyed on different threads, which will affect String's refcounting. Therefore, classes
     12        derived from ThreadSafeRefCounted must not have a String member variable.
     13
     14        No change in functionality, thus no new tests. WebSocket worker tests
     15        (tests under http/tests/websocket/tests/{hixie76,hybi}/workers/) should keep passing.
     16
     17        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
     18        (WebCore::ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper):
     19        (WebCore::ThreadableWebSocketChannelClientWrapper::subprotocol):
     20        Create a String from Vector<UChar>. Note that String constructor taking an empty vector returns
     21        a null string, not an empty string. We want an empty string in that case, so I had to add
     22        special-case handling for an empty vector.
     23        (WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol):
     24        Copy the content of the given String into Vector.
     25        * websockets/ThreadableWebSocketChannelClientWrapper.h:
     26
    1272011-09-14  Matthew Delaney  <mdelaney@apple.com>
    228
  • trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp

    r95026 r95176  
    4545    , m_syncMethodDone(false)
    4646    , m_useHixie76Protocol(true)
    47     , m_subprotocol("")
    4847    , m_sendRequestResult(false)
    4948    , m_bufferedAmount(0)
     
    8483String ThreadableWebSocketChannelClientWrapper::subprotocol() const
    8584{
    86     return m_subprotocol;
     85    if (m_subprotocol.isEmpty())
     86        return String("");
     87    return String(m_subprotocol);
    8788}
    8889
    8990void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subprotocol)
    9091{
    91     m_subprotocol = subprotocol;
     92    unsigned length = subprotocol.length();
     93    m_subprotocol.resize(length);
     94    if (length)
     95        memcpy(m_subprotocol.data(), subprotocol.characters(), sizeof(UChar) * length);
    9296}
    9397
  • trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h

    r95026 r95176  
    9494    bool m_syncMethodDone;
    9595    bool m_useHixie76Protocol;
    96     String m_subprotocol;
     96    Vector<UChar> m_subprotocol; // ThreadSafeRefCounted must not have a String member variable.
    9797    bool m_sendRequestResult;
    9898    unsigned long m_bufferedAmount;
Note: See TracChangeset for help on using the changeset viewer.