Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBValue.cpp

Issue 2822453003: Wrap large IndexedDB values into Blobs before writing to LevelDB. (Closed)
Patch Set: Fixed Windows compilation. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/indexeddb/IDBValue.h" 5 #include "modules/indexeddb/IDBValue.h"
6 6
7 #include "bindings/core/v8/serialization/SerializedScriptValue.h" 7 #include "bindings/core/v8/serialization/SerializedScriptValue.h"
8 #include "platform/blob/BlobData.h" 8 #include "platform/blob/BlobData.h"
9 #include "platform/wtf/PtrUtil.h" 9 #include "platform/wtf/PtrUtil.h"
10 #include "public/platform/WebBlobInfo.h" 10 #include "public/platform/WebBlobInfo.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 WTF::WrapUnique(new Vector<WebBlobInfo>(value->blob_info_->size()))), 53 WTF::WrapUnique(new Vector<WebBlobInfo>(value->blob_info_->size()))),
54 primary_key_(primary_key), 54 primary_key_(primary_key),
55 key_path_(key_path) { 55 key_path_(key_path) {
56 for (size_t i = 0; i < value->blob_info_->size(); ++i) { 56 for (size_t i = 0; i < value->blob_info_->size(); ++i) {
57 const WebBlobInfo& info = (*blob_info_)[i] = value->blob_info_->at(i); 57 const WebBlobInfo& info = (*blob_info_)[i] = value->blob_info_->at(i);
58 blob_data_->push_back( 58 blob_data_->push_back(
59 BlobDataHandle::Create(info.Uuid(), info.GetType(), info.size())); 59 BlobDataHandle::Create(info.Uuid(), info.GetType(), info.size()));
60 } 60 }
61 } 61 }
62 62
63 IDBValue::IDBValue(PassRefPtr<SharedBuffer> unwrapped_data,
64 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data,
65 std::unique_ptr<Vector<WebBlobInfo>> blob_info)
66 : data_(std::move(unwrapped_data)),
67 blob_data_(std::move(blob_data)),
68 blob_info_(std::move(blob_info)) {}
69
63 IDBValue::~IDBValue() { 70 IDBValue::~IDBValue() {
64 if (isolate_) 71 if (isolate_)
65 isolate_->AdjustAmountOfExternalAllocatedMemory(-external_allocated_size_); 72 isolate_->AdjustAmountOfExternalAllocatedMemory(-external_allocated_size_);
66 } 73 }
67 74
68 PassRefPtr<IDBValue> IDBValue::Create() { 75 PassRefPtr<IDBValue> IDBValue::Create() {
69 return AdoptRef(new IDBValue()); 76 return AdoptRef(new IDBValue());
70 } 77 }
71 78
72 PassRefPtr<IDBValue> IDBValue::Create(const WebIDBValue& value, 79 PassRefPtr<IDBValue> IDBValue::Create(const WebIDBValue& value,
73 v8::Isolate* isolate) { 80 v8::Isolate* isolate) {
74 return AdoptRef(new IDBValue(value, isolate)); 81 return AdoptRef(new IDBValue(value, isolate));
75 } 82 }
76 83
77 PassRefPtr<IDBValue> IDBValue::Create(const IDBValue* value, 84 PassRefPtr<IDBValue> IDBValue::Create(const IDBValue* value,
78 IDBKey* primary_key, 85 IDBKey* primary_key,
79 const IDBKeyPath& key_path) { 86 const IDBKeyPath& key_path) {
80 return AdoptRef(new IDBValue(value, primary_key, key_path)); 87 return AdoptRef(new IDBValue(value, primary_key, key_path));
81 } 88 }
82 89
90 PassRefPtr<IDBValue> IDBValue::Create(
91 PassRefPtr<SharedBuffer> unwrapped_data,
92 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data,
dcheng 2017/05/25 18:34:04 No need to fix in this CL, but: 1. Isn't Vector mo
pwnall 2017/05/25 20:01:10 Acknowledged. I will look to fix both of these in
93 std::unique_ptr<Vector<WebBlobInfo>> blob_info) {
94 return AdoptRef(new IDBValue(std::move(unwrapped_data), std::move(blob_data),
95 std::move(blob_info)));
96 }
97
83 Vector<String> IDBValue::GetUUIDs() const { 98 Vector<String> IDBValue::GetUUIDs() const {
84 Vector<String> uuids; 99 Vector<String> uuids;
85 uuids.ReserveCapacity(blob_info_->size()); 100 uuids.ReserveCapacity(blob_info_->size());
86 for (const auto& info : *blob_info_) 101 for (const auto& info : *blob_info_)
87 uuids.push_back(info.Uuid()); 102 uuids.push_back(info.Uuid());
88 return uuids; 103 return uuids;
89 } 104 }
90 105
91 RefPtr<SerializedScriptValue> IDBValue::CreateSerializedValue() const { 106 RefPtr<SerializedScriptValue> IDBValue::CreateSerializedValue() const {
92 return SerializedScriptValue::Create(data_->Data(), data_->size()); 107 return SerializedScriptValue::Create(data_->Data(), data_->size());
93 } 108 }
94 109
95 bool IDBValue::IsNull() const { 110 bool IDBValue::IsNull() const {
96 return !data_.Get(); 111 return !data_.Get();
97 } 112 }
98 113
99 } // namespace blink 114 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698