OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" | 5 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" |
6 | 6 |
7 #include "bindings/core/v8/ToV8.h" | 7 #include "bindings/core/v8/ToV8.h" |
8 #include "core/dom/CompositorProxy.h" | 8 #include "core/dom/CompositorProxy.h" |
9 #include "core/dom/DOMArrayBuffer.h" | 9 #include "core/dom/DOMArrayBuffer.h" |
10 #include "core/dom/DOMSharedArrayBuffer.h" | 10 #include "core/dom/DOMSharedArrayBuffer.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 break; | 205 break; |
206 } | 206 } |
207 return nullptr; | 207 return nullptr; |
208 } | 208 } |
209 | 209 |
210 RefPtr<BlobDataHandle> V8ScriptValueDeserializer::getOrCreateBlobDataHandle( | 210 RefPtr<BlobDataHandle> V8ScriptValueDeserializer::getOrCreateBlobDataHandle( |
211 const String& uuid, | 211 const String& uuid, |
212 const String& type, | 212 const String& type, |
213 uint64_t size) { | 213 uint64_t size) { |
214 // The containing ssv may have a BDH for this uuid if this ssv is just being | 214 // The containing ssv may have a BDH for this uuid if this ssv is just being |
215 // passed from main to worker thread (for example). We use those values when c
reating | 215 // passed from main to worker thread (for example). We use those values when |
216 // the new blob instead of cons'ing up a new BDH. | 216 // creating the new blob instead of cons'ing up a new BDH. |
217 // | 217 // |
218 // FIXME: Maybe we should require that it work that way where the ssv must hav
e a BDH for any | 218 // FIXME: Maybe we should require that it work that way where the ssv must |
219 // blobs it comes across during deserialization. Would require callers to expl
icitly populate | 219 // have a BDH for any blobs it comes across during deserialization. Would |
220 // the collection of BDH's for blobs to work, which would encourage lifetimes
to be considered | 220 // require callers to explicitly populate the collection of BDH's for blobs to |
221 // when passing ssv's around cross process. At present, we get 'lucky' in some
cases because | 221 // work, which would encourage lifetimes to be considered when passing ssv's |
222 // the blob in the src process happens to still exist at the time the dest pro
cess is deserializing. | 222 // around cross process. At present, we get 'lucky' in some cases because the |
| 223 // blob in the src process happens to still exist at the time the dest process |
| 224 // is deserializing. |
223 // For example in sharedWorker.postMessage(...). | 225 // For example in sharedWorker.postMessage(...). |
224 BlobDataHandleMap& handles = m_serializedScriptValue->blobDataHandles(); | 226 BlobDataHandleMap& handles = m_serializedScriptValue->blobDataHandles(); |
225 BlobDataHandleMap::const_iterator it = handles.find(uuid); | 227 BlobDataHandleMap::const_iterator it = handles.find(uuid); |
226 if (it != handles.end()) { | 228 if (it != handles.end()) { |
227 RefPtr<BlobDataHandle> handle = it->value; | 229 RefPtr<BlobDataHandle> handle = it->value; |
228 DCHECK_EQ(handle->type(), type); | 230 DCHECK_EQ(handle->type(), type); |
229 DCHECK_EQ(handle->size(), size); | 231 DCHECK_EQ(handle->size(), size); |
230 return handle; | 232 return handle; |
231 } | 233 } |
232 return BlobDataHandle::create(uuid, type, size); | 234 return BlobDataHandle::create(uuid, type, size); |
(...skipping 13 matching lines...) Expand all Loading... |
246 "Unable to deserialize cloned data."); | 248 "Unable to deserialize cloned data."); |
247 return v8::MaybeLocal<v8::Object>(); | 249 return v8::MaybeLocal<v8::Object>(); |
248 } | 250 } |
249 v8::Local<v8::Object> creationContext = m_scriptState->context()->Global(); | 251 v8::Local<v8::Object> creationContext = m_scriptState->context()->Global(); |
250 v8::Local<v8::Value> wrapper = toV8(wrappable, creationContext, isolate); | 252 v8::Local<v8::Value> wrapper = toV8(wrappable, creationContext, isolate); |
251 DCHECK(wrapper->IsObject()); | 253 DCHECK(wrapper->IsObject()); |
252 return wrapper.As<v8::Object>(); | 254 return wrapper.As<v8::Object>(); |
253 } | 255 } |
254 | 256 |
255 } // namespace blink | 257 } // namespace blink |
OLD | NEW |