OLD | NEW |
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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 v8::Handle<v8::NumberObject> numberObject = value.As<v8::NumberObject>()
; | 1045 v8::Handle<v8::NumberObject> numberObject = value.As<v8::NumberObject>()
; |
1046 m_writer.writeNumberObject(numberObject->ValueOf()); | 1046 m_writer.writeNumberObject(numberObject->ValueOf()); |
1047 } | 1047 } |
1048 | 1048 |
1049 void writeBooleanObject(v8::Handle<v8::Value> value) | 1049 void writeBooleanObject(v8::Handle<v8::Value> value) |
1050 { | 1050 { |
1051 v8::Handle<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject
>(); | 1051 v8::Handle<v8::BooleanObject> booleanObject = value.As<v8::BooleanObject
>(); |
1052 m_writer.writeBooleanObject(booleanObject->ValueOf()); | 1052 m_writer.writeBooleanObject(booleanObject->ValueOf()); |
1053 } | 1053 } |
1054 | 1054 |
1055 void writeBlob(v8::Handle<v8::Value> value) | 1055 StateBase* writeBlob(v8::Handle<v8::Value> value, StateBase* next) |
1056 { | 1056 { |
1057 Blob* blob = V8Blob::toNative(value.As<v8::Object>()); | 1057 Blob* blob = V8Blob::toNative(value.As<v8::Object>()); |
1058 if (!blob) | 1058 if (!blob) |
1059 return; | 1059 return 0; |
| 1060 if (blob->hasBeenClosed()) |
| 1061 return handleError(DataCloneError, "A Blob object has been closed, a
nd could therefore not be cloned.", next); |
1060 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); | 1062 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); |
1061 m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle()); | 1063 m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle()); |
| 1064 return 0; |
1062 } | 1065 } |
1063 | 1066 |
1064 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next) | 1067 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next) |
1065 { | 1068 { |
1066 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>()); | 1069 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>()); |
1067 if (!fs) | 1070 if (!fs) |
1068 return 0; | 1071 return 0; |
1069 if (!fs->clonable()) | 1072 if (!fs->clonable()) |
1070 return handleError(DataCloneError, "A FileSystem object could not be
cloned.", next); | 1073 return handleError(DataCloneError, "A FileSystem object could not be
cloned.", next); |
1071 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string
()); | 1074 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string
()); |
1072 return 0; | 1075 return 0; |
1073 } | 1076 } |
1074 | 1077 |
1075 void writeFile(v8::Handle<v8::Value> value) | 1078 StateBase* writeFile(v8::Handle<v8::Value> value, StateBase* next) |
1076 { | 1079 { |
1077 File* file = V8File::toNative(value.As<v8::Object>()); | 1080 File* file = V8File::toNative(value.As<v8::Object>()); |
1078 if (!file) | 1081 if (!file) |
1079 return; | 1082 return 0; |
| 1083 if (file->hasBeenClosed()) |
| 1084 return handleError(DataCloneError, "A File object has been closed, a
nd could therefore not be cloned.", next); |
1080 m_writer.writeFile(*file); | 1085 m_writer.writeFile(*file); |
1081 m_blobDataHandles.add(file->uuid(), file->blobDataHandle()); | 1086 m_blobDataHandles.add(file->uuid(), file->blobDataHandle()); |
| 1087 return 0; |
1082 } | 1088 } |
1083 | 1089 |
1084 void writeFileList(v8::Handle<v8::Value> value) | 1090 void writeFileList(v8::Handle<v8::Value> value) |
1085 { | 1091 { |
1086 FileList* fileList = V8FileList::toNative(value.As<v8::Object>()); | 1092 FileList* fileList = V8FileList::toNative(value.As<v8::Object>()); |
1087 if (!fileList) | 1093 if (!fileList) |
1088 return; | 1094 return; |
1089 m_writer.writeFileList(*fileList); | 1095 m_writer.writeFileList(*fileList); |
1090 unsigned length = fileList->length(); | 1096 unsigned length = fileList->length(); |
1091 for (unsigned i = 0; i < length; ++i) | 1097 for (unsigned i = 0; i < length; ++i) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 m_writer.writeDate(value->NumberValue()); | 1279 m_writer.writeDate(value->NumberValue()); |
1274 else if (value->IsStringObject()) | 1280 else if (value->IsStringObject()) |
1275 writeStringObject(value); | 1281 writeStringObject(value); |
1276 else if (value->IsNumberObject()) | 1282 else if (value->IsNumberObject()) |
1277 writeNumberObject(value); | 1283 writeNumberObject(value); |
1278 else if (value->IsBooleanObject()) | 1284 else if (value->IsBooleanObject()) |
1279 writeBooleanObject(value); | 1285 writeBooleanObject(value); |
1280 else if (value->IsArray()) { | 1286 else if (value->IsArray()) { |
1281 return startArrayState(value.As<v8::Array>(), next); | 1287 return startArrayState(value.As<v8::Array>(), next); |
1282 } else if (V8File::hasInstance(value, m_isolate)) | 1288 } else if (V8File::hasInstance(value, m_isolate)) |
1283 writeFile(value); | 1289 return writeFile(value, next); |
1284 else if (V8Blob::hasInstance(value, m_isolate)) | 1290 else if (V8Blob::hasInstance(value, m_isolate)) |
1285 writeBlob(value); | 1291 return writeBlob(value, next); |
1286 else if (V8DOMFileSystem::hasInstance(value, m_isolate)) | 1292 else if (V8DOMFileSystem::hasInstance(value, m_isolate)) |
1287 return writeDOMFileSystem(value, next); | 1293 return writeDOMFileSystem(value, next); |
1288 else if (V8FileList::hasInstance(value, m_isolate)) | 1294 else if (V8FileList::hasInstance(value, m_isolate)) |
1289 writeFileList(value); | 1295 writeFileList(value); |
1290 else if (V8ImageData::hasInstance(value, m_isolate)) | 1296 else if (V8ImageData::hasInstance(value, m_isolate)) |
1291 writeImageData(value); | 1297 writeImageData(value); |
1292 else if (value->IsRegExp()) | 1298 else if (value->IsRegExp()) |
1293 writeRegExp(value); | 1299 writeRegExp(value); |
1294 else if (V8ArrayBuffer::hasInstance(value, m_isolate)) | 1300 else if (V8ArrayBuffer::hasInstance(value, m_isolate)) |
1295 return writeArrayBuffer(value, next); | 1301 return writeArrayBuffer(value, next); |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2504 // If the allocated memory was not registered before, then this class is lik
ely | 2510 // If the allocated memory was not registered before, then this class is lik
ely |
2505 // used in a context other then Worker's onmessage environment and the prese
nce of | 2511 // used in a context other then Worker's onmessage environment and the prese
nce of |
2506 // current v8 context is not guaranteed. Avoid calling v8 then. | 2512 // current v8 context is not guaranteed. Avoid calling v8 then. |
2507 if (m_externallyAllocatedMemory) { | 2513 if (m_externallyAllocatedMemory) { |
2508 ASSERT(v8::Isolate::GetCurrent()); | 2514 ASSERT(v8::Isolate::GetCurrent()); |
2509 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 2515 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
2510 } | 2516 } |
2511 } | 2517 } |
2512 | 2518 |
2513 } // namespace WebCore | 2519 } // namespace WebCore |
OLD | NEW |