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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 { | 1132 { |
1133 ASSERT(!object.IsEmpty()); | 1133 ASSERT(!object.IsEmpty()); |
1134 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(object); | 1134 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(object); |
1135 if (!arrayBufferView) | 1135 if (!arrayBufferView) |
1136 return 0; | 1136 return 0; |
1137 if (!arrayBufferView->buffer()) | 1137 if (!arrayBufferView->buffer()) |
1138 return handleError(DataCloneError, next); | 1138 return handleError(DataCloneError, next); |
1139 v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer(), v8::Handle<v8::Object>(), m_writer.getIsolate()); | 1139 v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer(), v8::Handle<v8::Object>(), m_writer.getIsolate()); |
1140 if (underlyingBuffer.IsEmpty()) | 1140 if (underlyingBuffer.IsEmpty()) |
1141 return handleError(DataCloneError, next); | 1141 return handleError(DataCloneError, next); |
1142 StateBase* stateOut = doSerialize(underlyingBuffer, 0); | 1142 if (StateBase* stateOut = doSerialize(underlyingBuffer, 0)) { |
Dmitry Lomov (no reviews)
2013/11/04 10:15:35
style nit: I am a simple programmer and variable d
sof
2013/11/04 10:21:14
alright. One of the likeable syntactic features of
| |
1143 if (stateOut) | 1143 while (stateOut) |
1144 stateOut = pop(stateOut); | |
Dmitry Lomov (no reviews)
2013/11/04 10:15:35
Hmm I do not like this popping out loop (It repeat
sof
2013/11/04 10:21:14
Hmm, and we won't run into the depth check at the
| |
1144 return handleError(DataCloneError, next); | 1145 return handleError(DataCloneError, next); |
1146 } | |
1145 m_writer.writeArrayBufferView(*arrayBufferView); | 1147 m_writer.writeArrayBufferView(*arrayBufferView); |
1146 // This should be safe: we serialize something that we know to be a wrap per (see | 1148 // This should be safe: we serialize something that we know to be a wrap per (see |
1147 // the toV8 call above), so the call to doSerialize above should neither cause | 1149 // the toV8 call above), so the call to doSerialize above should neither cause |
1148 // the stack to overflow nor should it have the potential to reach this | 1150 // the stack to overflow nor should it have the potential to reach this |
1149 // ArrayBufferView again. We do need to grey the underlying buffer befor e we grey | 1151 // ArrayBufferView again. We do need to grey the underlying buffer befor e we grey |
1150 // its view, however; ArrayBuffers may be shared, so they need to be giv en reference IDs, | 1152 // its view, however; ArrayBuffers may be shared, so they need to be giv en reference IDs, |
1151 // and an ArrayBufferView cannot be constructed without a corresponding ArrayBuffer | 1153 // and an ArrayBufferView cannot be constructed without a corresponding ArrayBuffer |
1152 // (or without an additional tag that would allow us to do two-stage con struction | 1154 // (or without an additional tag that would allow us to do two-stage con struction |
1153 // like we do for Objects and Arrays). | 1155 // like we do for Objects and Arrays). |
1154 greyObject(object); | 1156 greyObject(object); |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2555 // If the allocated memory was not registered before, then this class is lik ely | 2557 // If the allocated memory was not registered before, then this class is lik ely |
2556 // used in a context other then Worker's onmessage environment and the prese nce of | 2558 // used in a context other then Worker's onmessage environment and the prese nce of |
2557 // current v8 context is not guaranteed. Avoid calling v8 then. | 2559 // current v8 context is not guaranteed. Avoid calling v8 then. |
2558 if (m_externallyAllocatedMemory) { | 2560 if (m_externallyAllocatedMemory) { |
2559 ASSERT(v8::Isolate::GetCurrent()); | 2561 ASSERT(v8::Isolate::GetCurrent()); |
2560 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry); | 2562 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externallyAllocatedMemo ry); |
2561 } | 2563 } |
2562 } | 2564 } |
2563 | 2565 |
2564 } // namespace WebCore | 2566 } // namespace WebCore |
OLD | NEW |