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

Side by Side Diff: webkit/glue/glue_serialize.cc

Issue 3108042: Support sending BlobData to browser process. Also support sending UploadData... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/webkit_blob.gypi ('k') | webkit/support/webkit_support.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/glue_serialize.h" 5 #include "webkit/glue/glue_serialize.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" 19 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
19 #include "webkit/glue/webkit_glue.h" 20 #include "webkit/glue/webkit_glue.h"
20 21
21 using WebKit::WebData; 22 using WebKit::WebData;
22 using WebKit::WebFileInfo; 23 using WebKit::WebFileInfo;
23 using WebKit::WebHistoryItem; 24 using WebKit::WebHistoryItem;
24 using WebKit::WebHTTPBody; 25 using WebKit::WebHTTPBody;
25 using WebKit::WebPoint; 26 using WebKit::WebPoint;
26 using WebKit::WebSerializedScriptValue; 27 using WebKit::WebSerializedScriptValue;
27 using WebKit::WebString; 28 using WebKit::WebString;
(...skipping 21 matching lines...) Expand all
49 // 2: Added case for NULL string versus "". Version 2 code can read Version 1 50 // 2: Added case for NULL string versus "". Version 2 code can read Version 1
50 // data, but not vice versa. 51 // data, but not vice versa.
51 // 3: Version 2 was broken, it stored number of WebUChars, not number of bytes. 52 // 3: Version 2 was broken, it stored number of WebUChars, not number of bytes.
52 // This version checks and reads v1 and v2 correctly. 53 // This version checks and reads v1 and v2 correctly.
53 // 4: Adds support for storing FormData::identifier(). 54 // 4: Adds support for storing FormData::identifier().
54 // 5: Adds support for empty FormData 55 // 5: Adds support for empty FormData
55 // 6: Adds support for documentSequenceNumbers 56 // 6: Adds support for documentSequenceNumbers
56 // 7: Adds support for stateObject 57 // 7: Adds support for stateObject
57 // 8: Adds support for file range and modification time 58 // 8: Adds support for file range and modification time
58 // 9: Adds support for itemSequenceNumbers 59 // 9: Adds support for itemSequenceNumbers
60 // 10: Adds support for blob
59 // Should be const, but unit tests may modify it. 61 // Should be const, but unit tests may modify it.
60 // 62 //
61 // NOTE: If the version is -1, then the pickle contains only a URL string. 63 // NOTE: If the version is -1, then the pickle contains only a URL string.
62 // See CreateHistoryStateForURL. 64 // See CreateHistoryStateForURL.
63 // 65 //
64 int kVersion = 9; 66 int kVersion = 10;
65 67
66 // A bunch of convenience functions to read/write to SerializeObjects. 68 // A bunch of convenience functions to read/write to SerializeObjects.
67 // The serializers assume the input data is in the correct format and so does 69 // The serializers assume the input data is in the correct format and so does
68 // no error checking. 70 // no error checking.
69 inline void WriteData(const void* data, int length, SerializeObject* obj) { 71 inline void WriteData(const void* data, int length, SerializeObject* obj) {
70 obj->pickle.WriteData(static_cast<const char*>(data), length); 72 obj->pickle.WriteData(static_cast<const char*>(data), length);
71 } 73 }
72 74
73 inline void ReadData(const SerializeObject* obj, const void** data, 75 inline void ReadData(const SerializeObject* obj, const void** data,
74 int* length) { 76 int* length) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (http_body.isNull()) 229 if (http_body.isNull())
228 return; 230 return;
229 231
230 WriteInteger(static_cast<int>(http_body.elementCount()), obj); 232 WriteInteger(static_cast<int>(http_body.elementCount()), obj);
231 WebHTTPBody::Element element; 233 WebHTTPBody::Element element;
232 for (size_t i = 0; http_body.elementAt(i, element); ++i) { 234 for (size_t i = 0; http_body.elementAt(i, element); ++i) {
233 WriteInteger(element.type, obj); 235 WriteInteger(element.type, obj);
234 if (element.type == WebHTTPBody::Element::TypeData) { 236 if (element.type == WebHTTPBody::Element::TypeData) {
235 WriteData(element.data.data(), static_cast<int>(element.data.size()), 237 WriteData(element.data.data(), static_cast<int>(element.data.size()),
236 obj); 238 obj);
237 } else { 239 } else if (element.type == WebHTTPBody::Element::TypeFile) {
238 WriteString(element.filePath, obj); 240 WriteString(element.filePath, obj);
239 WriteInteger64(element.fileStart, obj); 241 WriteInteger64(element.fileStart, obj);
240 WriteInteger64(element.fileLength, obj); 242 WriteInteger64(element.fileLength, obj);
241 WriteReal(element.fileInfo.modificationTime, obj); 243 WriteReal(element.fileInfo.modificationTime, obj);
244 } else {
245 WriteGURL(element.blobURL, obj);
242 } 246 }
243 } 247 }
244 WriteInteger64(http_body.identifier(), obj); 248 WriteInteger64(http_body.identifier(), obj);
245 } 249 }
246 250
247 static WebHTTPBody ReadFormData(const SerializeObject* obj) { 251 static WebHTTPBody ReadFormData(const SerializeObject* obj) {
248 // In newer versions, an initial boolean indicates if we have form data. 252 // In newer versions, an initial boolean indicates if we have form data.
249 if (obj->version >= 5 && !ReadBoolean(obj)) 253 if (obj->version >= 5 && !ReadBoolean(obj))
250 return WebHTTPBody(); 254 return WebHTTPBody();
251 255
252 // In older versions, 0 elements implied no form data. 256 // In older versions, 0 elements implied no form data.
253 int num_elements = ReadInteger(obj); 257 int num_elements = ReadInteger(obj);
254 if (num_elements == 0 && obj->version < 5) 258 if (num_elements == 0 && obj->version < 5)
255 return WebHTTPBody(); 259 return WebHTTPBody();
256 260
257 WebHTTPBody http_body; 261 WebHTTPBody http_body;
258 http_body.initialize(); 262 http_body.initialize();
259 263
260 for (int i = 0; i < num_elements; ++i) { 264 for (int i = 0; i < num_elements; ++i) {
261 int type = ReadInteger(obj); 265 int type = ReadInteger(obj);
262 if (type == WebHTTPBody::Element::TypeData) { 266 if (type == WebHTTPBody::Element::TypeData) {
263 const void* data; 267 const void* data;
264 int length = -1; 268 int length = -1;
265 ReadData(obj, &data, &length); 269 ReadData(obj, &data, &length);
266 if (length >= 0) 270 if (length >= 0)
267 http_body.appendData(WebData(static_cast<const char*>(data), length)); 271 http_body.appendData(WebData(static_cast<const char*>(data), length));
268 } else { 272 } else if (type == WebHTTPBody::Element::TypeFile) {
269 WebString file_path = ReadString(obj); 273 WebString file_path = ReadString(obj);
270 long long file_start = 0; 274 long long file_start = 0;
271 long long file_length = -1; 275 long long file_length = -1;
272 WebFileInfo file_info; 276 WebFileInfo file_info;
273 if (obj->version >= 8) { 277 if (obj->version >= 8) {
274 file_start = ReadInteger64(obj); 278 file_start = ReadInteger64(obj);
275 file_length = ReadInteger64(obj); 279 file_length = ReadInteger64(obj);
276 file_info.modificationTime = ReadReal(obj); 280 file_info.modificationTime = ReadReal(obj);
277 } 281 }
278 http_body.appendFileRange(file_path, file_start, file_length, file_info); 282 http_body.appendFileRange(file_path, file_start, file_length, file_info);
283 } else if (obj->version >= 10) {
284 GURL blob_url = ReadGURL(obj);
285 http_body.appendBlob(blob_url);
279 } 286 }
280 } 287 }
281 if (obj->version >= 4) 288 if (obj->version >= 4)
282 http_body.setIdentifier(ReadInteger64(obj)); 289 http_body.setIdentifier(ReadInteger64(obj));
283 290
284 return http_body; 291 return http_body;
285 } 292 }
286 293
287 // Writes the HistoryItem data into the SerializeObject object for 294 // Writes the HistoryItem data into the SerializeObject object for
288 // serialization. 295 // serialization.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 const WebHistoryItem& item = HistoryItemFromString(content_state, false); 473 const WebHistoryItem& item = HistoryItemFromString(content_state, false);
467 if (item.isNull()) { 474 if (item.isNull()) {
468 // Couldn't parse the string, return an empty string. 475 // Couldn't parse the string, return an empty string.
469 return std::string(); 476 return std::string();
470 } 477 }
471 478
472 return HistoryItemToString(item); 479 return HistoryItemToString(item);
473 } 480 }
474 481
475 } // namespace webkit_glue 482 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/blob/webkit_blob.gypi ('k') | webkit/support/webkit_support.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698