diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 19:55:08 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 19:55:08 +0000 |
commit | ccf1ac4398aeb300bc3c005640aaf57500488e2d (patch) | |
tree | 35eadc64a003ec79f2fc77924f5b92928cede2d0 /webkit/glue/glue_serialize.cc | |
parent | 059292e77d7fcfbf930ccb8cafdaaadd7a505a2e (diff) | |
download | chromium_src-ccf1ac4398aeb300bc3c005640aaf57500488e2d.zip chromium_src-ccf1ac4398aeb300bc3c005640aaf57500488e2d.tar.gz chromium_src-ccf1ac4398aeb300bc3c005640aaf57500488e2d.tar.bz2 |
Chrome changes to support cached form submissions.
The solution is to add a user-defined identifier to UploadData.
If that identifier is set, and if the request method is POST,
then HttpCache will enable caching for the response. (The cache
key will be a composition of the identifier and the URL.) A
subsequent POST request to the same URL with the same identifier
will "hit" the previously generated cache entry. Reuse from the
cache is subject to all of the standard rules.
For reference, here are the corresponding net changes:
http://codereview.chromium.org/52028
Here are the corresponding WebKit changes:
http://trac.webkit.org/changeset/41919
BUG=2636
R=sky
Review URL: http://codereview.chromium.org/52040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/glue_serialize.cc')
-rw-r--r-- | webkit/glue/glue_serialize.cc | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index ecf6879..15f82c5 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -45,8 +45,9 @@ struct SerializeObject { // data, but not vice versa. // 3: Version 2 was broken, it stored number of UChars, not number of bytes. // This version checks and reads v1 and v2 correctly. +// 4: Adds support for storing FormData::identifier(). // Should be const, but unit tests may modify it. -int kVersion = 3; +int kVersion = 4; // A bunch of convenience functions to read/write to SerializeObjects. // The serializers assume the input data is in the correct format and so does @@ -76,11 +77,21 @@ inline void WriteInteger(int data, SerializeObject* obj) { } inline int ReadInteger(const SerializeObject* obj) { - int tmp; + int tmp = 0; obj->pickle.ReadInt(&obj->iter, &tmp); return tmp; } +inline void WriteInteger64(int64 data, SerializeObject* obj) { + obj->pickle.WriteInt64(data); +} + +inline int64 ReadInteger64(const SerializeObject* obj) { + int64 tmp = 0; + obj->pickle.ReadInt64(&obj->iter, &tmp); + return tmp; +} + inline void WriteReal(double data, SerializeObject* obj) { WriteData(&data, sizeof(double), obj); } @@ -124,8 +135,8 @@ inline void WriteString(const String& data, SerializeObject* obj) { data.length() * sizeof(UChar)); } break; - case 3: - // Version 3 writes <length in bytes><string data>. + default: + // Version 3+ writes <length in bytes><string data>. // It uses -1 in the length field to mean String(). if (data.isNull()) { obj->pickle.WriteInt(-1); @@ -135,9 +146,6 @@ inline void WriteString(const String& data, SerializeObject* obj) { data.length() * sizeof(UChar)); } break; - default: - NOTREACHED(); - break; } } @@ -199,6 +207,7 @@ static void WriteFormData(const FormData* form_data, SerializeObject* obj) { WriteString(e.m_filename, obj); } } + WriteInteger64(form_data->identifier(), obj); } static PassRefPtr<FormData> ReadFormData(const SerializeObject* obj) { @@ -219,6 +228,8 @@ static PassRefPtr<FormData> ReadFormData(const SerializeObject* obj) { form_data->appendFile(ReadString(obj)); } } + if (obj->version >= 4) + form_data->setIdentifier(ReadInteger64(obj)); return form_data.release(); } @@ -264,7 +275,7 @@ static PassRefPtr<HistoryItem> ReadHistoryItem(const SerializeObject* obj) { // See note in WriteHistoryItem. on this. obj->version = ReadInteger(obj); - if (obj->version > kVersion) + if (obj->version > kVersion || obj->version < 1) return NULL; RefPtr<HistoryItem> item = HistoryItem::create(); |