Chromium Code Reviews| Index: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp |
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp |
| index 5362645282d29d6ac8864bd85645dc993c8ed338..3b5b0ca207e06099cfd379e1ad7ced6a1362b44d 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp |
| @@ -40,9 +40,11 @@ |
| #include "modules/indexeddb/IDBDatabase.h" |
| #include "modules/indexeddb/IDBKeyPath.h" |
| #include "modules/indexeddb/IDBTracing.h" |
| +#include "modules/indexeddb/IDBValueWrapper.h" |
| #include "platform/Histogram.h" |
| #include "platform/SharedBuffer.h" |
| #include "platform/bindings/ScriptState.h" |
| +#include "platform/wtf/RefPtr.h" |
| #include "public/platform/WebBlobInfo.h" |
| #include "public/platform/WebData.h" |
| #include "public/platform/WebVector.h" |
| @@ -376,15 +378,10 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| v8::Isolate* isolate = script_state->GetIsolate(); |
| DCHECK(isolate->InContext()); |
| - Vector<WebBlobInfo> blob_info; |
| - SerializedScriptValue::SerializeOptions options; |
| - options.blob_info = &blob_info; |
| - options.write_wasm_to_stream = |
| + bool write_wasm_to_stream = |
| ExecutionContext::From(script_state)->IsSecureContext(); |
| - options.for_storage = true; |
| - RefPtr<SerializedScriptValue> serialized_value = |
| - SerializedScriptValue::Serialize(isolate, value.V8Value(), options, |
| - exception_state); |
| + IDBValueWrapper value_wrapper(isolate, value.V8Value(), write_wasm_to_stream, |
|
jsbell
2017/05/08 22:08:01
Is the motivation for introducing the wrapper here
pwnall
2017/05/11 23:54:25
Yes. I wanted to pull out all the serialization co
|
| + exception_state); |
| if (exception_state.HadException()) |
| return nullptr; |
| @@ -408,9 +405,8 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| // value. |
| if (put_mode == kWebIDBPutModeCursorUpdate && uses_in_line_keys) { |
| DCHECK(key); |
| - if (clone.IsEmpty()) |
| - clone = DeserializeScriptValue(script_state, serialized_value.Get(), |
| - &blob_info); |
| + DCHECK(clone.IsEmpty()); |
| + value_wrapper.Clone(script_state, &clone); |
| IDBKey* key_path_key = ScriptValue::To<IDBKey*>( |
| script_state->GetIsolate(), clone, exception_state, key_path); |
| if (exception_state.HadException()) |
| @@ -433,10 +429,8 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| return nullptr; |
| } |
| if (uses_in_line_keys) { |
| - if (clone.IsEmpty()) { |
| - clone = DeserializeScriptValue(script_state, serialized_value.Get(), |
| - &blob_info); |
| - } |
| + if (clone.IsEmpty()) |
| + value_wrapper.Clone(script_state, &clone); |
| IDBKey* key_path_key = ScriptValue::To<IDBKey*>( |
| script_state->GetIsolate(), clone, exception_state, key_path); |
| if (exception_state.HadException()) |
| @@ -490,10 +484,8 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| Vector<int64_t> index_ids; |
| HeapVector<IndexKeys> index_keys; |
| for (const auto& it : Metadata().indexes) { |
| - if (clone.IsEmpty()) { |
| - clone = DeserializeScriptValue(script_state, serialized_value.Get(), |
| - &blob_info); |
| - } |
| + if (clone.IsEmpty()) |
| + value_wrapper.Clone(script_state, &clone); |
| IndexKeys keys; |
| GenerateIndexKeysForValue(script_state->GetIsolate(), *it.value, clone, |
| &keys); |
| @@ -503,16 +495,16 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state, |
| IDBRequest* request = |
| IDBRequest::Create(script_state, source, transaction_.Get()); |
| - Vector<char> wire_bytes; |
| - serialized_value->ToWireBytes(wire_bytes); |
| - RefPtr<SharedBuffer> value_buffer = SharedBuffer::AdoptVector(wire_bytes); |
| - request->StorePutOperationBlobs(serialized_value->BlobDataHandles()); |
| + request->ExtractOutgoingBlobHandlesFrom(&value_wrapper); |
| + value_wrapper.WrapIfBiggerThan(IDBValueWrapper::kWrapThreshold); |
| + |
| + BackendDB()->Put( |
| + transaction_->Id(), Id(), WebData(value_wrapper.ExtractWireBytes()), |
| + value_wrapper.WrappedBlobInfo(), key, |
| + static_cast<WebIDBPutMode>(put_mode), |
| + request->CreateWebCallbacks().release(), index_ids, index_keys); |
| - BackendDB()->Put(transaction_->Id(), Id(), WebData(value_buffer), blob_info, |
| - key, static_cast<WebIDBPutMode>(put_mode), |
| - request->CreateWebCallbacks().release(), index_ids, |
| - index_keys); |
| return request; |
| } |