Commit 5adc578c authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Cleanup deprecated and unused WebBlobInfo constructors.

Also remove last usage of these deprecated constructors (mostly in tests,
where just passing a dangling mojo message pipe works fine).

Bug: 769024
Change-Id: I38b390e64552abc971035eec97d090a85ec701f9
Reviewed-on: https://chromium-review.googlesource.com/883570Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532147}
parent e8a67f41
...@@ -183,8 +183,8 @@ TEST_F(WebIDBCursorImplTest, PrefetchTest) { ...@@ -183,8 +183,8 @@ TEST_F(WebIDBCursorImplTest, PrefetchTest) {
WebVector<WebBlobInfo> blob_info; WebVector<WebBlobInfo> blob_info;
blob_info.reserve(expected_key + i); blob_info.reserve(expected_key + i);
for (int j = 0; j < expected_key + i; ++j) { for (int j = 0; j < expected_key + i; ++j) {
blob_info.emplace_back(WebString::FromLatin1(base::GenerateGUID()), blob_info.emplace_back(WebBlobInfo::BlobForTesting(
"text/plain", 123); WebString::FromLatin1(base::GenerateGUID()), "text/plain", 123));
} }
values.emplace_back(WebData(), std::move(blob_info)); values.emplace_back(WebData(), std::move(blob_info));
} }
...@@ -249,8 +249,8 @@ TEST_F(WebIDBCursorImplTest, AdvancePrefetchTest) { ...@@ -249,8 +249,8 @@ TEST_F(WebIDBCursorImplTest, AdvancePrefetchTest) {
WebVector<WebBlobInfo> blob_info; WebVector<WebBlobInfo> blob_info;
blob_info.reserve(expected_key + i); blob_info.reserve(expected_key + i);
for (int j = 0; j < expected_key + i; ++j) { for (int j = 0; j < expected_key + i; ++j) {
blob_info.emplace_back(WebString::FromLatin1(base::GenerateGUID()), blob_info.emplace_back(WebBlobInfo::BlobForTesting(
"text/plain", 123); WebString::FromLatin1(base::GenerateGUID()), "text/plain", 123));
} }
values.emplace_back(WebData(), std::move(blob_info)); values.emplace_back(WebData(), std::move(blob_info));
} }
......
...@@ -44,10 +44,11 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) { ...@@ -44,10 +44,11 @@ int LLVMFuzzerInitialize(int* argc, char*** argv) {
g_page_holder = DummyPageHolder::Create().release(); g_page_holder = DummyPageHolder::Create().release();
g_page_holder->GetFrame().GetSettings()->SetScriptEnabled(true); g_page_holder->GetFrame().GetSettings()->SetScriptEnabled(true);
g_blob_info_array = new WebBlobInfoArray(); g_blob_info_array = new WebBlobInfoArray();
g_blob_info_array->emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", g_blob_info_array->emplace_back(WebBlobInfo::BlobForTesting(
"text/plain", 12); "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12));
g_blob_info_array->emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", g_blob_info_array->emplace_back(
"/native/path", "path", "text/plain"); WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "path", "text/plain"));
return 0; return 0;
} }
......
...@@ -1337,8 +1337,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndex) { ...@@ -1337,8 +1337,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndex) {
scoped_refptr<SerializedScriptValue> input = scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x69, 0x00}); SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x69, 0x00});
WebBlobInfoArray blob_info_array; WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", blob_info_array.emplace_back(WebBlobInfo::BlobForTesting(
"text/plain", 12); "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12));
V8ScriptValueDeserializer::Options options; V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array; options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
...@@ -1361,8 +1361,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndexOutOfRange) { ...@@ -1361,8 +1361,8 @@ TEST(V8ScriptValueSerializerTest, DecodeBlobIndexOutOfRange) {
} }
{ {
WebBlobInfoArray blob_info_array; WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", blob_info_array.emplace_back(WebBlobInfo::BlobForTesting(
"text/plain", 12); "d875dfc2-4505-461b-98fe-0cf6cc5eaf44", "text/plain", 12));
V8ScriptValueDeserializer::Options options; V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array; options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
...@@ -1596,8 +1596,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndex) { ...@@ -1596,8 +1596,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndex) {
scoped_refptr<SerializedScriptValue> input = scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x65, 0x00}); SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x65, 0x00});
WebBlobInfoArray blob_info_array; WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", blob_info_array.emplace_back(
"/native/path", "path", "text/plain"); WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "path", "text/plain"));
V8ScriptValueDeserializer::Options options; V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array; options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
...@@ -1621,8 +1622,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndexOutOfRange) { ...@@ -1621,8 +1622,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileIndexOutOfRange) {
} }
{ {
WebBlobInfoArray blob_info_array; WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", blob_info_array.emplace_back(
"/native/path", "path", "text/plain"); WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "path", "text/plain"));
V8ScriptValueDeserializer::Options options; V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array; options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
...@@ -1753,8 +1755,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileListIndex) { ...@@ -1753,8 +1755,9 @@ TEST(V8ScriptValueSerializerTest, DecodeFileListIndex) {
scoped_refptr<SerializedScriptValue> input = scoped_refptr<SerializedScriptValue> input =
SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x01, 0x00, 0x00}); SerializedValue({0xff, 0x09, 0x3f, 0x00, 0x4c, 0x01, 0x00, 0x00});
WebBlobInfoArray blob_info_array; WebBlobInfoArray blob_info_array;
blob_info_array.emplace_back("d875dfc2-4505-461b-98fe-0cf6cc5eaf44", blob_info_array.emplace_back(
"/native/path", "name", "text/plain"); WebBlobInfo::FileForTesting("d875dfc2-4505-461b-98fe-0cf6cc5eaf44",
"/native/path", "name", "text/plain"));
V8ScriptValueDeserializer::Options options; V8ScriptValueDeserializer::Options options;
options.blob_info = &blob_info_array; options.blob_info = &blob_info_array;
V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input, V8ScriptValueDeserializer deserializer(scope.GetScriptState(), input,
......
...@@ -147,8 +147,7 @@ bool IDBValueWrapper::WrapIfBiggerThan(unsigned max_bytes) { ...@@ -147,8 +147,7 @@ bool IDBValueWrapper::WrapIfBiggerThan(unsigned max_bytes) {
wrapper_blob_data->AppendBytes(wire_data_.data(), wire_data_size); wrapper_blob_data->AppendBytes(wire_data_.data(), wire_data_size);
scoped_refptr<BlobDataHandle> wrapper_handle = scoped_refptr<BlobDataHandle> wrapper_handle =
BlobDataHandle::Create(std::move(wrapper_blob_data), wire_data_size); BlobDataHandle::Create(std::move(wrapper_blob_data), wire_data_size);
blob_info_.emplace_back(wrapper_handle->Uuid(), wrapper_handle->GetType(), blob_info_.emplace_back(wrapper_handle);
wire_data_size);
blob_handles_.push_back(std::move(wrapper_handle)); blob_handles_.push_back(std::move(wrapper_handle));
wire_data_buffer_.clear(); wire_data_buffer_.clear();
......
...@@ -36,6 +36,22 @@ WebBlobInfo::WebBlobInfo(const WebString& uuid, ...@@ -36,6 +36,22 @@ WebBlobInfo::WebBlobInfo(const WebString& uuid,
file_name, file_name,
last_modified) {} last_modified) {}
// static
WebBlobInfo WebBlobInfo::BlobForTesting(const WebString& uuid,
const WebString& type,
long long size) {
return WebBlobInfo(uuid, type, size, mojo::MessagePipe().handle0);
}
// static
WebBlobInfo WebBlobInfo::FileForTesting(const WebString& uuid,
const WebString& file_path,
const WebString& file_name,
const WebString& type) {
return WebBlobInfo(uuid, file_path, file_name, type, 0, -1,
mojo::MessagePipe().handle0);
}
WebBlobInfo::~WebBlobInfo() { WebBlobInfo::~WebBlobInfo() {
blob_handle_.Reset(); blob_handle_.Reset();
} }
......
...@@ -17,38 +17,6 @@ class BlobDataHandle; ...@@ -17,38 +17,6 @@ class BlobDataHandle;
class WebBlobInfo { class WebBlobInfo {
public: public:
WebBlobInfo() : is_file_(false), size_(-1), last_modified_(0) {} WebBlobInfo() : is_file_(false), size_(-1), last_modified_(0) {}
// TODO(mek): Eliminate constructors that don't accept a message pipe.
WebBlobInfo(const WebString& uuid, const WebString& type, long long size)
: is_file_(false),
uuid_(uuid),
type_(type),
size_(size),
last_modified_(0) {}
WebBlobInfo(const WebString& uuid,
const WebString& file_path,
const WebString& file_name,
const WebString& type)
: is_file_(true),
uuid_(uuid),
type_(type),
size_(-1),
file_path_(file_path),
file_name_(file_name),
last_modified_(0) {}
WebBlobInfo(const WebString& uuid,
const WebString& file_path,
const WebString& file_name,
const WebString& type,
double last_modified,
long long size)
: is_file_(true),
uuid_(uuid),
type_(type),
size_(size),
file_path_(file_path),
file_name_(file_name),
last_modified_(last_modified) {}
BLINK_EXPORT WebBlobInfo(const WebString& uuid, BLINK_EXPORT WebBlobInfo(const WebString& uuid,
const WebString& type, const WebString& type,
long long size, long long size,
...@@ -61,6 +29,18 @@ class WebBlobInfo { ...@@ -61,6 +29,18 @@ class WebBlobInfo {
long long size, long long size,
mojo::ScopedMessagePipeHandle); mojo::ScopedMessagePipeHandle);
// For testing purposes, these two methods create a WebBlobInfo connected to a
// dangling mojo message pipe. This means that any operations that actually
// depend on the mojo connection to exist will fail, but otherwise you should
// be able to safely pass around these blobs.
BLINK_EXPORT static WebBlobInfo BlobForTesting(const WebString& uuid,
const WebString& type,
long long size);
BLINK_EXPORT static WebBlobInfo FileForTesting(const WebString& uuid,
const WebString& file_path,
const WebString& file_name,
const WebString& type);
BLINK_EXPORT ~WebBlobInfo(); BLINK_EXPORT ~WebBlobInfo();
BLINK_EXPORT WebBlobInfo(const WebBlobInfo& other); BLINK_EXPORT WebBlobInfo(const WebBlobInfo& other);
......
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