Commit b6ed97d9 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Get rid of unneeded BlobDataHandle vector from IDBValue.

The WebBlobInfo instances already contain all the BlobDataHandles, so
no reason to store both.

Bug: none
Change-Id: I308c790040af3cd7efea9fdd20520a4ded05a797
Reviewed-on: https://chromium-review.googlesource.com/884374
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532187}
parent f9e10f5f
...@@ -26,9 +26,8 @@ std::unique_ptr<IDBValue> CreateNullIDBValueForTesting(v8::Isolate* isolate) { ...@@ -26,9 +26,8 @@ std::unique_ptr<IDBValue> CreateNullIDBValueForTesting(v8::Isolate* isolate) {
scoped_refptr<SharedBuffer> idb_value_buffer = SharedBuffer::Create(); scoped_refptr<SharedBuffer> idb_value_buffer = SharedBuffer::Create();
idb_value_buffer->Append(reinterpret_cast<const char*>(ssv_wire_bytes.data()), idb_value_buffer->Append(reinterpret_cast<const char*>(ssv_wire_bytes.data()),
ssv_wire_bytes.length()); ssv_wire_bytes.length());
std::unique_ptr<IDBValue> idb_value = IDBValue::Create( std::unique_ptr<IDBValue> idb_value =
std::move(idb_value_buffer), Vector<scoped_refptr<BlobDataHandle>>(), IDBValue::Create(std::move(idb_value_buffer), Vector<WebBlobInfo>());
Vector<WebBlobInfo>());
idb_value->SetInjectedPrimaryKey(IDBKey::CreateNumber(42.0), idb_value->SetInjectedPrimaryKey(IDBKey::CreateNumber(42.0),
IDBKeyPath(String("primaryKey"))); IDBKeyPath(String("primaryKey")));
idb_value->SetIsolate(isolate); idb_value->SetIsolate(isolate);
...@@ -55,8 +54,7 @@ std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate* isolate, ...@@ -55,8 +54,7 @@ std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate* isolate,
scoped_refptr<SharedBuffer> wrapped_marker_buffer = wrapper.TakeWireBytes(); scoped_refptr<SharedBuffer> wrapped_marker_buffer = wrapper.TakeWireBytes();
std::unique_ptr<IDBValue> idb_value = std::unique_ptr<IDBValue> idb_value =
IDBValue::Create(std::move(wrapped_marker_buffer), IDBValue::Create(std::move(wrapped_marker_buffer), std::move(blob_infos));
std::move(blob_data_handles), std::move(blob_infos));
idb_value->SetInjectedPrimaryKey(IDBKey::CreateNumber(42.0), idb_value->SetInjectedPrimaryKey(IDBKey::CreateNumber(42.0),
IDBKeyPath(String("primaryKey"))); IDBKeyPath(String("primaryKey")));
idb_value->SetIsolate(isolate); idb_value->SetIsolate(isolate);
......
...@@ -21,21 +21,16 @@ IDBValue::IDBValue(const WebData& data, ...@@ -21,21 +21,16 @@ IDBValue::IDBValue(const WebData& data,
const WebVector<WebBlobInfo>& web_blob_info) const WebVector<WebBlobInfo>& web_blob_info)
: data_(data) { : data_(data) {
blob_info_.ReserveInitialCapacity(web_blob_info.size()); blob_info_.ReserveInitialCapacity(web_blob_info.size());
blob_data_.ReserveInitialCapacity(web_blob_info.size());
for (const WebBlobInfo& info : web_blob_info) { for (const WebBlobInfo& info : web_blob_info) {
blob_info_.push_back(info); blob_info_.push_back(info);
blob_data_.push_back(info.GetBlobHandle());
} }
} }
IDBValue::IDBValue(scoped_refptr<SharedBuffer> unwrapped_data, IDBValue::IDBValue(scoped_refptr<SharedBuffer> unwrapped_data,
Vector<scoped_refptr<BlobDataHandle>> blob_data,
Vector<WebBlobInfo> blob_info) Vector<WebBlobInfo> blob_info)
: data_(std::move(unwrapped_data)), : data_(std::move(unwrapped_data)),
blob_data_(std::move(blob_data)),
blob_info_(std::move(blob_info)) { blob_info_(std::move(blob_info)) {
DCHECK_EQ(blob_data_.size(), blob_info_.size());
} }
IDBValue::~IDBValue() { IDBValue::~IDBValue() {
...@@ -57,10 +52,9 @@ std::unique_ptr<IDBValue> IDBValue::Create( ...@@ -57,10 +52,9 @@ std::unique_ptr<IDBValue> IDBValue::Create(
std::unique_ptr<IDBValue> IDBValue::Create( std::unique_ptr<IDBValue> IDBValue::Create(
scoped_refptr<SharedBuffer> unwrapped_data, scoped_refptr<SharedBuffer> unwrapped_data,
Vector<scoped_refptr<BlobDataHandle>> blob_data,
Vector<WebBlobInfo> blob_info) { Vector<WebBlobInfo> blob_info) {
return base::WrapUnique(new IDBValue( return base::WrapUnique(
std::move(unwrapped_data), std::move(blob_data), std::move(blob_info))); new IDBValue(std::move(unwrapped_data), std::move(blob_info)));
} }
scoped_refptr<SerializedScriptValue> IDBValue::CreateSerializedValue() const { scoped_refptr<SerializedScriptValue> IDBValue::CreateSerializedValue() const {
...@@ -103,9 +97,9 @@ scoped_refptr<BlobDataHandle> IDBValue::TakeLastBlob() { ...@@ -103,9 +97,9 @@ scoped_refptr<BlobDataHandle> IDBValue::TakeLastBlob() {
DCHECK_GT(blob_info_.size(), 0U) DCHECK_GT(blob_info_.size(), 0U)
<< "The IDBValue does not have any attached Blob"; << "The IDBValue does not have any attached Blob";
scoped_refptr<BlobDataHandle> return_value =
blob_info_.back().GetBlobHandle();
blob_info_.pop_back(); blob_info_.pop_back();
scoped_refptr<BlobDataHandle> return_value = std::move(blob_data_.back());
blob_data_.pop_back();
return return_value; return return_value;
} }
......
...@@ -45,7 +45,6 @@ class MODULES_EXPORT IDBValue final { ...@@ -45,7 +45,6 @@ class MODULES_EXPORT IDBValue final {
// Used by IDBValueUnwrapper tests. // Used by IDBValueUnwrapper tests.
static std::unique_ptr<IDBValue> Create( static std::unique_ptr<IDBValue> Create(
scoped_refptr<SharedBuffer> unwrapped_data, scoped_refptr<SharedBuffer> unwrapped_data,
Vector<scoped_refptr<BlobDataHandle>>,
Vector<WebBlobInfo>); Vector<WebBlobInfo>);
~IDBValue(); ~IDBValue();
...@@ -97,14 +96,12 @@ class MODULES_EXPORT IDBValue final { ...@@ -97,14 +96,12 @@ class MODULES_EXPORT IDBValue final {
IDBValue(const WebData&, const WebVector<WebBlobInfo>&); IDBValue(const WebData&, const WebVector<WebBlobInfo>&);
IDBValue(scoped_refptr<SharedBuffer> unwrapped_data, IDBValue(scoped_refptr<SharedBuffer> unwrapped_data,
Vector<scoped_refptr<BlobDataHandle>>,
Vector<WebBlobInfo>); Vector<WebBlobInfo>);
// Keep this private to prevent new refs because we manually bookkeep the // Keep this private to prevent new refs because we manually bookkeep the
// memory to V8. // memory to V8.
scoped_refptr<SharedBuffer> data_; scoped_refptr<SharedBuffer> data_;
Vector<scoped_refptr<BlobDataHandle>> blob_data_;
Vector<WebBlobInfo> blob_info_; Vector<WebBlobInfo> blob_info_;
std::unique_ptr<IDBKey> primary_key_; std::unique_ptr<IDBKey> primary_key_;
......
...@@ -241,11 +241,11 @@ bool IDBValueUnwrapper::Parse(IDBValue* value) { ...@@ -241,11 +241,11 @@ bool IDBValueUnwrapper::Parse(IDBValue* value) {
if (!ReadVarInt(blob_offset)) if (!ReadVarInt(blob_offset))
return Reset(); return Reset();
size_t value_blob_count = value->blob_data_.size(); size_t value_blob_count = value->blob_info_.size();
if (!value_blob_count || blob_offset != value_blob_count - 1) if (!value_blob_count || blob_offset != value_blob_count - 1)
return Reset(); return Reset();
blob_handle_ = value->blob_data_.back(); blob_handle_ = value->blob_info_.back().GetBlobHandle();
if (blob_handle_->size() != blob_size_) if (blob_handle_->size() != blob_size_)
return Reset(); return Reset();
......
...@@ -484,7 +484,7 @@ TEST(IDBValueUnwrapperTest, IsWrapped) { ...@@ -484,7 +484,7 @@ TEST(IDBValueUnwrapperTest, IsWrapped) {
IDBKeyPath key_path(String("primaryKey")); IDBKeyPath key_path(String("primaryKey"));
std::unique_ptr<IDBValue> wrapped_value = std::unique_ptr<IDBValue> wrapped_value =
IDBValue::Create(wrapped_marker_buffer, blob_data_handles, blob_infos); IDBValue::Create(wrapped_marker_buffer, blob_infos);
wrapped_value->SetIsolate(scope.GetIsolate()); wrapped_value->SetIsolate(scope.GetIsolate());
EXPECT_TRUE(IDBValueUnwrapper::IsWrapped(wrapped_value.get())); EXPECT_TRUE(IDBValueUnwrapper::IsWrapped(wrapped_value.get()));
...@@ -497,9 +497,8 @@ TEST(IDBValueUnwrapperTest, IsWrapped) { ...@@ -497,9 +497,8 @@ TEST(IDBValueUnwrapperTest, IsWrapped) {
// return false. // return false.
ASSERT_LT(3U, wrapped_marker_bytes.size()); ASSERT_LT(3U, wrapped_marker_bytes.size());
for (size_t i = 0; i < 3; ++i) { for (size_t i = 0; i < 3; ++i) {
std::unique_ptr<IDBValue> mutant_value = std::unique_ptr<IDBValue> mutant_value = IDBValue::Create(
IDBValue::Create(SharedBuffer::Create(wrapped_marker_bytes.data(), i), SharedBuffer::Create(wrapped_marker_bytes.data(), i), blob_infos);
blob_data_handles, blob_infos);
mutant_value->SetIsolate(scope.GetIsolate()); mutant_value->SetIsolate(scope.GetIsolate());
EXPECT_FALSE(IDBValueUnwrapper::IsWrapped(mutant_value.get())); EXPECT_FALSE(IDBValueUnwrapper::IsWrapped(mutant_value.get()));
...@@ -515,7 +514,7 @@ TEST(IDBValueUnwrapperTest, IsWrapped) { ...@@ -515,7 +514,7 @@ TEST(IDBValueUnwrapperTest, IsWrapped) {
std::unique_ptr<IDBValue> mutant_value = std::unique_ptr<IDBValue> mutant_value =
IDBValue::Create(SharedBuffer::Create(wrapped_marker_bytes.data(), IDBValue::Create(SharedBuffer::Create(wrapped_marker_bytes.data(),
wrapped_marker_bytes.size()), wrapped_marker_bytes.size()),
blob_data_handles, blob_infos); blob_infos);
mutant_value->SetIsolate(scope.GetIsolate()); mutant_value->SetIsolate(scope.GetIsolate());
EXPECT_FALSE(IDBValueUnwrapper::IsWrapped(mutant_value.get())); EXPECT_FALSE(IDBValueUnwrapper::IsWrapped(mutant_value.get()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment