| 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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 , m_next(next) | 1025 , m_next(next) |
| 1026 { | 1026 { |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 private: | 1029 private: |
| 1030 v8::Handle<v8::Value> m_composite; | 1030 v8::Handle<v8::Value> m_composite; |
| 1031 StateBase* m_next; | 1031 StateBase* m_next; |
| 1032 }; | 1032 }; |
| 1033 | 1033 |
| 1034 // Dummy state that is used to signal serialization errors. | 1034 // Dummy state that is used to signal serialization errors. |
| 1035 class ErrorState FINAL : public StateBase { | 1035 class ErrorState final : public StateBase { |
| 1036 public: | 1036 public: |
| 1037 ErrorState() | 1037 ErrorState() |
| 1038 : StateBase(v8Undefined(), 0) | 1038 : StateBase(v8Undefined(), 0) |
| 1039 { | 1039 { |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 virtual StateBase* advance(Serializer&) OVERRIDE | 1042 virtual StateBase* advance(Serializer&) override |
| 1043 { | 1043 { |
| 1044 delete this; | 1044 delete this; |
| 1045 return 0; | 1045 return 0; |
| 1046 } | 1046 } |
| 1047 }; | 1047 }; |
| 1048 | 1048 |
| 1049 template <typename T> | 1049 template <typename T> |
| 1050 class State : public StateBase { | 1050 class State : public StateBase { |
| 1051 public: | 1051 public: |
| 1052 v8::Handle<T> composite() { return v8::Handle<T>::Cast(StateBase::compos
ite()); } | 1052 v8::Handle<T> composite() { return v8::Handle<T>::Cast(StateBase::compos
ite()); } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 | 1117 |
| 1118 v8::Local<v8::Array> m_propertyNames; | 1118 v8::Local<v8::Array> m_propertyNames; |
| 1119 | 1119 |
| 1120 private: | 1120 private: |
| 1121 v8::Local<v8::Value> m_propertyName; | 1121 v8::Local<v8::Value> m_propertyName; |
| 1122 unsigned m_index; | 1122 unsigned m_index; |
| 1123 unsigned m_numSerializedProperties; | 1123 unsigned m_numSerializedProperties; |
| 1124 bool m_nameDone; | 1124 bool m_nameDone; |
| 1125 }; | 1125 }; |
| 1126 | 1126 |
| 1127 class ObjectState FINAL : public AbstractObjectState { | 1127 class ObjectState final : public AbstractObjectState { |
| 1128 public: | 1128 public: |
| 1129 ObjectState(v8::Handle<v8::Object> object, StateBase* next) | 1129 ObjectState(v8::Handle<v8::Object> object, StateBase* next) |
| 1130 : AbstractObjectState(object, next) | 1130 : AbstractObjectState(object, next) |
| 1131 { | 1131 { |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 virtual StateBase* advance(Serializer& serializer) OVERRIDE | 1134 virtual StateBase* advance(Serializer& serializer) override |
| 1135 { | 1135 { |
| 1136 if (m_propertyNames.IsEmpty()) { | 1136 if (m_propertyNames.IsEmpty()) { |
| 1137 m_propertyNames = composite()->GetPropertyNames(); | 1137 m_propertyNames = composite()->GetPropertyNames(); |
| 1138 if (StateBase* newState = serializer.checkException(this)) | 1138 if (StateBase* newState = serializer.checkException(this)) |
| 1139 return newState; | 1139 return newState; |
| 1140 if (m_propertyNames.IsEmpty()) | 1140 if (m_propertyNames.IsEmpty()) |
| 1141 return serializer.handleError(InputError, "Empty property na
mes cannot be cloned.", nextState()); | 1141 return serializer.handleError(InputError, "Empty property na
mes cannot be cloned.", nextState()); |
| 1142 } | 1142 } |
| 1143 return serializeProperties(false, serializer); | 1143 return serializeProperties(false, serializer); |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 protected: | 1146 protected: |
| 1147 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) OVERRIDE | 1147 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) override |
| 1148 { | 1148 { |
| 1149 return serializer.writeObject(numProperties, this); | 1149 return serializer.writeObject(numProperties, this); |
| 1150 } | 1150 } |
| 1151 }; | 1151 }; |
| 1152 | 1152 |
| 1153 class DenseArrayState FINAL : public AbstractObjectState { | 1153 class DenseArrayState final : public AbstractObjectState { |
| 1154 public: | 1154 public: |
| 1155 DenseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> prope
rtyNames, StateBase* next, v8::Isolate* isolate) | 1155 DenseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> prope
rtyNames, StateBase* next, v8::Isolate* isolate) |
| 1156 : AbstractObjectState(array, next) | 1156 : AbstractObjectState(array, next) |
| 1157 , m_arrayIndex(0) | 1157 , m_arrayIndex(0) |
| 1158 , m_arrayLength(array->Length()) | 1158 , m_arrayLength(array->Length()) |
| 1159 { | 1159 { |
| 1160 m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames); | 1160 m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 virtual StateBase* advance(Serializer& serializer) OVERRIDE | 1163 virtual StateBase* advance(Serializer& serializer) override |
| 1164 { | 1164 { |
| 1165 while (m_arrayIndex < m_arrayLength) { | 1165 while (m_arrayIndex < m_arrayLength) { |
| 1166 v8::Handle<v8::Value> value = composite().As<v8::Array>()->Get(m
_arrayIndex); | 1166 v8::Handle<v8::Value> value = composite().As<v8::Array>()->Get(m
_arrayIndex); |
| 1167 m_arrayIndex++; | 1167 m_arrayIndex++; |
| 1168 if (StateBase* newState = serializer.checkException(this)) | 1168 if (StateBase* newState = serializer.checkException(this)) |
| 1169 return newState; | 1169 return newState; |
| 1170 if (StateBase* newState = serializer.doSerialize(value, this)) | 1170 if (StateBase* newState = serializer.doSerialize(value, this)) |
| 1171 return newState; | 1171 return newState; |
| 1172 } | 1172 } |
| 1173 return serializeProperties(true, serializer); | 1173 return serializeProperties(true, serializer); |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 protected: | 1176 protected: |
| 1177 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) OVERRIDE | 1177 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) override |
| 1178 { | 1178 { |
| 1179 return serializer.writeDenseArray(numProperties, m_arrayLength, this
); | 1179 return serializer.writeDenseArray(numProperties, m_arrayLength, this
); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 private: | 1182 private: |
| 1183 uint32_t m_arrayIndex; | 1183 uint32_t m_arrayIndex; |
| 1184 uint32_t m_arrayLength; | 1184 uint32_t m_arrayLength; |
| 1185 }; | 1185 }; |
| 1186 | 1186 |
| 1187 class SparseArrayState FINAL : public AbstractObjectState { | 1187 class SparseArrayState final : public AbstractObjectState { |
| 1188 public: | 1188 public: |
| 1189 SparseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> prop
ertyNames, StateBase* next, v8::Isolate* isolate) | 1189 SparseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> prop
ertyNames, StateBase* next, v8::Isolate* isolate) |
| 1190 : AbstractObjectState(array, next) | 1190 : AbstractObjectState(array, next) |
| 1191 { | 1191 { |
| 1192 m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames); | 1192 m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames); |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 virtual StateBase* advance(Serializer& serializer) OVERRIDE | 1195 virtual StateBase* advance(Serializer& serializer) override |
| 1196 { | 1196 { |
| 1197 return serializeProperties(false, serializer); | 1197 return serializeProperties(false, serializer); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 protected: | 1200 protected: |
| 1201 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) OVERRIDE | 1201 virtual StateBase* objectDone(unsigned numProperties, Serializer& serial
izer) override |
| 1202 { | 1202 { |
| 1203 return serializer.writeSparseArray(numProperties, composite().As<v8:
:Array>()->Length(), this); | 1203 return serializer.writeSparseArray(numProperties, composite().As<v8:
:Array>()->Length(), this); |
| 1204 } | 1204 } |
| 1205 }; | 1205 }; |
| 1206 | 1206 |
| 1207 StateBase* push(StateBase* state) | 1207 StateBase* push(StateBase* state) |
| 1208 { | 1208 { |
| 1209 ASSERT(state); | 1209 ASSERT(state); |
| 1210 ++m_depth; | 1210 ++m_depth; |
| 1211 return checkComposite(state) ? state : handleError(InputError, "Value be
ing cloned is either cyclic or too deeply nested.", state); | 1211 return checkComposite(state) ? state : handleError(InputError, "Value be
ing cloned is either cyclic or too deeply nested.", state); |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 const unsigned m_length; | 2550 const unsigned m_length; |
| 2551 unsigned m_position; | 2551 unsigned m_position; |
| 2552 uint32_t m_version; | 2552 uint32_t m_version; |
| 2553 const WebBlobInfoArray* m_blobInfo; | 2553 const WebBlobInfoArray* m_blobInfo; |
| 2554 const BlobDataHandleMap& m_blobDataHandles; | 2554 const BlobDataHandleMap& m_blobDataHandles; |
| 2555 }; | 2555 }; |
| 2556 | 2556 |
| 2557 | 2557 |
| 2558 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; | 2558 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; |
| 2559 | 2559 |
| 2560 class Deserializer FINAL : public CompositeCreator { | 2560 class Deserializer final : public CompositeCreator { |
| 2561 public: | 2561 public: |
| 2562 Deserializer(Reader& reader, MessagePortArray* messagePorts, ArrayBufferCont
entsArray* arrayBufferContents) | 2562 Deserializer(Reader& reader, MessagePortArray* messagePorts, ArrayBufferCont
entsArray* arrayBufferContents) |
| 2563 : m_reader(reader) | 2563 : m_reader(reader) |
| 2564 , m_transferredMessagePorts(messagePorts) | 2564 , m_transferredMessagePorts(messagePorts) |
| 2565 , m_arrayBufferContents(arrayBufferContents) | 2565 , m_arrayBufferContents(arrayBufferContents) |
| 2566 , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) | 2566 , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) |
| 2567 , m_version(0) | 2567 , m_version(0) |
| 2568 { | 2568 { |
| 2569 } | 2569 } |
| 2570 | 2570 |
| 2571 v8::Handle<v8::Value> deserialize() | 2571 v8::Handle<v8::Value> deserialize() |
| 2572 { | 2572 { |
| 2573 v8::Isolate* isolate = m_reader.scriptState()->isolate(); | 2573 v8::Isolate* isolate = m_reader.scriptState()->isolate(); |
| 2574 if (!m_reader.readVersion(m_version) || m_version > SerializedScriptValu
e::wireFormatVersion) | 2574 if (!m_reader.readVersion(m_version) || m_version > SerializedScriptValu
e::wireFormatVersion) |
| 2575 return v8::Null(isolate); | 2575 return v8::Null(isolate); |
| 2576 m_reader.setVersion(m_version); | 2576 m_reader.setVersion(m_version); |
| 2577 v8::EscapableHandleScope scope(isolate); | 2577 v8::EscapableHandleScope scope(isolate); |
| 2578 while (!m_reader.isEof()) { | 2578 while (!m_reader.isEof()) { |
| 2579 if (!doDeserialize()) | 2579 if (!doDeserialize()) |
| 2580 return v8::Null(isolate); | 2580 return v8::Null(isolate); |
| 2581 } | 2581 } |
| 2582 if (stackDepth() != 1 || m_openCompositeReferenceStack.size()) | 2582 if (stackDepth() != 1 || m_openCompositeReferenceStack.size()) |
| 2583 return v8::Null(isolate); | 2583 return v8::Null(isolate); |
| 2584 v8::Handle<v8::Value> result = scope.Escape(element(0)); | 2584 v8::Handle<v8::Value> result = scope.Escape(element(0)); |
| 2585 return result; | 2585 return result; |
| 2586 } | 2586 } |
| 2587 | 2587 |
| 2588 virtual bool newSparseArray(uint32_t) OVERRIDE | 2588 virtual bool newSparseArray(uint32_t) override |
| 2589 { | 2589 { |
| 2590 v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isol
ate(), 0); | 2590 v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isol
ate(), 0); |
| 2591 openComposite(array); | 2591 openComposite(array); |
| 2592 return true; | 2592 return true; |
| 2593 } | 2593 } |
| 2594 | 2594 |
| 2595 virtual bool newDenseArray(uint32_t length) OVERRIDE | 2595 virtual bool newDenseArray(uint32_t length) override |
| 2596 { | 2596 { |
| 2597 v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isol
ate(), length); | 2597 v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isol
ate(), length); |
| 2598 openComposite(array); | 2598 openComposite(array); |
| 2599 return true; | 2599 return true; |
| 2600 } | 2600 } |
| 2601 | 2601 |
| 2602 virtual bool consumeTopOfStack(v8::Handle<v8::Value>* object) OVERRIDE | 2602 virtual bool consumeTopOfStack(v8::Handle<v8::Value>* object) override |
| 2603 { | 2603 { |
| 2604 if (stackDepth() < 1) | 2604 if (stackDepth() < 1) |
| 2605 return false; | 2605 return false; |
| 2606 *object = element(stackDepth() - 1); | 2606 *object = element(stackDepth() - 1); |
| 2607 pop(1); | 2607 pop(1); |
| 2608 return true; | 2608 return true; |
| 2609 } | 2609 } |
| 2610 | 2610 |
| 2611 virtual bool newObject() OVERRIDE | 2611 virtual bool newObject() override |
| 2612 { | 2612 { |
| 2613 v8::Local<v8::Object> object = v8::Object::New(m_reader.scriptState()->i
solate()); | 2613 v8::Local<v8::Object> object = v8::Object::New(m_reader.scriptState()->i
solate()); |
| 2614 if (object.IsEmpty()) | 2614 if (object.IsEmpty()) |
| 2615 return false; | 2615 return false; |
| 2616 openComposite(object); | 2616 openComposite(object); |
| 2617 return true; | 2617 return true; |
| 2618 } | 2618 } |
| 2619 | 2619 |
| 2620 virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>* v
alue) OVERRIDE | 2620 virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>* v
alue) override |
| 2621 { | 2621 { |
| 2622 v8::Local<v8::Object> object; | 2622 v8::Local<v8::Object> object; |
| 2623 if (m_version > 0) { | 2623 if (m_version > 0) { |
| 2624 v8::Local<v8::Value> composite; | 2624 v8::Local<v8::Value> composite; |
| 2625 if (!closeComposite(&composite)) | 2625 if (!closeComposite(&composite)) |
| 2626 return false; | 2626 return false; |
| 2627 object = composite.As<v8::Object>(); | 2627 object = composite.As<v8::Object>(); |
| 2628 } else { | 2628 } else { |
| 2629 object = v8::Object::New(m_reader.scriptState()->isolate()); | 2629 object = v8::Object::New(m_reader.scriptState()->isolate()); |
| 2630 } | 2630 } |
| 2631 if (object.IsEmpty()) | 2631 if (object.IsEmpty()) |
| 2632 return false; | 2632 return false; |
| 2633 return initializeObject(object, numProperties, value); | 2633 return initializeObject(object, numProperties, value); |
| 2634 } | 2634 } |
| 2635 | 2635 |
| 2636 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8
::Handle<v8::Value>* value) OVERRIDE | 2636 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8
::Handle<v8::Value>* value) override |
| 2637 { | 2637 { |
| 2638 v8::Local<v8::Array> array; | 2638 v8::Local<v8::Array> array; |
| 2639 if (m_version > 0) { | 2639 if (m_version > 0) { |
| 2640 v8::Local<v8::Value> composite; | 2640 v8::Local<v8::Value> composite; |
| 2641 if (!closeComposite(&composite)) | 2641 if (!closeComposite(&composite)) |
| 2642 return false; | 2642 return false; |
| 2643 array = composite.As<v8::Array>(); | 2643 array = composite.As<v8::Array>(); |
| 2644 } else { | 2644 } else { |
| 2645 array = v8::Array::New(m_reader.scriptState()->isolate()); | 2645 array = v8::Array::New(m_reader.scriptState()->isolate()); |
| 2646 } | 2646 } |
| 2647 if (array.IsEmpty()) | 2647 if (array.IsEmpty()) |
| 2648 return false; | 2648 return false; |
| 2649 return initializeObject(array, numProperties, value); | 2649 return initializeObject(array, numProperties, value); |
| 2650 } | 2650 } |
| 2651 | 2651 |
| 2652 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8:
:Handle<v8::Value>* value) OVERRIDE | 2652 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8:
:Handle<v8::Value>* value) override |
| 2653 { | 2653 { |
| 2654 v8::Local<v8::Array> array; | 2654 v8::Local<v8::Array> array; |
| 2655 if (m_version > 0) { | 2655 if (m_version > 0) { |
| 2656 v8::Local<v8::Value> composite; | 2656 v8::Local<v8::Value> composite; |
| 2657 if (!closeComposite(&composite)) | 2657 if (!closeComposite(&composite)) |
| 2658 return false; | 2658 return false; |
| 2659 array = composite.As<v8::Array>(); | 2659 array = composite.As<v8::Array>(); |
| 2660 } | 2660 } |
| 2661 if (array.IsEmpty()) | 2661 if (array.IsEmpty()) |
| 2662 return false; | 2662 return false; |
| 2663 if (!initializeObject(array, numProperties, value)) | 2663 if (!initializeObject(array, numProperties, value)) |
| 2664 return false; | 2664 return false; |
| 2665 if (length > stackDepth()) | 2665 if (length > stackDepth()) |
| 2666 return false; | 2666 return false; |
| 2667 for (unsigned i = 0, stackPos = stackDepth() - length; i < length; i++,
stackPos++) { | 2667 for (unsigned i = 0, stackPos = stackDepth() - length; i < length; i++,
stackPos++) { |
| 2668 v8::Local<v8::Value> elem = element(stackPos); | 2668 v8::Local<v8::Value> elem = element(stackPos); |
| 2669 if (!elem->IsUndefined()) | 2669 if (!elem->IsUndefined()) |
| 2670 array->Set(i, elem); | 2670 array->Set(i, elem); |
| 2671 } | 2671 } |
| 2672 pop(length); | 2672 pop(length); |
| 2673 return true; | 2673 return true; |
| 2674 } | 2674 } |
| 2675 | 2675 |
| 2676 virtual void pushObjectReference(const v8::Handle<v8::Value>& object) OVERRI
DE | 2676 virtual void pushObjectReference(const v8::Handle<v8::Value>& object) overri
de |
| 2677 { | 2677 { |
| 2678 m_objectPool.append(object); | 2678 m_objectPool.append(object); |
| 2679 } | 2679 } |
| 2680 | 2680 |
| 2681 virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle<v8::Val
ue>* object) OVERRIDE | 2681 virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle<v8::Val
ue>* object) override |
| 2682 { | 2682 { |
| 2683 if (!m_transferredMessagePorts) | 2683 if (!m_transferredMessagePorts) |
| 2684 return false; | 2684 return false; |
| 2685 if (index >= m_transferredMessagePorts->size()) | 2685 if (index >= m_transferredMessagePorts->size()) |
| 2686 return false; | 2686 return false; |
| 2687 v8::Handle<v8::Object> creationContext = m_reader.scriptState()->context
()->Global(); | 2687 v8::Handle<v8::Object> creationContext = m_reader.scriptState()->context
()->Global(); |
| 2688 *object = toV8(m_transferredMessagePorts->at(index).get(), creationConte
xt, m_reader.scriptState()->isolate()); | 2688 *object = toV8(m_transferredMessagePorts->at(index).get(), creationConte
xt, m_reader.scriptState()->isolate()); |
| 2689 return true; | 2689 return true; |
| 2690 } | 2690 } |
| 2691 | 2691 |
| 2692 virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle<v8::Val
ue>* object) OVERRIDE | 2692 virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle<v8::Val
ue>* object) override |
| 2693 { | 2693 { |
| 2694 if (!m_arrayBufferContents) | 2694 if (!m_arrayBufferContents) |
| 2695 return false; | 2695 return false; |
| 2696 if (index >= m_arrayBuffers.size()) | 2696 if (index >= m_arrayBuffers.size()) |
| 2697 return false; | 2697 return false; |
| 2698 v8::Handle<v8::Object> result = m_arrayBuffers.at(index); | 2698 v8::Handle<v8::Object> result = m_arrayBuffers.at(index); |
| 2699 if (result.IsEmpty()) { | 2699 if (result.IsEmpty()) { |
| 2700 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_arrayBufferConten
ts->at(index)); | 2700 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_arrayBufferConten
ts->at(index)); |
| 2701 buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::i
nstanceTemplate()); | 2701 buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::i
nstanceTemplate()); |
| 2702 v8::Isolate* isolate = m_reader.scriptState()->isolate(); | 2702 v8::Isolate* isolate = m_reader.scriptState()->isolate(); |
| 2703 v8::Handle<v8::Object> creationContext = m_reader.scriptState()->con
text()->Global(); | 2703 v8::Handle<v8::Object> creationContext = m_reader.scriptState()->con
text()->Global(); |
| 2704 isolate->AdjustAmountOfExternalAllocatedMemory(buffer->byteLength())
; | 2704 isolate->AdjustAmountOfExternalAllocatedMemory(buffer->byteLength())
; |
| 2705 result = toV8Object(buffer.get(), creationContext, isolate); | 2705 result = toV8Object(buffer.get(), creationContext, isolate); |
| 2706 m_arrayBuffers[index] = result; | 2706 m_arrayBuffers[index] = result; |
| 2707 } | 2707 } |
| 2708 *object = result; | 2708 *object = result; |
| 2709 return true; | 2709 return true; |
| 2710 } | 2710 } |
| 2711 | 2711 |
| 2712 virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Handle<
v8::Value>* object) OVERRIDE | 2712 virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Handle<
v8::Value>* object) override |
| 2713 { | 2713 { |
| 2714 if (reference >= m_objectPool.size()) | 2714 if (reference >= m_objectPool.size()) |
| 2715 return false; | 2715 return false; |
| 2716 *object = m_objectPool[reference]; | 2716 *object = m_objectPool[reference]; |
| 2717 return object; | 2717 return object; |
| 2718 } | 2718 } |
| 2719 | 2719 |
| 2720 virtual uint32_t objectReferenceCount() OVERRIDE | 2720 virtual uint32_t objectReferenceCount() override |
| 2721 { | 2721 { |
| 2722 return m_objectPool.size(); | 2722 return m_objectPool.size(); |
| 2723 } | 2723 } |
| 2724 | 2724 |
| 2725 private: | 2725 private: |
| 2726 bool initializeObject(v8::Handle<v8::Object> object, uint32_t numProperties,
v8::Handle<v8::Value>* value) | 2726 bool initializeObject(v8::Handle<v8::Object> object, uint32_t numProperties,
v8::Handle<v8::Value>* value) |
| 2727 { | 2727 { |
| 2728 unsigned length = 2 * numProperties; | 2728 unsigned length = 2 * numProperties; |
| 2729 if (length > stackDepth()) | 2729 if (length > stackDepth()) |
| 2730 return false; | 2730 return false; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 // If the allocated memory was not registered before, then this class is lik
ely | 3063 // If the allocated memory was not registered before, then this class is lik
ely |
| 3064 // used in a context other then Worker's onmessage environment and the prese
nce of | 3064 // used in a context other then Worker's onmessage environment and the prese
nce of |
| 3065 // current v8 context is not guaranteed. Avoid calling v8 then. | 3065 // current v8 context is not guaranteed. Avoid calling v8 then. |
| 3066 if (m_externallyAllocatedMemory) { | 3066 if (m_externallyAllocatedMemory) { |
| 3067 ASSERT(v8::Isolate::GetCurrent()); | 3067 ASSERT(v8::Isolate::GetCurrent()); |
| 3068 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 3068 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
| 3069 } | 3069 } |
| 3070 } | 3070 } |
| 3071 | 3071 |
| 3072 } // namespace blink | 3072 } // namespace blink |
| OLD | NEW |