| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/indexeddb/IDBTestHelper.h" |
| 6 |
| 7 #include <utility> |
| 8 #include "modules/indexeddb/IDBKey.h" |
| 9 #include "modules/indexeddb/IDBKeyPath.h" |
| 10 #include "modules/indexeddb/IDBValueWrapping.h" |
| 11 #include "platform/SharedBuffer.h" |
| 12 #include "platform/blob/BlobData.h" |
| 13 #include "platform/wtf/Vector.h" |
| 14 #include "public/platform/WebBlobInfo.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 RefPtr<IDBValue> CreateIDBValueForTesting(v8::Isolate* isolate, |
| 19 bool create_wrapped_value) { |
| 20 size_t element_count = create_wrapped_value ? 16 : 2; |
| 21 v8::Local<v8::Array> v8_array = v8::Array::New(isolate, element_count); |
| 22 for (size_t i = 0; i < element_count; ++i) |
| 23 v8_array->Set(i, v8::True(isolate)); |
| 24 |
| 25 NonThrowableExceptionState non_throwable_exception_state; |
| 26 IDBValueWrapper wrapper(isolate, v8_array, |
| 27 SerializedScriptValue::SerializeOptions::kSerialize, |
| 28 non_throwable_exception_state); |
| 29 wrapper.WrapIfBiggerThan(create_wrapped_value ? 0 : 1024 * element_count); |
| 30 |
| 31 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data_handles = |
| 32 WTF::MakeUnique<Vector<RefPtr<BlobDataHandle>>>(); |
| 33 wrapper.ExtractBlobDataHandles(blob_data_handles.get()); |
| 34 Vector<WebBlobInfo>& blob_infos = wrapper.WrappedBlobInfo(); |
| 35 RefPtr<SharedBuffer> wrapped_marker_buffer = wrapper.ExtractWireBytes(); |
| 36 IDBKey* key = IDBKey::CreateNumber(42.0); |
| 37 IDBKeyPath key_path(String("primaryKey")); |
| 38 |
| 39 RefPtr<IDBValue> idb_value = IDBValue::Create( |
| 40 std::move(wrapped_marker_buffer), std::move(blob_data_handles), |
| 41 WTF::MakeUnique<Vector<WebBlobInfo>>(blob_infos), key, key_path); |
| 42 |
| 43 DCHECK_EQ(create_wrapped_value, |
| 44 IDBValueUnwrapper::IsWrapped(idb_value.Get())); |
| 45 return idb_value; |
| 46 } |
| 47 |
| 48 } // namespace blink |
| OLD | NEW |