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

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

Issue 125043004: Remove world type from hasInstance() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/ScriptProfiler.cpp ('k') | Source/bindings/v8/V8Binding.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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 uint32_t m_nextObjectReference; 1209 uint32_t m_nextObjectReference;
1210 BlobDataHandleMap& m_blobDataHandles; 1210 BlobDataHandleMap& m_blobDataHandles;
1211 v8::Isolate* m_isolate; 1211 v8::Isolate* m_isolate;
1212 }; 1212 };
1213 1213
1214 Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, Stat eBase* next) 1214 Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, Stat eBase* next)
1215 { 1215 {
1216 m_writer.writeReferenceCount(m_nextObjectReference); 1216 m_writer.writeReferenceCount(m_nextObjectReference);
1217 uint32_t objectReference; 1217 uint32_t objectReference;
1218 uint32_t arrayBufferIndex; 1218 uint32_t arrayBufferIndex;
1219 WrapperWorldType currentWorldType = worldType(m_isolate);
1220 if ((value->IsObject() || value->IsDate() || value->IsRegExp()) 1219 if ((value->IsObject() || value->IsDate() || value->IsRegExp())
1221 && m_objectPool.tryGet(value.As<v8::Object>(), &objectReference)) { 1220 && m_objectPool.tryGet(value.As<v8::Object>(), &objectReference)) {
1222 // Note that IsObject() also detects wrappers (eg, it will catch the thi ngs 1221 // Note that IsObject() also detects wrappers (eg, it will catch the thi ngs
1223 // that we grey and write below). 1222 // that we grey and write below).
1224 ASSERT(!value->IsString()); 1223 ASSERT(!value->IsString());
1225 m_writer.writeObjectReference(objectReference); 1224 m_writer.writeObjectReference(objectReference);
1226 } else if (value.IsEmpty()) { 1225 } else if (value.IsEmpty()) {
1227 return handleError(InputError, "The empty property name cannot be cloned .", next); 1226 return handleError(InputError, "The empty property name cannot be cloned .", next);
1228 } else if (value->IsUndefined()) 1227 } else if (value->IsUndefined())
1229 m_writer.writeUndefined(); 1228 m_writer.writeUndefined();
1230 else if (value->IsNull()) 1229 else if (value->IsNull())
1231 m_writer.writeNull(); 1230 m_writer.writeNull();
1232 else if (value->IsTrue()) 1231 else if (value->IsTrue())
1233 m_writer.writeTrue(); 1232 m_writer.writeTrue();
1234 else if (value->IsFalse()) 1233 else if (value->IsFalse())
1235 m_writer.writeFalse(); 1234 m_writer.writeFalse();
1236 else if (value->IsInt32()) 1235 else if (value->IsInt32())
1237 m_writer.writeInt32(value->Int32Value()); 1236 m_writer.writeInt32(value->Int32Value());
1238 else if (value->IsUint32()) 1237 else if (value->IsUint32())
1239 m_writer.writeUint32(value->Uint32Value()); 1238 m_writer.writeUint32(value->Uint32Value());
1240 else if (value->IsNumber()) 1239 else if (value->IsNumber())
1241 m_writer.writeNumber(value.As<v8::Number>()->Value()); 1240 m_writer.writeNumber(value.As<v8::Number>()->Value());
1242 else if (V8ArrayBufferView::hasInstance(value, m_isolate, currentWorldType)) 1241 else if (V8ArrayBufferView::hasInstance(value, m_isolate))
1243 return writeAndGreyArrayBufferView(value.As<v8::Object>(), next); 1242 return writeAndGreyArrayBufferView(value.As<v8::Object>(), next);
1244 else if (value->IsString()) 1243 else if (value->IsString())
1245 writeString(value); 1244 writeString(value);
1246 else if (V8MessagePort::hasInstance(value, m_isolate, currentWorldType)) { 1245 else if (V8MessagePort::hasInstance(value, m_isolate)) {
1247 uint32_t messagePortIndex; 1246 uint32_t messagePortIndex;
1248 if (m_transferredMessagePorts.tryGet(value.As<v8::Object>(), &messagePor tIndex)) 1247 if (m_transferredMessagePorts.tryGet(value.As<v8::Object>(), &messagePor tIndex))
1249 m_writer.writeTransferredMessagePort(messagePortIndex); 1248 m_writer.writeTransferredMessagePort(messagePortIndex);
1250 else 1249 else
1251 return handleError(DataCloneError, "A MessagePort could not be c loned.", next); 1250 return handleError(DataCloneError, "A MessagePort could not be c loned.", next);
1252 } else if (V8ArrayBuffer::hasInstance(value, m_isolate, currentWorldType) && m_transferredArrayBuffers.tryGet(value.As<v8::Object>(), &arrayBufferIndex)) 1251 } else if (V8ArrayBuffer::hasInstance(value, m_isolate) && m_transferredArra yBuffers.tryGet(value.As<v8::Object>(), &arrayBufferIndex))
1253 return writeTransferredArrayBuffer(value, arrayBufferIndex, next); 1252 return writeTransferredArrayBuffer(value, arrayBufferIndex, next);
1254 else { 1253 else {
1255 v8::Handle<v8::Object> jsObject = value.As<v8::Object>(); 1254 v8::Handle<v8::Object> jsObject = value.As<v8::Object>();
1256 if (jsObject.IsEmpty()) 1255 if (jsObject.IsEmpty())
1257 return handleError(DataCloneError, "An object could not be cloned.", next); 1256 return handleError(DataCloneError, "An object could not be cloned.", next);
1258 greyObject(jsObject); 1257 greyObject(jsObject);
1259 if (value->IsDate()) 1258 if (value->IsDate())
1260 m_writer.writeDate(value->NumberValue()); 1259 m_writer.writeDate(value->NumberValue());
1261 else if (value->IsStringObject()) 1260 else if (value->IsStringObject())
1262 writeStringObject(value); 1261 writeStringObject(value);
1263 else if (value->IsNumberObject()) 1262 else if (value->IsNumberObject())
1264 writeNumberObject(value); 1263 writeNumberObject(value);
1265 else if (value->IsBooleanObject()) 1264 else if (value->IsBooleanObject())
1266 writeBooleanObject(value); 1265 writeBooleanObject(value);
1267 else if (value->IsArray()) { 1266 else if (value->IsArray()) {
1268 return startArrayState(value.As<v8::Array>(), next); 1267 return startArrayState(value.As<v8::Array>(), next);
1269 } else if (V8File::hasInstance(value, m_isolate, currentWorldType)) 1268 } else if (V8File::hasInstance(value, m_isolate))
1270 writeFile(value); 1269 writeFile(value);
1271 else if (V8Blob::hasInstance(value, m_isolate, currentWorldType)) 1270 else if (V8Blob::hasInstance(value, m_isolate))
1272 writeBlob(value); 1271 writeBlob(value);
1273 else if (V8DOMFileSystem::hasInstance(value, m_isolate, currentWorldType )) 1272 else if (V8DOMFileSystem::hasInstance(value, m_isolate))
1274 return writeDOMFileSystem(value, next); 1273 return writeDOMFileSystem(value, next);
1275 else if (V8FileList::hasInstance(value, m_isolate, currentWorldType)) 1274 else if (V8FileList::hasInstance(value, m_isolate))
1276 writeFileList(value); 1275 writeFileList(value);
1277 else if (V8ImageData::hasInstance(value, m_isolate, currentWorldType)) 1276 else if (V8ImageData::hasInstance(value, m_isolate))
1278 writeImageData(value); 1277 writeImageData(value);
1279 else if (value->IsRegExp()) 1278 else if (value->IsRegExp())
1280 writeRegExp(value); 1279 writeRegExp(value);
1281 else if (V8ArrayBuffer::hasInstance(value, m_isolate, currentWorldType)) 1280 else if (V8ArrayBuffer::hasInstance(value, m_isolate))
1282 return writeArrayBuffer(value, next); 1281 return writeArrayBuffer(value, next);
1283 else if (value->IsObject()) { 1282 else if (value->IsObject()) {
1284 if (isHostObject(jsObject) || jsObject->IsCallable() || value->IsNat iveError()) 1283 if (isHostObject(jsObject) || jsObject->IsCallable() || value->IsNat iveError())
1285 return handleError(DataCloneError, "An object could not be clone d.", next); 1284 return handleError(DataCloneError, "An object could not be clone d.", next);
1286 return startObjectState(jsObject, next); 1285 return startObjectState(jsObject, next);
1287 } else 1286 } else
1288 return handleError(DataCloneError, "A value could not be cloned.", n ext); 1287 return handleError(DataCloneError, "A value could not be cloned.", n ext);
1289 } 1288 }
1290 return 0; 1289 return 0;
1291 } 1290 }
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 // If the allocated memory was not registered before, then this class is lik ely 2450 // If the allocated memory was not registered before, then this class is lik ely
2452 // used in a context other then Worker's onmessage environment and the prese nce of 2451 // used in a context other then Worker's onmessage environment and the prese nce of
2453 // current v8 context is not guaranteed. Avoid calling v8 then. 2452 // current v8 context is not guaranteed. Avoid calling v8 then.
2454 if (m_externallyAllocatedMemory) { 2453 if (m_externallyAllocatedMemory) {
2455 ASSERT(v8::Isolate::GetCurrent()); 2454 ASSERT(v8::Isolate::GetCurrent());
2456 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory); 2455 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte rnallyAllocatedMemory);
2457 } 2456 }
2458 } 2457 }
2459 2458
2460 } // namespace WebCore 2459 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptProfiler.cpp ('k') | Source/bindings/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698