Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1550)

Unified Diff: webkit/glue/glue_serialize.cc

Issue 225012: Store non-standard HTTP headers in history Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/api/src/WebHistoryItem.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/glue_serialize.cc
===================================================================
--- webkit/glue/glue_serialize.cc (revision 26790)
+++ webkit/glue/glue_serialize.cc (working copy)
@@ -12,6 +12,7 @@
#include "webkit/api/public/WebData.h"
#include "webkit/api/public/WebHistoryItem.h"
#include "webkit/api/public/WebHTTPBody.h"
+#include "webkit/api/public/WebHTTPHeaderVisitor.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebVector.h"
@@ -21,6 +22,7 @@
using WebKit::WebData;
using WebKit::WebHistoryItem;
using WebKit::WebHTTPBody;
+using WebKit::WebHTTPHeaderVisitor;
using WebKit::WebPoint;
using WebKit::WebString;
using WebKit::WebUChar;
@@ -50,8 +52,9 @@
// This version checks and reads v1 and v2 correctly.
// 4: Adds support for storing FormData::identifier().
// 5: Adds support for empty FormData
+// 6: Adds support for extra HTTP headers.
// Should be const, but unit tests may modify it.
-int kVersion = 5;
+int kVersion = 6;
// A bunch of convenience functions to read/write to SerializeObjects.
// The serializers assume the input data is in the correct format and so does
@@ -285,6 +288,27 @@
WriteInteger(static_cast<int>(children.size()), obj);
for (size_t i = 0, c = children.size(); i < c; ++i)
WriteHistoryItem(children[i], obj);
+
+ // Extra HTTP headers.
+ std::map<string16, string16> header_map;
+ class HeaderMapVisitor : public WebHTTPHeaderVisitor {
+ public:
+ HeaderMapVisitor(std::map<string16, string16>* header_map) {
+ map_ = header_map;
+ }
+ virtual void visitHeader(const WebString& name, const WebString& value) {
+ map_->insert(std::make_pair(name, value));
+ }
+ private:
+ std::map<string16, string16>* map_;
+ } header_map_visitor(&header_map);
+ item.visitHTTPHeaderFields(&header_map_visitor);
+ WriteInteger(static_cast<int>(header_map.size()), obj);
+ std::map<string16, string16>::const_iterator it = header_map.begin();
+ for (; it != header_map.end(); ++it) {
+ WriteString(it->first, obj);
+ WriteString(it->second, obj);
+ }
}
// Creates a new HistoryItem tree based on the serialized string.
@@ -330,6 +354,19 @@
for (int i = 0; i < num_children; ++i)
item.appendToChildren(ReadHistoryItem(obj, include_form_data));
+ if (obj->version >= 6) {
+ // Extra HTTP headers.
+ int num_extra_headers = ReadInteger(obj);
+ if (num_extra_headers > 0) {
+ WebString name, value;
+ for (int i = 0; i < num_extra_headers; ++i) {
+ name = ReadString(obj);
+ value = ReadString(obj);
+ item.setHTTPHeaderField(name, value);
+ }
+ }
+ }
+
return item;
}
« no previous file with comments | « webkit/api/src/WebHistoryItem.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698