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

Side by Side Diff: WebCore/bindings/v8/SerializedScriptValue.cpp

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « WebCore/bindings/v8/SerializedScriptValue.h ('k') | WebCore/fileapi/Blob.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 doWriteWebCoreString(type); 424 doWriteWebCoreString(type);
425 } 425 }
426 426
427 void writeFileList(const FileList& fileList) 427 void writeFileList(const FileList& fileList)
428 { 428 {
429 append(FileListTag); 429 append(FileListTag);
430 uint32_t length = fileList.length(); 430 uint32_t length = fileList.length();
431 doWriteUint32(length); 431 doWriteUint32(length);
432 for (unsigned i = 0; i < length; ++i) { 432 for (unsigned i = 0; i < length; ++i) {
433 doWriteWebCoreString(fileList.item(i)->path()); 433 doWriteWebCoreString(fileList.item(i)->path());
434 doWriteWebCoreString(fileList.item(i)->url().string()); 434 doWriteWebCoreString(fileList.item(i)->uuid()); // TODO: bump versio n numbers somewhere?
435 doWriteWebCoreString(fileList.item(i)->type()); 435 doWriteWebCoreString(fileList.item(i)->type());
436 } 436 }
437 } 437 }
438 438
439 void writeArrayBuffer(const ArrayBuffer& arrayBuffer) 439 void writeArrayBuffer(const ArrayBuffer& arrayBuffer)
440 { 440 {
441 append(ArrayBufferTag); 441 append(ArrayBufferTag);
442 doWriteArrayBuffer(arrayBuffer); 442 doWriteArrayBuffer(arrayBuffer);
443 } 443 }
444 444
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 public: 697 public:
698 enum Status { 698 enum Status {
699 Success, 699 Success,
700 InputError, 700 InputError,
701 DataCloneError, 701 DataCloneError,
702 InvalidStateError, 702 InvalidStateError,
703 JSException, 703 JSException,
704 JSFailure 704 JSFailure
705 }; 705 };
706 706
707 Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, v8::TryCatch& tryCatch) 707 Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch)
708 : m_writer(writer) 708 : m_writer(writer)
709 , m_tryCatch(tryCatch) 709 , m_tryCatch(tryCatch)
710 , m_depth(0) 710 , m_depth(0)
711 , m_execDepth(0) 711 , m_execDepth(0)
712 , m_status(Success) 712 , m_status(Success)
713 , m_nextObjectReference(0) 713 , m_nextObjectReference(0)
714 , m_blobURLs(blobURLs) 714 , m_blobDataHandles(blobDataHandles)
715 { 715 {
716 ASSERT(!tryCatch.HasCaught()); 716 ASSERT(!tryCatch.HasCaught());
717 if (messagePorts) { 717 if (messagePorts) {
718 for (size_t i = 0; i < messagePorts->size(); i++) 718 for (size_t i = 0; i < messagePorts->size(); i++)
719 m_transferredMessagePorts.set(toV8Object(messagePorts->at(i).get (), m_writer.getIsolate()), i); 719 m_transferredMessagePorts.set(toV8Object(messagePorts->at(i).get (), m_writer.getIsolate()), i);
720 } 720 }
721 if (arrayBuffers) { 721 if (arrayBuffers) {
722 for (size_t i = 0; i < arrayBuffers->size(); i++) { 722 for (size_t i = 0; i < arrayBuffers->size(); i++) {
723 v8::Handle<v8::Object> v8ArrayBuffer = toV8Object(arrayBuffers-> at(i).get(), m_writer.getIsolate()); 723 v8::Handle<v8::Object> v8ArrayBuffer = toV8Object(arrayBuffers-> at(i).get(), m_writer.getIsolate());
724 // Coalesce multiple occurences of the same buffer to the first index. 724 // Coalesce multiple occurences of the same buffer to the first index.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 { 1071 {
1072 v8::Handle<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject >(); 1072 v8::Handle<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject >();
1073 m_writer.writeBooleanObject(booleanObject->BooleanValue()); 1073 m_writer.writeBooleanObject(booleanObject->BooleanValue());
1074 } 1074 }
1075 1075
1076 void writeBlob(v8::Handle<v8::Value> value) 1076 void writeBlob(v8::Handle<v8::Value> value)
1077 { 1077 {
1078 Blob* blob = V8Blob::toNative(value.As<v8::Object>()); 1078 Blob* blob = V8Blob::toNative(value.As<v8::Object>());
1079 if (!blob) 1079 if (!blob)
1080 return; 1080 return;
1081 m_writer.writeBlob(blob->url().string(), blob->type(), blob->size()); 1081 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size());
1082 m_blobURLs.append(blob->url().string()); 1082 m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle());
1083 } 1083 }
1084 1084
1085 #if ENABLE(FILE_SYSTEM) 1085 #if ENABLE(FILE_SYSTEM)
1086 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next) 1086 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next)
1087 { 1087 {
1088 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>()); 1088 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>());
1089 if (!fs) 1089 if (!fs)
1090 return 0; 1090 return 0;
1091 if (!fs->clonable()) 1091 if (!fs->clonable())
1092 return handleError(DataCloneError, next); 1092 return handleError(DataCloneError, next);
1093 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string ()); 1093 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string ());
1094 return 0; 1094 return 0;
1095 } 1095 }
1096 #endif 1096 #endif
1097 1097
1098 void writeFile(v8::Handle<v8::Value> value) 1098 void writeFile(v8::Handle<v8::Value> value)
1099 { 1099 {
1100 File* file = V8File::toNative(value.As<v8::Object>()); 1100 File* file = V8File::toNative(value.As<v8::Object>());
1101 if (!file) 1101 if (!file)
1102 return; 1102 return;
1103 m_writer.writeFile(file->path(), file->url().string(), file->type()); 1103 m_writer.writeFile(file->path(), file->uuid(), file->type());
1104 m_blobURLs.append(file->url().string()); 1104 m_blobDataHandles.add(file->uuid(), file->blobDataHandle());
1105 } 1105 }
1106 1106
1107 void writeFileList(v8::Handle<v8::Value> value) 1107 void writeFileList(v8::Handle<v8::Value> value)
1108 { 1108 {
1109 FileList* fileList = V8FileList::toNative(value.As<v8::Object>()); 1109 FileList* fileList = V8FileList::toNative(value.As<v8::Object>());
1110 if (!fileList) 1110 if (!fileList)
1111 return; 1111 return;
1112 m_writer.writeFileList(*fileList); 1112 m_writer.writeFileList(*fileList);
1113 unsigned length = fileList->length(); 1113 unsigned length = fileList->length();
1114 for (unsigned i = 0; i < length; ++i) 1114 for (unsigned i = 0; i < length; ++i)
1115 m_blobURLs.append(fileList->item(i)->url().string()); 1115 m_blobDataHandles.add(fileList->item(i)->uuid(), fileList->item(i)-> blobDataHandle());
1116 } 1116 }
1117 1117
1118 void writeImageData(v8::Handle<v8::Value> value) 1118 void writeImageData(v8::Handle<v8::Value> value)
1119 { 1119 {
1120 ImageData* imageData = V8ImageData::toNative(value.As<v8::Object>()); 1120 ImageData* imageData = V8ImageData::toNative(value.As<v8::Object>());
1121 if (!imageData) 1121 if (!imageData)
1122 return; 1122 return;
1123 Uint8ClampedArray* pixelArray = imageData->data(); 1123 Uint8ClampedArray* pixelArray = imageData->data();
1124 m_writer.writeImageData(imageData->width(), imageData->height(), pixelAr ray->data(), pixelArray->length()); 1124 m_writer.writeImageData(imageData->width(), imageData->height(), pixelAr ray->data(), pixelArray->length());
1125 } 1125 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 Writer& m_writer; 1224 Writer& m_writer;
1225 v8::TryCatch& m_tryCatch; 1225 v8::TryCatch& m_tryCatch;
1226 int m_depth; 1226 int m_depth;
1227 int m_execDepth; 1227 int m_execDepth;
1228 Status m_status; 1228 Status m_status;
1229 typedef V8ObjectMap<v8::Object, uint32_t> ObjectPool; 1229 typedef V8ObjectMap<v8::Object, uint32_t> ObjectPool;
1230 ObjectPool m_objectPool; 1230 ObjectPool m_objectPool;
1231 ObjectPool m_transferredMessagePorts; 1231 ObjectPool m_transferredMessagePorts;
1232 ObjectPool m_transferredArrayBuffers; 1232 ObjectPool m_transferredArrayBuffers;
1233 uint32_t m_nextObjectReference; 1233 uint32_t m_nextObjectReference;
1234 Vector<String>& m_blobURLs; 1234 BlobDataHandleMap& m_blobDataHandles;
1235 }; 1235 };
1236 1236
1237 Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, Stat eBase* next) 1237 Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, Stat eBase* next)
1238 { 1238 {
1239 if (m_execDepth + (next ? next->execDepth() : 0) > 1) { 1239 if (m_execDepth + (next ? next->execDepth() : 0) > 1) {
1240 m_writer.writeNull(); 1240 m_writer.writeNull();
1241 return 0; 1241 return 0;
1242 } 1242 }
1243 m_writer.writeReferenceCount(m_nextObjectReference); 1243 m_writer.writeReferenceCount(m_nextObjectReference);
1244 uint32_t objectReference; 1244 uint32_t objectReference;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 virtual bool newObject() = 0; 1334 virtual bool newObject() = 0;
1335 virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>*) = 0; 1335 virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>*) = 0;
1336 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8 ::Handle<v8::Value>*) = 0; 1336 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8 ::Handle<v8::Value>*) = 0;
1337 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8: :Handle<v8::Value>*) = 0; 1337 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8: :Handle<v8::Value>*) = 0;
1338 }; 1338 };
1339 1339
1340 // Reader is responsible for deserializing primitive types and 1340 // Reader is responsible for deserializing primitive types and
1341 // restoring information about saved objects of composite types. 1341 // restoring information about saved objects of composite types.
1342 class Reader { 1342 class Reader {
1343 public: 1343 public:
1344 Reader(const uint8_t* buffer, int length, v8::Isolate* isolate) 1344 Reader(const uint8_t* buffer, int length, v8::Isolate* isolate, const BlobDa taHandleMap& blobDataHandles)
1345 : m_buffer(buffer) 1345 : m_buffer(buffer)
1346 , m_length(length) 1346 , m_length(length)
1347 , m_position(0) 1347 , m_position(0)
1348 , m_version(0) 1348 , m_version(0)
1349 , m_isolate(isolate) 1349 , m_isolate(isolate)
1350 , m_blobDataHandles(blobDataHandles)
1350 { 1351 {
1351 ASSERT(!(reinterpret_cast<size_t>(buffer) & 1)); 1352 ASSERT(!(reinterpret_cast<size_t>(buffer) & 1));
1352 ASSERT(length >= 0); 1353 ASSERT(length >= 0);
1353 } 1354 }
1354 1355
1355 bool isEof() const { return m_position >= m_length; } 1356 bool isEof() const { return m_position >= m_length; }
1356 1357
1357 bool read(v8::Handle<v8::Value>* value, CompositeCreator& creator) 1358 bool read(v8::Handle<v8::Value>* value, CompositeCreator& creator)
1358 { 1359 {
1359 SerializationTag tag; 1360 SerializationTag tag;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 return false; 1853 return false;
1853 uint32_t flags; 1854 uint32_t flags;
1854 if (!doReadUint32(&flags)) 1855 if (!doReadUint32(&flags))
1855 return false; 1856 return false;
1856 *value = v8::RegExp::New(pattern.As<v8::String>(), static_cast<v8::RegEx p::Flags>(flags)); 1857 *value = v8::RegExp::New(pattern.As<v8::String>(), static_cast<v8::RegEx p::Flags>(flags));
1857 return true; 1858 return true;
1858 } 1859 }
1859 1860
1860 bool readBlob(v8::Handle<v8::Value>* value) 1861 bool readBlob(v8::Handle<v8::Value>* value)
1861 { 1862 {
1862 String url; 1863 String uuid;
1863 String type; 1864 String type;
1864 uint64_t size; 1865 uint64_t size;
1865 if (!readWebCoreString(&url)) 1866 if (!readWebCoreString(&uuid))
1866 return false; 1867 return false;
1867 if (!readWebCoreString(&type)) 1868 if (!readWebCoreString(&type))
1868 return false; 1869 return false;
1869 if (!doReadUint64(&size)) 1870 if (!doReadUint64(&size))
1870 return false; 1871 return false;
1871 PassRefPtr<Blob> blob = Blob::create(KURL(ParsedURLString, url), type, s ize); 1872 PassRefPtr<Blob> blob = Blob::create(getOrCreateBlobDataHandle(uuid, typ e, size));
1872 *value = toV8(blob, v8::Handle<v8::Object>(), m_isolate); 1873 *value = toV8(blob, v8::Handle<v8::Object>(), m_isolate);
1873 return true; 1874 return true;
1874 } 1875 }
1875 1876
1876 #if ENABLE(FILE_SYSTEM) 1877 #if ENABLE(FILE_SYSTEM)
1877 bool readDOMFileSystem(v8::Handle<v8::Value>* value) 1878 bool readDOMFileSystem(v8::Handle<v8::Value>* value)
1878 { 1879 {
1879 uint32_t type; 1880 uint32_t type;
1880 String name; 1881 String name;
1881 String url; 1882 String url;
1882 if (!doReadUint32(&type)) 1883 if (!doReadUint32(&type))
1883 return false; 1884 return false;
1884 if (!readWebCoreString(&name)) 1885 if (!readWebCoreString(&name))
1885 return false; 1886 return false;
1886 if (!readWebCoreString(&url)) 1887 if (!readWebCoreString(&url))
1887 return false; 1888 return false;
1888 RefPtr<DOMFileSystem> fs = DOMFileSystem::create(getScriptExecutionConte xt(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, ur l), AsyncFileSystem::create()); 1889 RefPtr<DOMFileSystem> fs = DOMFileSystem::create(getScriptExecutionConte xt(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, ur l), AsyncFileSystem::create());
1889 *value = toV8(fs.release(), v8::Handle<v8::Object>(), m_isolate); 1890 *value = toV8(fs.release(), v8::Handle<v8::Object>(), m_isolate);
1890 return true; 1891 return true;
1891 } 1892 }
1892 #endif 1893 #endif
1893 1894
1894 bool readFile(v8::Handle<v8::Value>* value) 1895 bool readFile(v8::Handle<v8::Value>* value)
1895 { 1896 {
1896 String path; 1897 String path;
1897 String url; 1898 String uuid;
1898 String type; 1899 String type;
1899 if (!readWebCoreString(&path)) 1900 if (!readWebCoreString(&path))
1900 return false; 1901 return false;
1901 if (!readWebCoreString(&url)) 1902 if (!readWebCoreString(&uuid))
1902 return false; 1903 return false;
1903 if (!readWebCoreString(&type)) 1904 if (!readWebCoreString(&type))
1904 return false; 1905 return false;
1905 PassRefPtr<File> file = File::create(path, KURL(ParsedURLString, url), t ype); 1906 PassRefPtr<File> file = File::create(path, getOrCreateBlobDataHandle(uui d, type));
1906 *value = toV8(file, v8::Handle<v8::Object>(), m_isolate); 1907 *value = toV8(file, v8::Handle<v8::Object>(), m_isolate);
1907 return true; 1908 return true;
1908 } 1909 }
1909 1910
1910 bool readFileList(v8::Handle<v8::Value>* value) 1911 bool readFileList(v8::Handle<v8::Value>* value)
1911 { 1912 {
1912 uint32_t length; 1913 uint32_t length;
1913 if (!doReadUint32(&length)) 1914 if (!doReadUint32(&length))
1914 return false; 1915 return false;
1915 PassRefPtr<FileList> fileList = FileList::create(); 1916 PassRefPtr<FileList> fileList = FileList::create();
1916 for (unsigned i = 0; i < length; ++i) { 1917 for (unsigned i = 0; i < length; ++i) {
1917 String path; 1918 String path;
1918 String urlString; 1919 String uuid;
1919 String type; 1920 String type;
1920 if (!readWebCoreString(&path)) 1921 if (!readWebCoreString(&path))
1921 return false; 1922 return false;
1922 if (!readWebCoreString(&urlString)) 1923 if (!readWebCoreString(&uuid))
1923 return false; 1924 return false;
1924 if (!readWebCoreString(&type)) 1925 if (!readWebCoreString(&type))
1925 return false; 1926 return false;
1926 fileList->append(File::create(path, KURL(ParsedURLString, urlString) , type)); 1927 fileList->append(File::create(path, getOrCreateBlobDataHandle(uuid, type)));
1927 } 1928 }
1928 *value = toV8(fileList, v8::Handle<v8::Object>(), m_isolate); 1929 *value = toV8(fileList, v8::Handle<v8::Object>(), m_isolate);
1929 return true; 1930 return true;
1930 } 1931 }
1931 1932
1932 template<class T> 1933 template<class T>
1933 bool doReadUintHelper(T* value) 1934 bool doReadUintHelper(T* value)
1934 { 1935 {
1935 *value = 0; 1936 *value = 0;
1936 uint8_t currentByte; 1937 uint8_t currentByte;
(...skipping 21 matching lines...) Expand all
1958 bool doReadNumber(double* number) 1959 bool doReadNumber(double* number)
1959 { 1960 {
1960 if (m_position + sizeof(double) > m_length) 1961 if (m_position + sizeof(double) > m_length)
1961 return false; 1962 return false;
1962 uint8_t* numberAsByteArray = reinterpret_cast<uint8_t*>(number); 1963 uint8_t* numberAsByteArray = reinterpret_cast<uint8_t*>(number);
1963 for (unsigned i = 0; i < sizeof(double); ++i) 1964 for (unsigned i = 0; i < sizeof(double); ++i)
1964 numberAsByteArray[i] = m_buffer[m_position++]; 1965 numberAsByteArray[i] = m_buffer[m_position++];
1965 return true; 1966 return true;
1966 } 1967 }
1967 1968
1969 PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, con st String& type, long long size = -1)
1970 {
1971 // The containing ssv may have a BDH for this uuid if this ssv is just b eing
1972 // passed from main to worker thread (for example). We use those values when creating the
1973 // new blob instead of cons'ing up a new BDH.
1974 //
1975 // FIXME: Maybe we should require that it work that way where the ssv mu st have a BDH for any
1976 // blobs it comes across during deserialization. Would require callers t o explicitly populate
1977 // the collection of BDH's for blobs to work, which would encourage life times to be considered
1978 // when passing ssv's around cross process. At present, we get 'lucky' i n some cases because
1979 // the blob in the src process happens to still exists at the time the d est process is deserializing.
1980 // For example in sharedWorker.postMesssage(...).
1981 BlobDataHandleMap::const_iterator it = m_blobDataHandles.find(uuid);
1982 if (it != m_blobDataHandles.end())
1983 return it->value;
1984 return BlobDataHandle::create(uuid, type, size);
1985 }
1986
1968 const uint8_t* m_buffer; 1987 const uint8_t* m_buffer;
1969 const unsigned m_length; 1988 const unsigned m_length;
1970 unsigned m_position; 1989 unsigned m_position;
1971 uint32_t m_version; 1990 uint32_t m_version;
1972 v8::Isolate* m_isolate; 1991 v8::Isolate* m_isolate;
1992 const BlobDataHandleMap& m_blobDataHandles;
1973 }; 1993 };
1974 1994
1975 1995
1976 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; 1996 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray;
1977 1997
1978 class Deserializer : public CompositeCreator { 1998 class Deserializer : public CompositeCreator {
1979 public: 1999 public:
1980 explicit Deserializer(Reader& reader, 2000 explicit Deserializer(Reader& reader,
1981 MessagePortArray* messagePorts, ArrayBufferContentsArr ay* arrayBufferContents) 2001 MessagePortArray* messagePorts, ArrayBufferContentsArr ay* arrayBufferContents)
1982 : m_reader(reader) 2002 : m_reader(reader)
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 } 2436 }
2417 2437
2418 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow, v8::Is olate* isolate) 2438 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag ePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow, v8::Is olate* isolate)
2419 : m_externallyAllocatedMemory(0) 2439 : m_externallyAllocatedMemory(0)
2420 { 2440 {
2421 didThrow = false; 2441 didThrow = false;
2422 Writer writer(isolate); 2442 Writer writer(isolate);
2423 Serializer::Status status; 2443 Serializer::Status status;
2424 { 2444 {
2425 v8::TryCatch tryCatch; 2445 v8::TryCatch tryCatch;
2426 Serializer serializer(writer, messagePorts, arrayBuffers, m_blobURLs, tr yCatch); 2446 Serializer serializer(writer, messagePorts, arrayBuffers, m_blobDataHand les, tryCatch);
2427 status = serializer.serialize(value); 2447 status = serializer.serialize(value);
2428 if (status == Serializer::JSException) { 2448 if (status == Serializer::JSException) {
2429 // If there was a JS exception thrown, re-throw it. 2449 // If there was a JS exception thrown, re-throw it.
2430 didThrow = true; 2450 didThrow = true;
2431 tryCatch.ReThrow(); 2451 tryCatch.ReThrow();
2432 return; 2452 return;
2433 } 2453 }
2434 } 2454 }
2435 switch (status) { 2455 switch (status) {
2436 case Serializer::InputError: 2456 case Serializer::InputError:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messa gePorts) 2491 v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messa gePorts)
2472 { 2492 {
2473 return deserialize(v8::Isolate::GetCurrent(), messagePorts); 2493 return deserialize(v8::Isolate::GetCurrent(), messagePorts);
2474 } 2494 }
2475 2495
2476 v8::Handle<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, M essagePortArray* messagePorts) 2496 v8::Handle<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, M essagePortArray* messagePorts)
2477 { 2497 {
2478 if (!m_data.impl()) 2498 if (!m_data.impl())
2479 return v8NullWithCheck(isolate); 2499 return v8NullWithCheck(isolate);
2480 COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes); 2500 COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes);
2481 Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()), 2 * m_data.length(), isolate); 2501 Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()), 2 * m_data.length(), isolate, m_blobDataHandles);
2482 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g et()); 2502 Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.g et());
2483 return deserializer.deserialize(); 2503 return deserializer.deserialize();
2484 } 2504 }
2485 2505
2486 #if ENABLE(INSPECTOR) 2506 #if ENABLE(INSPECTOR)
2487 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt ate) 2507 ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptSt ate)
2488 { 2508 {
2489 v8::HandleScope handleScope; 2509 v8::HandleScope handleScope;
2490 v8::Context::Scope contextScope(scriptState->context()); 2510 v8::Context::Scope contextScope(scriptState->context());
2491 2511
(...skipping 19 matching lines...) Expand all
2511 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry); 2531 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry);
2512 } 2532 }
2513 } 2533 }
2514 2534
2515 uint32_t SerializedScriptValue::wireFormatVersion() 2535 uint32_t SerializedScriptValue::wireFormatVersion()
2516 { 2536 {
2517 return WebCore::wireFormatVersion; 2537 return WebCore::wireFormatVersion;
2518 } 2538 }
2519 2539
2520 } // namespace WebCore 2540 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/bindings/v8/SerializedScriptValue.h ('k') | WebCore/fileapi/Blob.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698