Title: [88486] trunk/Source/WebKit/chromium
- Revision
- 88486
- Author
- [email protected]
- Date
- 2011-06-09 14:45:18 -0700 (Thu, 09 Jun 2011)
Log Message
2011-06-09 Jay Civelli <[email protected]>
Reviewed by Darin Fisher.
Page serializer APIs now use WebData instead of fetching the entire
resource contents.
https://bugs.webkit.org/show_bug.cgi?id=61908
* public/WebData.h:
* public/WebPageSerializer.h:
* src/WebData.cpp:
(WebKit::WebData::getSomeData):
* src/WebPageSerializer.cpp:
(WebKit::WebPageSerializer::serialize):
(WebKit::WebPageSerializer::serializeToMHTML):
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (88485 => 88486)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-06-09 21:24:23 UTC (rev 88485)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-06-09 21:45:18 UTC (rev 88486)
@@ -1,3 +1,19 @@
+2011-06-09 Jay Civelli <[email protected]>
+
+ Reviewed by Darin Fisher.
+
+ Page serializer APIs now use WebData instead of fetching the entire
+ resource contents.
+ https://bugs.webkit.org/show_bug.cgi?id=61908
+
+ * public/WebData.h:
+ * public/WebPageSerializer.h:
+ * src/WebData.cpp:
+ (WebKit::WebData::getSomeData):
+ * src/WebPageSerializer.cpp:
+ (WebKit::WebPageSerializer::serialize):
+ (WebKit::WebPageSerializer::serializeToMHTML):
+
2011-06-09 Bill Budge <[email protected]>
Reviewed by Adam Barth.
Modified: trunk/Source/WebKit/chromium/public/WebData.h (88485 => 88486)
--- trunk/Source/WebKit/chromium/public/WebData.h 2011-06-09 21:24:23 UTC (rev 88485)
+++ trunk/Source/WebKit/chromium/public/WebData.h 2011-06-09 21:45:18 UTC (rev 88486)
@@ -76,6 +76,22 @@
WEBKIT_API void assign(const char* data, size_t size);
WEBKIT_API size_t size() const;
+
+ // Sets |data| to point to the content of the WebData at index |position|
+ // and returns the number of bytes available to be read in |data|.
+ // Return 0 when no more data is left.
+ // Usage:
+ // const char* segment;
+ // size_t position = 0;
+ // while (size_t length = webData.getSomeData(segment, position)) {
+ // // Use the data. for example: decoder->decode(segment, length);
+ // position += length;
+ // }
+ WEBKIT_API size_t getSomeData(const char*& data, size_t position) const;
+
+ // Returns all the data from the SharedBuffer.
+ // Consider using getSomeData() as data() could require flattening the internal buffer
+ // which might be expensive.
WEBKIT_API const char* data() const;
bool isEmpty() const { return !size(); }
Modified: trunk/Source/WebKit/chromium/public/WebPageSerializer.h (88485 => 88486)
--- trunk/Source/WebKit/chromium/public/WebPageSerializer.h 2011-06-09 21:24:23 UTC (rev 88485)
+++ trunk/Source/WebKit/chromium/public/WebPageSerializer.h 2011-06-09 21:45:18 UTC (rev 88486)
@@ -33,6 +33,7 @@
#include "WebCString.h"
#include "WebCommon.h"
+#include "WebData.h"
#include "WebURL.h"
namespace WebKit {
@@ -49,7 +50,7 @@
struct Resource {
WebURL url;
WebCString mimeType;
- WebCString data;
+ WebData data;
};
// Serializes all the frames from the WebView, retrieves the page's
@@ -59,7 +60,7 @@
WEBKIT_API static void serialize(WebView*, WebVector<Resource>*);
// Serializes the WebView contents to a MHTML representation.
- WEBKIT_API static WebCString serializeToMHTML(WebView*);
+ WEBKIT_API static WebData serializeToMHTML(WebView*);
// IMPORTANT:
// The API below is an older implementation of a pageserialization that
Modified: trunk/Source/WebKit/chromium/src/WebData.cpp (88485 => 88486)
--- trunk/Source/WebKit/chromium/src/WebData.cpp 2011-06-09 21:24:23 UTC (rev 88485)
+++ trunk/Source/WebKit/chromium/src/WebData.cpp 2011-06-09 21:45:18 UTC (rev 88486)
@@ -69,6 +69,11 @@
return const_cast<WebDataPrivate*>(m_private)->size();
}
+size_t WebData::getSomeData(const char*& data, size_t position) const
+{
+ return m_private->getSomeData(data, position);
+}
+
const char* WebData::data() const
{
if (!m_private)
Modified: trunk/Source/WebKit/chromium/src/WebPageSerializer.cpp (88485 => 88486)
--- trunk/Source/WebKit/chromium/src/WebPageSerializer.cpp 2011-06-09 21:24:23 UTC (rev 88485)
+++ trunk/Source/WebKit/chromium/src/WebPageSerializer.cpp 2011-06-09 21:45:18 UTC (rev 88486)
@@ -193,19 +193,15 @@
Resource resource;
resource.url = ""
resource.mimeType = iter->mimeType.ascii();
- // FIXME: we are copying all the resource data here. Idealy we would have a WebSharedData().
- resource.data = "" iter->data->size());
+ resource.data = ""
result.append(resource);
}
-
*resourcesParam = result;
}
-WebCString WebPageSerializer::serializeToMHTML(WebView* view)
+WebData WebPageSerializer::serializeToMHTML(WebView* view)
{
- RefPtr<SharedBuffer> mhtml = MHTMLArchive::generateMHTMLData(static_cast<WebViewImpl*>(view)->page());
- // FIXME: we are copying all the data here. Idealy we would have a WebSharedData().
- return WebCString(mhtml->data(), mhtml->size());
+ return MHTMLArchive::generateMHTMLData(static_cast<WebViewImpl*>(view)->page());
}
bool WebPageSerializer::serialize(WebFrame* frame,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes