ThreadableWebSocketChannelClientWrapper shouldn't have a String in it.
authoryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 13:25:18 +0000 (13:25 +0000)
committeryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 13:25:18 +0000 (13:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67908

Reviewed by David Levin.

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

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>.
(WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol):
Copy the content of the given String into Vector.
* websockets/ThreadableWebSocketChannelClientWrapper.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@95025 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h

index 9ed4c78..ec81d8c 100644 (file)
@@ -1,3 +1,23 @@
+2011-09-13  Yuta Kitamura  <yutak@chromium.org>
+
+        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>.
+
+        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>.
+        (WebCore::ThreadableWebSocketChannelClientWrapper::setSubprotocol):
+        Copy the content of the given String into Vector.
+        * websockets/ThreadableWebSocketChannelClientWrapper.h:
+
 2011-09-13  Fumitoshi Ukai  <ukai@chromium.org>
 
         Unreviewed, build fix.
index 2eecc69..2d6d1dd 100644 (file)
@@ -44,7 +44,6 @@ ThreadableWebSocketChannelClientWrapper::ThreadableWebSocketChannelClientWrapper
     : m_client(client)
     , m_syncMethodDone(false)
     , m_useHixie76Protocol(true)
-    , m_subprotocol("")
     , m_sendRequestResult(false)
     , m_bufferedAmount(0)
     , m_suspended(false)
@@ -83,12 +82,15 @@ void ThreadableWebSocketChannelClientWrapper::setUseHixie76Protocol(bool useHixi
 
 String ThreadableWebSocketChannelClientWrapper::subprotocol() const
 {
-    return m_subprotocol;
+    return String(m_subprotocol);
 }
 
 void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subprotocol)
 {
-    m_subprotocol = subprotocol;
+    unsigned length = subprotocol.length();
+    m_subprotocol.resize(length);
+    if (length)
+        memcpy(m_subprotocol.data(), subprotocol.characters(), sizeof(UChar) * length);
 }
 
 bool ThreadableWebSocketChannelClientWrapper::sendRequestResult() const
index dd3e6a7..5050ddc 100644 (file)
@@ -93,7 +93,7 @@ protected:
     WebSocketChannelClient* m_client;
     bool m_syncMethodDone;
     bool m_useHixie76Protocol;
-    String m_subprotocol;
+    Vector<UChar> m_subprotocol;
     bool m_sendRequestResult;
     unsigned long m_bufferedAmount;
     bool m_suspended;