OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Informs V8 about external memory allocated and owned by this object. | 132 // Informs V8 about external memory allocated and owned by this object. |
133 // Large values should contribute to GC counters to eventually trigger a GC, | 133 // Large values should contribute to GC counters to eventually trigger a GC, |
134 // otherwise flood of postMessage() can cause OOM. | 134 // otherwise flood of postMessage() can cause OOM. |
135 // Ok to invoke multiple times (only adds memory once). | 135 // Ok to invoke multiple times (only adds memory once). |
136 // The memory registration is revoked automatically in destructor. | 136 // The memory registration is revoked automatically in destructor. |
137 void registerMemoryAllocatedWithCurrentScriptContext(); | 137 void registerMemoryAllocatedWithCurrentScriptContext(); |
138 | 138 |
139 // Upon passing a serialized value from one context to another (via a | 139 // Upon passing a serialized value from one context to another (via a |
140 // postMessage()), the allocation amounts it has registered with the | 140 // postMessage()), the allocation amounts it has registered with the |
141 // 'origining' context must be discharged, as the 'target' context will assume | 141 // 'origining' context must be discharged, as the 'target' context will assume |
142 // ownership of value. This method takes care of the first part of the | 142 // ownership of the value. As we're potentially working across threads, this |
143 // external allocation bookkeeping, the above registration method the other | 143 // transfer of cost is handled in three stages: |
144 // half. | 144 // |
145 void unregisterMemoryAllocatedByCurrentScriptContext(); | 145 // - prepareForTransferringContext(): prepares and marks this |
| 146 // SerializedScriptValue as being destined for transfer to another |
| 147 // context. |
| 148 // - finalizeTransferringContext(): checks if the transfer was successful, |
| 149 // and if so, discounts allocation costs from the context just left. |
| 150 // - registerMemoryAllocatedWithCurrentScriptContext() - called by the |
| 151 // 'target' once ownership has been assumed. It registers the allocation |
| 152 // costs of the resources that the SerializedScriptValue holds onto in |
| 153 // that new context. |
| 154 // |
| 155 // The first two are called by 'origining' context, before and after actual |
| 156 // transfer. |
| 157 // |
| 158 void prepareForTransferringContext(); |
| 159 void finalizeTransferringContext(); |
146 | 160 |
147 const uint8_t* data() const { return m_dataBuffer.get(); } | 161 const uint8_t* data() const { return m_dataBuffer.get(); } |
148 size_t dataLengthInBytes() const { return m_dataBufferSize; } | 162 size_t dataLengthInBytes() const { return m_dataBufferSize; } |
149 | 163 |
150 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 164 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
151 ArrayBufferContentsArray* getArrayBufferContentsArray() { | 165 ArrayBufferContentsArray* getArrayBufferContentsArray() { |
152 return m_arrayBufferContentsArray.get(); | 166 return m_arrayBufferContentsArray.get(); |
153 } | 167 } |
154 ImageBitmapContentsArray* getImageBitmapContentsArray() { | 168 ImageBitmapContentsArray* getImageBitmapContentsArray() { |
155 return m_imageBitmapContentsArray.get(); | 169 return m_imageBitmapContentsArray.get(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 v8::Local<v8::Value> value, | 214 v8::Local<v8::Value> value, |
201 ExceptionState& exceptionState) { | 215 ExceptionState& exceptionState) { |
202 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, | 216 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, |
203 exceptionState); | 217 exceptionState); |
204 } | 218 } |
205 }; | 219 }; |
206 | 220 |
207 } // namespace blink | 221 } // namespace blink |
208 | 222 |
209 #endif // SerializedScriptValue_h | 223 #endif // SerializedScriptValue_h |
OLD | NEW |