Title: [125576] trunk/Source/WebCore
- Revision
- 125576
- Author
- commit-qu...@webkit.org
- Date
- 2012-08-14 10:19:36 -0700 (Tue, 14 Aug 2012)
Log Message
[BlackBerry] Pass URL String's 8-bit buffer directly to platform layer when possible
https://bugs.webkit.org/show_bug.cgi?id=93861
Patch by Yong Li <y...@rim.com> on 2012-08-14
Reviewed by Rob Buis.
PR# 187605.
URL strings and HTTP header strings usually use 8-bit buffers internally. We can
just pass the buffers to platform calls when only Latin1 strings are needed.
* platform/blackberry/ReadOnlyLatin1String.h: Added.
(WebCore):
(ReadOnlyLatin1String): A utility class that uses either WTF::CString or WTF::String's 8-bit buffer.
(WebCore::ReadOnlyLatin1String::ReadOnlyLatin1String): Can only be constructed with WTF::String for now.
(WebCore::ReadOnlyLatin1String::data):
(WebCore::ReadOnlyLatin1String::length):
* platform/network/blackberry/ResourceRequestBlackBerry.cpp:
(WebCore::ResourceRequest::initializePlatformRequest):
* platform/network/blackberry/SocketStreamHandleBlackBerry.cpp:
(WebCore::SocketStreamHandle::SocketStreamHandle):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (125575 => 125576)
--- trunk/Source/WebCore/ChangeLog 2012-08-14 17:16:19 UTC (rev 125575)
+++ trunk/Source/WebCore/ChangeLog 2012-08-14 17:19:36 UTC (rev 125576)
@@ -1,3 +1,25 @@
+2012-08-14 Yong Li <y...@rim.com>
+
+ [BlackBerry] Pass URL String's 8-bit buffer directly to platform layer when possible
+ https://bugs.webkit.org/show_bug.cgi?id=93861
+
+ Reviewed by Rob Buis.
+
+ PR# 187605.
+ URL strings and HTTP header strings usually use 8-bit buffers internally. We can
+ just pass the buffers to platform calls when only Latin1 strings are needed.
+
+ * platform/blackberry/ReadOnlyLatin1String.h: Added.
+ (WebCore):
+ (ReadOnlyLatin1String): A utility class that uses either WTF::CString or WTF::String's 8-bit buffer.
+ (WebCore::ReadOnlyLatin1String::ReadOnlyLatin1String): Can only be constructed with WTF::String for now.
+ (WebCore::ReadOnlyLatin1String::data):
+ (WebCore::ReadOnlyLatin1String::length):
+ * platform/network/blackberry/ResourceRequestBlackBerry.cpp:
+ (WebCore::ResourceRequest::initializePlatformRequest):
+ * platform/network/blackberry/SocketStreamHandleBlackBerry.cpp:
+ (WebCore::SocketStreamHandle::SocketStreamHandle):
+
2012-08-14 Christophe Dumez <christophe.du...@intel.com>
Fix LayoutTests/canvas/philip/tests/2d.text.draw.space.collapse.nonspace.html
Added: trunk/Source/WebCore/platform/blackberry/ReadOnlyLatin1String.h (0 => 125576)
--- trunk/Source/WebCore/platform/blackberry/ReadOnlyLatin1String.h (rev 0)
+++ trunk/Source/WebCore/platform/blackberry/ReadOnlyLatin1String.h 2012-08-14 17:19:36 UTC (rev 125576)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef ReadOnlyLatin1String_h
+#define ReadOnlyLatin1String_h
+
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class ReadOnlyLatin1String {
+public:
+ explicit ReadOnlyLatin1String(const String& string)
+ {
+ if (string.is8Bit())
+ m_string = string;
+ else {
+ ASSERT(string.containsOnlyLatin1());
+ m_cstring = string.latin1();
+ }
+ }
+
+ const char* data() const { return m_string.isNull() ? m_cstring.data() : reinterpret_cast<const char*>(m_string.characters8()); }
+
+ size_t length() const { return m_string.isNull() ? m_cstring.length() : m_string.length(); }
+
+private:
+ String m_string;
+ CString m_cstring;
+};
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp (125575 => 125576)
--- trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp 2012-08-14 17:16:19 UTC (rev 125575)
+++ trunk/Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp 2012-08-14 17:19:36 UTC (rev 125576)
@@ -21,6 +21,7 @@
#include "BlobRegistryImpl.h"
#include "CookieManager.h"
+#include "ReadOnlyLatin1String.h"
#include <LocaleHandler.h>
#include <network/NetworkRequest.h>
#include <wtf/HashMap.h>
@@ -148,8 +149,10 @@
if (isInitial)
platformRequest.setRequestInitial(timeoutInterval());
else {
- platformRequest.setRequestUrl(url().string().utf8().data(),
- httpMethod().latin1().data(),
+ ReadOnlyLatin1String latin1URL(url().string());
+ ReadOnlyLatin1String latin1HttpMethod(httpMethod());
+ platformRequest.setRequestUrl(latin1URL.data(), latin1URL.length(),
+ latin1HttpMethod.data(), latin1HttpMethod.length(),
platformCachePolicyForRequest(*this),
platformTargetTypeForRequest(*this),
timeoutInterval());
@@ -198,12 +201,19 @@
String key = it->first;
String value = it->second;
if (!key.isEmpty()) {
- // We need to check the encoding and encode the cookie's value using latin1 or utf8 to support unicode characters.
- // We wo't use the old cookies of resourceRequest for new location because these cookies may be changed by redirection.
- if (!equalIgnoringCase(key, "Cookie"))
- platformRequest.addHeader(key.latin1().data(), value.latin1().data());
- else if (!cookieHeaderMayBeDirty)
- platformRequest.addHeader(key.latin1().data(), value.containsOnlyLatin1() ? value.latin1().data() : value.utf8().data());
+ if (equalIgnoringCase(key, "Cookie")) {
+ // We won't use the old cookies of resourceRequest for new location because these cookies may be changed by redirection.
+ if (cookieHeaderMayBeDirty)
+ continue;
+ // We need to check the encoding and encode the cookie's value using latin1 or utf8 to support unicode data.
+ if (!value.containsOnlyLatin1()) {
+ platformRequest.addHeader("Cookie", value.utf8().data());
+ continue;
+ }
+ }
+ ReadOnlyLatin1String latin1Key(key);
+ ReadOnlyLatin1String latin1Value(value);
+ platformRequest.addHeader(latin1Key.data(), latin1Key.length(), latin1Value.data(), latin1Value.length());
}
}
Modified: trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp (125575 => 125576)
--- trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp 2012-08-14 17:16:19 UTC (rev 125575)
+++ trunk/Source/WebCore/platform/network/blackberry/SocketStreamHandleBlackBerry.cpp 2012-08-14 17:19:36 UTC (rev 125576)
@@ -39,6 +39,7 @@
#include "Page.h"
#include "PageClientBlackBerry.h"
#include "PageGroup.h"
+#include "ReadOnlyLatin1String.h"
#include "SocketStreamError.h"
#include "SocketStreamHandleClient.h"
@@ -70,7 +71,8 @@
// Open the socket
BlackBerry::Platform::NetworkRequest request;
- request.setRequestUrl(url.string().latin1().data(), "CONNECT");
+ ReadOnlyLatin1String latin1URL(url.string());
+ request.setRequestUrl(latin1URL.data(), latin1URL.length(), "CONNECT", 7);
m_socketStream->setRequest(request);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes