Commit fe7f9100 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

IndexedDB: Remove default constructor from IDBValue.

The default constructor is only used in tests, for convenience. It is
not obvious what the semantics should be for such a constructor.

This CL removes the default constructor and introduces a test helper that
creates IDBValue instances.

Bug: 
Change-Id: If8b2cada03afe8cd3ffa58cc6ab711d96b96f013
Reviewed-on: https://chromium-review.googlesource.com/828694
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524501}
parent 1f808902
...@@ -108,13 +108,14 @@ void EnsureIDBCallbacksDontThrow(IDBRequest* request, ...@@ -108,13 +108,14 @@ void EnsureIDBCallbacksDontThrow(IDBRequest* request,
request->HandleResponse( request->HandleResponse(
DOMException::Create(kAbortError, "Description goes here.")); DOMException::Create(kAbortError, "Description goes here."));
request->HandleResponse(nullptr, IDBKey::CreateInvalid(), request->HandleResponse(nullptr, IDBKey::CreateInvalid(),
IDBKey::CreateInvalid(), IDBValue::Create()); IDBKey::CreateInvalid(),
CreateNullIDBValueForTesting());
request->HandleResponse(IDBKey::CreateInvalid()); request->HandleResponse(IDBKey::CreateInvalid());
request->HandleResponse(IDBValue::Create()); request->HandleResponse(CreateNullIDBValueForTesting());
request->HandleResponse(static_cast<int64_t>(0)); request->HandleResponse(static_cast<int64_t>(0));
request->HandleResponse(); request->HandleResponse();
request->HandleResponse(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(), request->HandleResponse(IDBKey::CreateInvalid(), IDBKey::CreateInvalid(),
IDBValue::Create()); CreateNullIDBValueForTesting());
request->EnqueueResponse(Vector<String>()); request->EnqueueResponse(Vector<String>());
EXPECT_TRUE(!exception_state.HadException()); EXPECT_TRUE(!exception_state.HadException());
......
...@@ -17,6 +17,23 @@ ...@@ -17,6 +17,23 @@
namespace blink { namespace blink {
std::unique_ptr<IDBValue> CreateNullIDBValueForTesting() {
scoped_refptr<SerializedScriptValue> null_ssv =
SerializedScriptValue::NullValue();
StringView ssv_wire_bytes = null_ssv->GetWireData();
DCHECK(ssv_wire_bytes.Is8Bit());
scoped_refptr<SharedBuffer> idb_value_buffer = SharedBuffer::Create();
idb_value_buffer->Append(
reinterpret_cast<const char*>(ssv_wire_bytes.Characters8()),
ssv_wire_bytes.length());
return IDBValue::Create(std::move(idb_value_buffer),
Vector<scoped_refptr<BlobDataHandle>>(),
Vector<WebBlobInfo>(), IDBKey::CreateNumber(42.0),
IDBKeyPath(String("primaryKey")));
}
std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate* isolate, std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate* isolate,
bool create_wrapped_value) { bool create_wrapped_value) {
size_t element_count = create_wrapped_value ? 16 : 2; size_t element_count = create_wrapped_value ? 16 : 2;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
namespace blink { namespace blink {
std::unique_ptr<IDBValue> CreateNullIDBValueForTesting();
// The created value is an array of true. If create_wrapped_value is true, the // The created value is an array of true. If create_wrapped_value is true, the
// IDBValue's byte array will be wrapped in a Blob, otherwise it will not be. // IDBValue's byte array will be wrapped in a Blob, otherwise it will not be.
std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate*, std::unique_ptr<IDBValue> CreateIDBValueForTesting(v8::Isolate*,
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
namespace blink { namespace blink {
IDBValue::IDBValue() = default;
IDBValue::IDBValue(const WebIDBValue& value, v8::Isolate* isolate) IDBValue::IDBValue(const WebIDBValue& value, v8::Isolate* isolate)
: IDBValue(value.data, : IDBValue(value.data,
value.web_blob_info, value.web_blob_info,
...@@ -72,10 +70,6 @@ IDBValue::~IDBValue() { ...@@ -72,10 +70,6 @@ IDBValue::~IDBValue() {
isolate_->AdjustAmountOfExternalAllocatedMemory(-external_allocated_size_); isolate_->AdjustAmountOfExternalAllocatedMemory(-external_allocated_size_);
} }
std::unique_ptr<IDBValue> IDBValue::Create() {
return WTF::WrapUnique(new IDBValue());
}
std::unique_ptr<IDBValue> IDBValue::Create(const WebIDBValue& value, std::unique_ptr<IDBValue> IDBValue::Create(const WebIDBValue& value,
v8::Isolate* isolate) { v8::Isolate* isolate) {
return WTF::WrapUnique(new IDBValue(value, isolate)); return WTF::WrapUnique(new IDBValue(value, isolate));
......
...@@ -24,7 +24,6 @@ struct WebIDBValue; ...@@ -24,7 +24,6 @@ struct WebIDBValue;
class MODULES_EXPORT IDBValue final { class MODULES_EXPORT IDBValue final {
public: public:
static std::unique_ptr<IDBValue> Create();
static std::unique_ptr<IDBValue> Create(const WebIDBValue&, v8::Isolate*); static std::unique_ptr<IDBValue> Create(const WebIDBValue&, v8::Isolate*);
// Injects a primary key into a value coming from the backend. // Injects a primary key into a value coming from the backend.
...@@ -61,7 +60,6 @@ class MODULES_EXPORT IDBValue final { ...@@ -61,7 +60,6 @@ class MODULES_EXPORT IDBValue final {
friend class IDBValueUnwrapper; friend class IDBValueUnwrapper;
IDBValue();
IDBValue(const WebIDBValue&, v8::Isolate*); IDBValue(const WebIDBValue&, v8::Isolate*);
IDBValue(scoped_refptr<SharedBuffer>, IDBValue(scoped_refptr<SharedBuffer>,
const WebVector<WebBlobInfo>&, const WebVector<WebBlobInfo>&,
......
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