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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 } | 1275 } |
1276 | 1276 |
1277 StateBase* writeBlob(v8::Handle<v8::Value> value, StateBase* next) | 1277 StateBase* writeBlob(v8::Handle<v8::Value> value, StateBase* next) |
1278 { | 1278 { |
1279 Blob* blob = V8Blob::toNative(value.As<v8::Object>()); | 1279 Blob* blob = V8Blob::toNative(value.As<v8::Object>()); |
1280 if (!blob) | 1280 if (!blob) |
1281 return 0; | 1281 return 0; |
1282 if (blob->hasBeenClosed()) | 1282 if (blob->hasBeenClosed()) |
1283 return handleError(DataCloneError, "A Blob object has been closed, a
nd could therefore not be cloned.", next); | 1283 return handleError(DataCloneError, "A Blob object has been closed, a
nd could therefore not be cloned.", next); |
1284 int blobIndex = -1; | 1284 int blobIndex = -1; |
1285 m_blobDataHandles.add(blob->uuid(), blob->blobDataHandle()); | 1285 m_blobDataHandles.set(blob->uuid(), blob->blobDataHandle()); |
1286 if (appendBlobInfo(blob->uuid(), blob->type(), blob->size(), &blobIndex)
) | 1286 if (appendBlobInfo(blob->uuid(), blob->type(), blob->size(), &blobIndex)
) |
1287 m_writer.writeBlobIndex(blobIndex); | 1287 m_writer.writeBlobIndex(blobIndex); |
1288 else | 1288 else |
1289 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); | 1289 m_writer.writeBlob(blob->uuid(), blob->type(), blob->size()); |
1290 return 0; | 1290 return 0; |
1291 } | 1291 } |
1292 | 1292 |
1293 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next) | 1293 StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next) |
1294 { | 1294 { |
1295 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>()); | 1295 DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>()); |
1296 if (!fs) | 1296 if (!fs) |
1297 return 0; | 1297 return 0; |
1298 if (!fs->clonable()) | 1298 if (!fs->clonable()) |
1299 return handleError(DataCloneError, "A FileSystem object could not be
cloned.", next); | 1299 return handleError(DataCloneError, "A FileSystem object could not be
cloned.", next); |
1300 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string
()); | 1300 m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string
()); |
1301 return 0; | 1301 return 0; |
1302 } | 1302 } |
1303 | 1303 |
1304 StateBase* writeFile(v8::Handle<v8::Value> value, StateBase* next) | 1304 StateBase* writeFile(v8::Handle<v8::Value> value, StateBase* next) |
1305 { | 1305 { |
1306 File* file = V8File::toNative(value.As<v8::Object>()); | 1306 File* file = V8File::toNative(value.As<v8::Object>()); |
1307 if (!file) | 1307 if (!file) |
1308 return 0; | 1308 return 0; |
1309 if (file->hasBeenClosed()) | 1309 if (file->hasBeenClosed()) |
1310 return handleError(DataCloneError, "A File object has been closed, a
nd could therefore not be cloned.", next); | 1310 return handleError(DataCloneError, "A File object has been closed, a
nd could therefore not be cloned.", next); |
1311 int blobIndex = -1; | 1311 int blobIndex = -1; |
1312 m_blobDataHandles.add(file->uuid(), file->blobDataHandle()); | 1312 m_blobDataHandles.set(file->uuid(), file->blobDataHandle()); |
1313 if (appendFileInfo(file, &blobIndex)) { | 1313 if (appendFileInfo(file, &blobIndex)) { |
1314 ASSERT(blobIndex >= 0); | 1314 ASSERT(blobIndex >= 0); |
1315 m_writer.writeFileIndex(blobIndex); | 1315 m_writer.writeFileIndex(blobIndex); |
1316 } else { | 1316 } else { |
1317 m_writer.writeFile(*file); | 1317 m_writer.writeFile(*file); |
1318 } | 1318 } |
1319 return 0; | 1319 return 0; |
1320 } | 1320 } |
1321 | 1321 |
1322 StateBase* writeFileList(v8::Handle<v8::Value> value, StateBase* next) | 1322 StateBase* writeFileList(v8::Handle<v8::Value> value, StateBase* next) |
1323 { | 1323 { |
1324 FileList* fileList = V8FileList::toNative(value.As<v8::Object>()); | 1324 FileList* fileList = V8FileList::toNative(value.As<v8::Object>()); |
1325 if (!fileList) | 1325 if (!fileList) |
1326 return 0; | 1326 return 0; |
1327 unsigned length = fileList->length(); | 1327 unsigned length = fileList->length(); |
1328 Vector<int> blobIndices; | 1328 Vector<int> blobIndices; |
1329 for (unsigned i = 0; i < length; ++i) { | 1329 for (unsigned i = 0; i < length; ++i) { |
1330 int blobIndex = -1; | 1330 int blobIndex = -1; |
1331 const File* file = fileList->item(i); | 1331 const File* file = fileList->item(i); |
1332 if (file->hasBeenClosed()) | 1332 if (file->hasBeenClosed()) |
1333 return handleError(DataCloneError, "A File object has been close
d, and could therefore not be cloned.", next); | 1333 return handleError(DataCloneError, "A File object has been close
d, and could therefore not be cloned.", next); |
1334 m_blobDataHandles.add(file->uuid(), file->blobDataHandle()); | 1334 m_blobDataHandles.set(file->uuid(), file->blobDataHandle()); |
1335 if (appendFileInfo(file, &blobIndex)) { | 1335 if (appendFileInfo(file, &blobIndex)) { |
1336 ASSERT(!i || blobIndex > 0); | 1336 ASSERT(!i || blobIndex > 0); |
1337 ASSERT(blobIndex >= 0); | 1337 ASSERT(blobIndex >= 0); |
1338 blobIndices.append(blobIndex); | 1338 blobIndices.append(blobIndex); |
1339 } | 1339 } |
1340 } | 1340 } |
1341 if (!blobIndices.isEmpty()) | 1341 if (!blobIndices.isEmpty()) |
1342 m_writer.writeFileListIndex(blobIndices); | 1342 m_writer.writeFileListIndex(blobIndices); |
1343 else | 1343 else |
1344 m_writer.writeFileList(*fileList); | 1344 m_writer.writeFileList(*fileList); |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 // If the allocated memory was not registered before, then this class is lik
ely | 3053 // If the allocated memory was not registered before, then this class is lik
ely |
3054 // used in a context other then Worker's onmessage environment and the prese
nce of | 3054 // used in a context other then Worker's onmessage environment and the prese
nce of |
3055 // current v8 context is not guaranteed. Avoid calling v8 then. | 3055 // current v8 context is not guaranteed. Avoid calling v8 then. |
3056 if (m_externallyAllocatedMemory) { | 3056 if (m_externallyAllocatedMemory) { |
3057 ASSERT(v8::Isolate::GetCurrent()); | 3057 ASSERT(v8::Isolate::GetCurrent()); |
3058 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 3058 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
3059 } | 3059 } |
3060 } | 3060 } |
3061 | 3061 |
3062 } // namespace WebCore | 3062 } // namespace WebCore |
OLD | NEW |