Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (89320 => 89321)
--- trunk/Source/WebCore/CMakeLists.txt 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-06-21 00:36:27 UTC (rev 89321)
@@ -1042,7 +1042,7 @@
platform/ScrollbarThemeComposite.cpp
platform/ScrollView.cpp
platform/SharedBuffer.cpp
- platform/SharedBufferCRLFLineReader.cpp
+ platform/SharedBufferChunkReader.cpp
platform/SchemeRegistry.cpp
platform/ThreadGlobalData.cpp
platform/ThreadTimers.cpp
Modified: trunk/Source/WebCore/ChangeLog (89320 => 89321)
--- trunk/Source/WebCore/ChangeLog 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/ChangeLog 2011-06-21 00:36:27 UTC (rev 89321)
@@ -1,3 +1,32 @@
+2011-06-20 Jay Civelli <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Making SharedBufferCRLFLineReader more generic, so it can be used to read MHTML
+ file with binary parts.
+ https://bugs.webkit.org/show_bug.cgi?id=62966
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/archive/mhtml/MHTMLParser.cpp:
+ (WebCore::skipLinesUntilBoundaryFound):
+ (WebCore::MHTMLParser::MHTMLParser):
+ (WebCore::MHTMLParser::parseNextPart):
+ * loader/archive/mhtml/MHTMLParser.h:
+ * platform/SharedBufferChunkReader.cpp: Renamed from Source/WebCore/platform/SharedBufferCRLFLineReader.cpp.
+ (WebCore::SharedBufferChunkReader::SharedBufferChunkReader):
+ (WebCore::SharedBufferChunkReader::setSeparator):
+ (WebCore::SharedBufferChunkReader::nextChunk):
+ * platform/SharedBufferChunkReader.h: Renamed from Source/WebCore/platform/SharedBufferCRLFLineReader.h.
+ * platform/network/MIMEHeader.cpp:
+ (WebCore::retrieveKeyValuePairs):
+ (WebCore::MIMEHeader::parseHeader):
+ * platform/network/MIMEHeader.h:
+
2011-06-20 Martin Robinson <[email protected]>
Reviewed by Xan Lopez.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (89320 => 89321)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-06-21 00:36:27 UTC (rev 89321)
@@ -2743,8 +2743,8 @@
Source/WebCore/platform/SecureTextInput.h \
Source/WebCore/platform/SharedBuffer.cpp \
Source/WebCore/platform/SharedBuffer.h \
- Source/WebCore/platform/SharedBufferCRLFLineReader.cpp \
- Source/WebCore/platform/SharedBufferCRLFLineReader.h \
+ Source/WebCore/platform/SharedBufferChunkReader.cpp \
+ Source/WebCore/platform/SharedBufferChunkReader.h \
Source/WebCore/platform/SharedTimer.h \
Source/WebCore/platform/Sound.h \
Source/WebCore/platform/sql/SQLiteAuthorizer.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (89320 => 89321)
--- trunk/Source/WebCore/WebCore.gypi 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/WebCore.gypi 2011-06-21 00:36:27 UTC (rev 89321)
@@ -788,7 +788,7 @@
'platform/ScrollbarTheme.h',
'platform/SearchPopupMenu.h',
'platform/SharedBuffer.h',
- 'platform/SharedBufferCRLFLineReader.h',
+ 'platform/SharedBufferChunkReader.h',
'platform/SystemTime.h',
'platform/Theme.h',
'platform/ThemeTypes.h',
@@ -3670,7 +3670,7 @@
'platform/SecureTextInput.cpp',
'platform/SecureTextInput.h',
'platform/SharedBuffer.cpp',
- 'platform/SharedBufferCRLFLineReader.cpp',
+ 'platform/SharedBufferChunkReader.cpp',
'platform/SharedTimer.h',
'platform/Sound.h',
'platform/SuddenTermination.h',
Modified: trunk/Source/WebCore/WebCore.pro (89320 => 89321)
--- trunk/Source/WebCore/WebCore.pro 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/WebCore.pro 2011-06-21 00:36:27 UTC (rev 89321)
@@ -1061,7 +1061,7 @@
platform/ScrollView.cpp \
platform/text/SegmentedString.cpp \
platform/SharedBuffer.cpp \
- platform/SharedBufferCRLFLineReader.cpp \
+ platform/SharedBufferChunkReader.cpp \
platform/text/String.cpp \
platform/text/TextBoundaries.cpp \
platform/text/TextCodec.cpp \
@@ -2077,7 +2077,7 @@
platform/ScrollView.h \
platform/SearchPopupMenu.h \
platform/SharedBuffer.h \
- platform/SharedBufferCRLFLineReader.h \
+ platform/SharedBufferChunkReader.h \
platform/sql/SQLiteDatabase.h \
platform/sql/SQLiteFileSystem.h \
platform/sql/SQLiteStatement.h \
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (89320 => 89321)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-06-21 00:36:27 UTC (rev 89321)
@@ -26666,11 +26666,11 @@
>
</File>
<File
- RelativePath="..\platform\SharedBufferCRLFLineReader.cpp"
+ RelativePath="..\platform\SharedBufferChunkReader.cpp"
>
</File>
<File
- RelativePath="..\platform\SharedBufferCRLFLineReader.h"
+ RelativePath="..\platform\SharedBufferChunkReader.h"
>
</File>
<File
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (89320 => 89321)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-21 00:36:27 UTC (rev 89321)
@@ -804,6 +804,8 @@
372C00C4129611F1005C9575 /* TextBoundaries.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372C00C3129611F1005C9575 /* TextBoundaries.cpp */; };
372C00D9129619F8005C9575 /* FindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 372C00D8129619F8005C9575 /* FindOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
3744570F0DB05FA500AE0992 /* SVGGlyphMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */; };
+ 37569E0313AF172C00CDBA8E /* SharedBufferChunkReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37569E0013AF172C00CDBA8E /* SharedBufferChunkReader.cpp */; };
+ 37569E0513AF172C00CDBA8E /* SharedBufferChunkReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */; };
375CD232119D43C800A2A859 /* Hyphenation.h in Headers */ = {isa = PBXBuildFile; fileRef = 375CD231119D43C800A2A859 /* Hyphenation.h */; };
375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 375CD239119D44EA00A2A859 /* HyphenationMac.mm */; };
3774ABA50FA21EB400AD7DE9 /* OverlapTestRequestClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -823,8 +825,6 @@
379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = 379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */; };
37ACCE420DA2980F0089E602 /* FontRenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 37ACCE410DA2980F0089E602 /* FontRenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACCE620DA2AA960089E602 /* FontDescription.cpp */; };
- 37AFFDF61370A0B800E895C0 /* SharedBufferCRLFLineReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFFDF41370A0B800E895C0 /* SharedBufferCRLFLineReader.cpp */; };
- 37AFFDF71370A0B800E895C0 /* SharedBufferCRLFLineReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 37AFFDF51370A0B800E895C0 /* SharedBufferCRLFLineReader.h */; };
37C2360B1097EDED00EF9F72 /* FontComplexTextMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */; };
37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; };
37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
@@ -7242,6 +7242,8 @@
372C00C3129611F1005C9575 /* TextBoundaries.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBoundaries.cpp; sourceTree = "<group>"; };
372C00D8129619F8005C9575 /* FindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindOptions.h; sourceTree = "<group>"; };
3744570E0DB05FA500AE0992 /* SVGGlyphMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGGlyphMap.h; sourceTree = "<group>"; };
+ 37569E0013AF172C00CDBA8E /* SharedBufferChunkReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBufferChunkReader.cpp; sourceTree = "<group>"; };
+ 37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferChunkReader.h; sourceTree = "<group>"; };
375CD231119D43C800A2A859 /* Hyphenation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Hyphenation.h; sourceTree = "<group>"; };
375CD239119D44EA00A2A859 /* HyphenationMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HyphenationMac.mm; sourceTree = "<group>"; };
3774ABA30FA21EB400AD7DE9 /* OverlapTestRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverlapTestRequestClient.h; sourceTree = "<group>"; };
@@ -7261,8 +7263,6 @@
379E61C8126CA5C300B63E8D /* BaseCheckableInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseCheckableInputType.h; sourceTree = "<group>"; };
37ACCE410DA2980F0089E602 /* FontRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontRenderingMode.h; sourceTree = "<group>"; };
37ACCE620DA2AA960089E602 /* FontDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescription.cpp; sourceTree = "<group>"; };
- 37AFFDF41370A0B800E895C0 /* SharedBufferCRLFLineReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBufferCRLFLineReader.cpp; sourceTree = "<group>"; };
- 37AFFDF51370A0B800E895C0 /* SharedBufferCRLFLineReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferCRLFLineReader.h; sourceTree = "<group>"; };
37C2360A1097EDED00EF9F72 /* FontComplexTextMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontComplexTextMac.cpp; sourceTree = "<group>"; };
37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
37C2360F1097EE7700EF9F72 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; };
@@ -18857,8 +18857,8 @@
33C0CCD3112C5E6200CE057D /* SecureTextInput.h */,
1A4A954B0B4EDCCB002D8C3C /* SharedBuffer.cpp */,
1A4A954C0B4EDCCB002D8C3C /* SharedBuffer.h */,
- 37AFFDF41370A0B800E895C0 /* SharedBufferCRLFLineReader.cpp */,
- 37AFFDF51370A0B800E895C0 /* SharedBufferCRLFLineReader.h */,
+ 37569E0013AF172C00CDBA8E /* SharedBufferChunkReader.cpp */,
+ 37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */,
93309EA0099EB78C0056E581 /* SharedTimer.h */,
4B3043C60AE0370300A82647 /* Sound.h */,
F587866202DE3B1101EA4122 /* SSLKeyGenerator.h */,
@@ -22441,7 +22441,6 @@
A80E6CE80A1989CA007FB8C5 /* ShadowValue.h in Headers */,
B2AFFC940D00A5DF0030074D /* ShapeArabic.h in Headers */,
1A4A954E0B4EDCCB002D8C3C /* SharedBuffer.h in Headers */,
- 37AFFDF71370A0B800E895C0 /* SharedBufferCRLFLineReader.h in Headers */,
498770EB1242C535002226BA /* SharedGraphicsContext3D.h in Headers */,
93309EA3099EB78C0056E581 /* SharedTimer.h in Headers */,
41E1B1D40FF5986900576B3B /* SharedWorker.h in Headers */,
@@ -25330,7 +25329,6 @@
B2AFFC930D00A5DF0030074D /* ShapeArabic.c in Sources */,
1A4A954D0B4EDCCB002D8C3C /* SharedBuffer.cpp in Sources */,
512DD8E30D91E2B4000F89EE /* SharedBufferCF.cpp in Sources */,
- 37AFFDF61370A0B800E895C0 /* SharedBufferCRLFLineReader.cpp in Sources */,
1A4A95520B4EDCFF002D8C3C /* SharedBufferMac.mm in Sources */,
498770EA1242C535002226BA /* SharedGraphicsContext3D.cpp in Sources */,
93309EA2099EB78C0056E581 /* SharedTimerMac.mm in Sources */,
Modified: trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.cpp (89320 => 89321)
--- trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.cpp 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.cpp 2011-06-21 00:36:27 UTC (rev 89321)
@@ -43,10 +43,10 @@
namespace WebCore {
-static bool skipLinesUntilBoundaryFound(SharedBufferCRLFLineReader& lineReader, const String& boundary)
+static bool skipLinesUntilBoundaryFound(SharedBufferChunkReader& lineReader, const String& boundary)
{
String line;
- while (!(line = lineReader.nextLine()).isNull()) {
+ while (!(line = lineReader.nextChunk()).isNull()) {
if (line == boundary)
return true;
}
@@ -54,7 +54,7 @@
}
MHTMLParser::MHTMLParser(SharedBuffer* data)
- : m_lineReader(data)
+ : m_lineReader(data, "\r\n")
{
}
@@ -147,7 +147,7 @@
const bool checkBoundary = !endOfPartBoundary.isEmpty();
bool endOfPartReached = false;
String line;
- while (!(line = m_lineReader.nextLine()).isNull()) {
+ while (!(line = m_lineReader.nextChunk()).isNull()) {
if (checkBoundary && (line == endOfPartBoundary || line == endOfDocumentBoundary)) {
endOfArchiveReached = (line == endOfDocumentBoundary);
endOfPartReached = true;
Modified: trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.h (89320 => 89321)
--- trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.h 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/loader/archive/mhtml/MHTMLParser.h 2011-06-21 00:36:27 UTC (rev 89321)
@@ -32,7 +32,7 @@
#define MHTMLParser_h
#if ENABLE(MHTML)
-#include "SharedBufferCRLFLineReader.h"
+#include "SharedBufferChunkReader.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
@@ -61,7 +61,7 @@
void addResourceToArchive(ArchiveResource*, MHTMLArchive*);
- SharedBufferCRLFLineReader m_lineReader;
+ SharedBufferChunkReader m_lineReader;
Vector<RefPtr<ArchiveResource> > m_resources;
Vector<RefPtr<MHTMLArchive> > m_frames;
};
Deleted: trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.cpp (89320 => 89321)
--- trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.cpp 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.cpp 2011-06-21 00:36:27 UTC (rev 89321)
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedBufferCRLFLineReader.h"
-
-#include "SharedBuffer.h"
-#include <wtf/text/StringBuilder.h>
-
-namespace WebCore {
-
-SharedBufferCRLFLineReader::SharedBufferCRLFLineReader(SharedBuffer* buffer)
- : m_buffer(buffer)
- , m_bufferPosition(0)
- , m_segment(0)
- , m_segmentLength(0)
- , m_segmentIndex(0)
- , m_reachedEndOfFile(false)
-{
-}
-
-String SharedBufferCRLFLineReader::nextLine()
-{
- if (m_reachedEndOfFile)
- return String();
-
- bool previousCharacterWasCR = false;
- StringBuilder stringBuilder;
- while (true) {
- bool reachedEndOfLine = false;
- while (m_segmentIndex < m_segmentLength) {
- reachedEndOfLine = false;
- char currentCharacter = m_segment[m_segmentIndex];
- if (previousCharacterWasCR) {
- if (currentCharacter == '\n')
- reachedEndOfLine = true;
- else
- stringBuilder.append('\r');
- } else if (currentCharacter != '\r')
- stringBuilder.append(currentCharacter);
-
- previousCharacterWasCR = (currentCharacter == '\r');
- m_segmentIndex++;
- if (reachedEndOfLine)
- return stringBuilder.toString();
- }
-
- // Read the next segment.
- m_segmentIndex = 0;
- m_bufferPosition += m_segmentLength;
- m_segmentLength = m_buffer->getSomeData(m_segment, m_bufferPosition);
- if (!m_segmentLength) {
- m_reachedEndOfFile = true;
- if (previousCharacterWasCR)
- stringBuilder.append('\r');
- String line = stringBuilder.toString();
- return (line.isEmpty() && !reachedEndOfLine) ? String() : line;
- }
- }
- return String();
-}
-
-}
Deleted: trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.h (89320 => 89321)
--- trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.h 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.h 2011-06-21 00:36:27 UTC (rev 89321)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SharedBufferCRLFLineReader_h
-#define SharedBufferCRLFLineReader_h
-
-#include <wtf/text/WTFString.h>
-
-namespace WTF {
-class StringBuilder;
-}
-
-namespace WebCore {
-
-class SharedBuffer;
-
-class SharedBufferCRLFLineReader {
-public:
- explicit SharedBufferCRLFLineReader(SharedBuffer*);
-
- // Returns the next line read from the buffer.
- // Returns a null string when the end of the buffer has been reached.
- String nextLine();
-
-private:
- SharedBuffer* m_buffer;
- size_t m_bufferPosition;
- const char* m_segment;
- size_t m_segmentLength;
- size_t m_segmentIndex;
- bool m_reachedEndOfFile;
-};
-
-}
-
-#endif
Copied: trunk/Source/WebCore/platform/SharedBufferChunkReader.cpp (from rev 89319, trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.cpp) (0 => 89321)
--- trunk/Source/WebCore/platform/SharedBufferChunkReader.cpp (rev 0)
+++ trunk/Source/WebCore/platform/SharedBufferChunkReader.cpp 2011-06-21 00:36:27 UTC (rev 89321)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SharedBufferChunkReader.h"
+
+#include "SharedBuffer.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+SharedBufferChunkReader::SharedBufferChunkReader(SharedBuffer* buffer, const String& separator)
+ : m_buffer(buffer)
+ , m_bufferPosition(0)
+ , m_segment(0)
+ , m_segmentLength(0)
+ , m_segmentIndex(0)
+ , m_reachedEndOfFile(false)
+ , m_separator(separator)
+ , m_separatorIndex(0)
+{
+}
+
+void SharedBufferChunkReader::setSeparator(const String& separator)
+{
+ m_separator = separator;
+}
+
+String SharedBufferChunkReader::nextChunk(bool includeSeparator)
+{
+ if (m_reachedEndOfFile)
+ return String();
+
+ StringBuilder stringBuilder;
+ while (true) {
+ while (m_segmentIndex < m_segmentLength) {
+ char currentCharacter = m_segment[m_segmentIndex++];
+ if (currentCharacter != m_separator[m_separatorIndex]) {
+ if (m_separatorIndex > 0) {
+ stringBuilder.append(m_separator.substring(0, m_separatorIndex));
+ m_separatorIndex = 0;
+ }
+ stringBuilder.append(currentCharacter);
+ continue;
+ }
+ m_separatorIndex++;
+ if (m_separatorIndex == m_separator.length()) {
+ if (includeSeparator)
+ stringBuilder.append(m_separator);
+ m_separatorIndex = 0;
+ return stringBuilder.toString();
+ }
+ }
+
+ // Read the next segment.
+ m_segmentIndex = 0;
+ m_bufferPosition += m_segmentLength;
+ m_segmentLength = m_buffer->getSomeData(m_segment, m_bufferPosition);
+ if (!m_segmentLength) {
+ m_reachedEndOfFile = true;
+ if (m_separatorIndex > 0)
+ stringBuilder.append(m_separator.substring(0, m_separatorIndex));
+ return stringBuilder.length() > 0 ? stringBuilder.toString() : String();
+ }
+ }
+ return String(); // Compiler is unhappy without this.
+}
+
+}
Copied: trunk/Source/WebCore/platform/SharedBufferChunkReader.h (from rev 89319, trunk/Source/WebCore/platform/SharedBufferCRLFLineReader.h) (0 => 89321)
--- trunk/Source/WebCore/platform/SharedBufferChunkReader.h (rev 0)
+++ trunk/Source/WebCore/platform/SharedBufferChunkReader.h 2011-06-21 00:36:27 UTC (rev 89321)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SharedBufferChunkReader_h
+#define SharedBufferChunkReader_h
+
+#include <wtf/text/WTFString.h>
+
+namespace WTF {
+class StringBuilder;
+}
+
+namespace WebCore {
+
+class SharedBuffer;
+
+class SharedBufferChunkReader {
+public:
+ SharedBufferChunkReader(SharedBuffer*, const String& separator);
+
+ void setSeparator(const String&);
+
+ // Returns a null string when the end of the buffer has been reached.
+ String nextChunk(bool includeSeparator = false);
+
+private:
+ SharedBuffer* m_buffer;
+ size_t m_bufferPosition;
+ const char* m_segment;
+ size_t m_segmentLength;
+ size_t m_segmentIndex;
+ bool m_reachedEndOfFile;
+ String m_separator;
+ size_t m_separatorIndex;
+};
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/network/MIMEHeader.cpp (89320 => 89321)
--- trunk/Source/WebCore/platform/network/MIMEHeader.cpp 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/platform/network/MIMEHeader.cpp 2011-06-21 00:36:27 UTC (rev 89321)
@@ -32,7 +32,7 @@
#include "MIMEHeader.h"
#include "ContentTypeParser.h"
-#include "SharedBufferCRLFLineReader.h"
+#include "SharedBufferChunkReader.h"
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
@@ -43,13 +43,13 @@
typedef HashMap<String, String> KeyValueMap;
-static KeyValueMap retrieveKeyValuePairs(WebCore::SharedBufferCRLFLineReader* buffer)
+static KeyValueMap retrieveKeyValuePairs(WebCore::SharedBufferChunkReader* buffer)
{
KeyValueMap keyValuePairs;
String line;
String key;
StringBuilder value;
- while (!(line = buffer->nextLine()).isNull()) {
+ while (!(line = buffer->nextChunk()).isNull()) {
if (line.isEmpty())
break; // Empty line means end of key/value section.
if (line[0] == '\t') {
@@ -79,7 +79,7 @@
return keyValuePairs;
}
-PassRefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferCRLFLineReader* buffer)
+PassRefPtr<MIMEHeader> MIMEHeader::parseHeader(SharedBufferChunkReader* buffer)
{
RefPtr<MIMEHeader> mimeHeader = adoptRef(new MIMEHeader);
KeyValueMap keyValuePairs = retrieveKeyValuePairs(buffer);
Modified: trunk/Source/WebCore/platform/network/MIMEHeader.h (89320 => 89321)
--- trunk/Source/WebCore/platform/network/MIMEHeader.h 2011-06-21 00:36:09 UTC (rev 89320)
+++ trunk/Source/WebCore/platform/network/MIMEHeader.h 2011-06-21 00:36:27 UTC (rev 89321)
@@ -37,7 +37,7 @@
namespace WebCore {
-class SharedBufferCRLFLineReader;
+class SharedBufferChunkReader;
// FIXME: This class is a limited MIME parser used to parse the MIME headers of MHTML files.
class MIMEHeader : public RefCounted<MIMEHeader> {
@@ -49,7 +49,7 @@
Unknown
};
- static PassRefPtr<MIMEHeader> parseHeader(SharedBufferCRLFLineReader*);
+ static PassRefPtr<MIMEHeader> parseHeader(SharedBufferChunkReader* crLFLineReader);
bool isMultipart() const { return m_contentType.startsWith("multipart/"); }