0

Remove DataElementType::kBlob

It's no longer being used.

Fixed: 846167
Change-Id: I3636e12cdab07188c90199329826de4ef18432f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444430
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813901}
This commit is contained in:
Matt Menke
2020-10-05 20:47:04 +00:00
committed by Commit Bot
parent 89f2e556fd
commit 353144938b
23 changed files with 44 additions and 179 deletions

@ -78,7 +78,6 @@ class BlobURLTest : public testing::Test {
BlobURLTest()
: task_environment_(BrowserTaskEnvironment::IO_MAINLOOP),
blob_data_(new BlobDataBuilder("uuid")),
blob_uuid_(blob_data_->uuid()),
response_error_code_(net::OK),
expected_error_code_(net::OK),
expected_status_code_(0) {}
@ -309,7 +308,6 @@ class BlobURLTest : public testing::Test {
storage::BlobUrlRegistry blob_url_registry_;
std::unique_ptr<storage::BlobDataHandle> blob_handle_;
std::unique_ptr<BlobDataBuilder> blob_data_;
std::string blob_uuid_;
std::unique_ptr<BlobDataSnapshot> blob_data_snapshot_;
std::string response_;
int response_error_code_;

@ -1289,11 +1289,6 @@ bool ChildProcessSecurityPolicyImpl::CanReadRequestBody(
// Data is self-contained within |body| - no need to check access.
break;
case network::mojom::DataElementType::kBlob:
// No need to validate - the unguessability of the uuid of the blob is a
// sufficient defense against access from an unrelated renderer.
break;
case network::mojom::DataElementType::kDataPipe:
// Data is self-contained within |body| - no need to check access.
break;

@ -54,12 +54,6 @@ void AppendFileRangeToRequestBody(
file_modification_time);
}
void AppendBlobToRequestBody(
const scoped_refptr<network::ResourceRequestBody>& request_body,
const std::string& uuid) {
request_body->AppendBlob(uuid);
}
//----------------------------------------------------------------------------
void AppendReferencedFilesFromHttpBody(
@ -290,10 +284,6 @@ GURL ReadGURL(SerializeObject* obj) {
return GURL();
}
void WriteStdString(const std::string& s, SerializeObject* obj) {
obj->pickle.WriteString(s);
}
std::string ReadStdString(SerializeObject* obj) {
std::string s;
if (obj->iter.ReadString(&s))
@ -416,10 +406,6 @@ void WriteResourceRequestBody(const network::ResourceRequestBody& request_body,
WriteInteger64(static_cast<int64_t>(element.length()), obj);
WriteReal(element.expected_modification_time().ToDoubleT(), obj);
break;
case network::mojom::DataElementType::kBlob:
WriteInteger(blink::WebHTTPBody::Element::kTypeBlob, obj);
WriteStdString(element.blob_uuid(), obj);
break;
default:
NOTREACHED();
continue;
@ -451,11 +437,11 @@ void ReadResourceRequestBody(
request_body, file_path, file_start, file_length,
base::Time::FromDoubleT(file_modification_time));
} else if (type == blink::WebHTTPBody::Element::kTypeBlob) {
// Skip obsolete blob values.
if (obj->version >= 16) {
std::string blob_uuid = ReadStdString(obj);
AppendBlobToRequestBody(request_body, blob_uuid);
ReadStdString(obj);
} else {
ReadGURL(obj); // Skip the obsolete blob url value.
ReadGURL(obj);
}
}
}
@ -691,9 +677,6 @@ void WriteResourceRequestBody(const network::ResourceRequestBody& request_body,
data_element->set_file(std::move(file));
break;
}
case network::mojom::DataElementType::kBlob:
data_element->set_blob_uuid(element.blob_uuid());
break;
case network::mojom::DataElementType::kDataPipe:
NOTIMPLEMENTED();
break;
@ -727,7 +710,7 @@ void ReadResourceRequestBody(
break;
}
case blink::mojom::Element::Tag::BLOB_UUID:
AppendBlobToRequestBody(request_body, element->get_blob_uuid());
// No longer supported.
break;
case blink::mojom::Element::Tag::DEPRECATED_FILE_SYSTEM_FILE:
// No longer supported.

@ -50,7 +50,6 @@ void ExpectEquality(const network::DataElement& expected,
EXPECT_EQ(expected.length(), actual.length());
EXPECT_EQ(expected.expected_modification_time(),
actual.expected_modification_time());
EXPECT_EQ(expected.blob_uuid(), actual.blob_uuid());
}
template <>
@ -686,8 +685,6 @@ TEST_F(PageStateSerializationTest, BackwardsCompat_HttpBody) {
std::string test_body("foo");
http_body.request_body->AppendBytes(test_body.data(), test_body.size());
http_body.request_body->AppendBlob("some_uuid");
base::FilePath path(FILE_PATH_LITERAL("file.txt"));
http_body.request_body->AppendFileRange(base::FilePath(path), 100, 1024,
base::Time::FromDoubleT(9999.0));

@ -137,9 +137,6 @@ WebHTTPBody GetWebHTTPBodyForRequestBody(
modification_time);
break;
}
case network::mojom::DataElementType::kBlob:
http_body.AppendBlob(WebString::FromASCII(element.blob_uuid()));
break;
case network::mojom::DataElementType::kDataPipe: {
http_body.AppendDataPipe(element.CloneDataPipeGetter());
break;

@ -40,15 +40,6 @@ void DataElement::SetToFilePathRange(
expected_modification_time_ = expected_modification_time;
}
void DataElement::SetToBlobRange(const std::string& blob_uuid,
uint64_t offset,
uint64_t length) {
type_ = mojom::DataElementType::kBlob;
blob_uuid_ = blob_uuid;
offset_ = offset;
length_ = length;
}
void DataElement::SetToDataPipe(
mojo::PendingRemote<mojom::DataPipeGetter> data_pipe_getter) {
DCHECK(data_pipe_getter);
@ -116,9 +107,6 @@ void PrintTo(const DataElement& x, std::ostream* os) {
*os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe()
<< ", expected_modification_time: " << x.expected_modification_time();
break;
case mojom::DataElementType::kBlob:
*os << "TYPE_BLOB, uuid: " << x.blob_uuid();
break;
case mojom::DataElementType::kDataPipe:
*os << "TYPE_DATA_PIPE";
break;
@ -145,8 +133,6 @@ bool operator==(const DataElement& a, const DataElement& b) {
case mojom::DataElementType::kFile:
return a.path() == b.path() &&
a.expected_modification_time() == b.expected_modification_time();
case mojom::DataElementType::kBlob:
return a.blob_uuid() == b.blob_uuid();
case mojom::DataElementType::kDataPipe:
return false;
case mojom::DataElementType::kChunkedDataPipe:

@ -35,8 +35,8 @@ class FetchAPIDataElementDataView;
namespace network {
// Represents part of an upload body. This could be either one of bytes, file or
// blob data.
// Represents part of an upload body. This could be one of raw bytes, file data,
// or a mojo pipe that streams data.
class COMPONENT_EXPORT(NETWORK_CPP_BASE) DataElement {
public:
static const uint64_t kUnknownSize = std::numeric_limits<uint64_t>::max();
@ -54,7 +54,6 @@ class COMPONENT_EXPORT(NETWORK_CPP_BASE) DataElement {
return reinterpret_cast<const char*>(buf_.data());
}
const base::FilePath& path() const { return path_; }
const std::string& blob_uuid() const { return blob_uuid_; }
uint64_t offset() const { return offset_; }
uint64_t length() const { return length_; }
const base::Time& expected_modification_time() const {
@ -94,22 +93,12 @@ class COMPONENT_EXPORT(NETWORK_CPP_BASE) DataElement {
length_ = buf_.size();
}
// Sets TYPE_BLOB data.
void SetToBlob(const std::string& uuid) {
SetToBlobRange(uuid, 0, std::numeric_limits<uint64_t>::max());
}
// Sets TYPE_FILE data with range.
void SetToFilePathRange(const base::FilePath& path,
uint64_t offset,
uint64_t length,
const base::Time& expected_modification_time);
// Sets TYPE_BLOB data with range.
void SetToBlobRange(const std::string& blob_uuid,
uint64_t offset,
uint64_t length);
// Sets TYPE_DATA_PIPE data. The data pipe consumer can safely wait for the
// callback passed to Read() to be invoked before reading the request body.
void SetToDataPipe(
@ -149,8 +138,6 @@ class COMPONENT_EXPORT(NETWORK_CPP_BASE) DataElement {
std::vector<uint8_t> buf_;
// For TYPE_FILE.
base::FilePath path_;
// For TYPE_BLOB.
std::string blob_uuid_;
// For TYPE_DATA_PIPE.
mojo::PendingRemote<mojom::DataPipeGetter> data_pipe_getter_;
// For TYPE_CHUNKED_DATA_PIPE.

@ -30,12 +30,6 @@ void ParamTraits<network::DataElement>::Write(base::Pickle* m,
WriteParam(m, p.expected_modification_time());
break;
}
case network::mojom::DataElementType::kBlob: {
WriteParam(m, p.blob_uuid());
WriteParam(m, p.offset());
WriteParam(m, p.length());
break;
}
case network::mojom::DataElementType::kDataPipe: {
WriteParam(m, p.CloneDataPipeGetter().PassPipe().release());
break;
@ -86,18 +80,6 @@ bool ParamTraits<network::DataElement>::Read(const base::Pickle* m,
expected_modification_time);
return true;
}
case network::mojom::DataElementType::kBlob: {
std::string blob_uuid;
uint64_t offset, length;
if (!ReadParam(m, iter, &blob_uuid))
return false;
if (!ReadParam(m, iter, &offset))
return false;
if (!ReadParam(m, iter, &length))
return false;
r->SetToBlobRange(blob_uuid, offset, length);
return true;
}
case network::mojom::DataElementType::kDataPipe: {
mojo::MessagePipeHandle message_pipe;
if (!ReadParam(m, iter, &message_pipe))

@ -57,17 +57,6 @@ void ResourceRequestBody::AppendFileRange(
expected_modification_time);
}
void ResourceRequestBody::AppendBlob(const std::string& uuid) {
AppendBlob(uuid, std::numeric_limits<uint64_t>::max());
}
void ResourceRequestBody::AppendBlob(const std::string& uuid, uint64_t length) {
DCHECK(EnableToAppendElement());
elements_.push_back(DataElement());
elements_.back().SetToBlobRange(uuid, 0 /* offset */, length);
}
void ResourceRequestBody::AppendDataPipe(
mojo::PendingRemote<mojom::DataPipeGetter> data_pipe_getter) {
DCHECK(EnableToAppendElement());

@ -45,19 +45,6 @@ class COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequestBody
uint64_t length,
const base::Time& expected_modification_time);
// Appends a blob. If the 2-parameter version is used, the resulting body can
// be read by Blink, which is needed when the body is sent to Blink, e.g., for
// service worker interception. The length must be size of the entire blob,
// not a subrange of it. If the length is unknown, use the 1-parameter
// version, but this means the body/blob won't be readable by Blink (that's OK
// if this ResourceRequestBody will only be sent to the browser process and
// won't be sent to Blink).
//
// TODO(crbug.com/846167): Remove these functions when NetworkService is
// enabled, as blobs are passed via AppendDataPipe in that case.
void AppendBlob(const std::string& uuid);
void AppendBlob(const std::string& uuid, uint64_t length);
void AppendDataPipe(
mojo::PendingRemote<mojom::DataPipeGetter> data_pipe_getter);

@ -266,10 +266,6 @@ bool StructTraits<network::mojom::DataElementDataView, network::DataElement>::
network::debug::SetDeserializationCrashKeyString("data_element_path");
return false;
}
if (!data.ReadBlobUuid(&out->blob_uuid_)) {
network::debug::SetDeserializationCrashKeyString("data_element_blob_uuid");
return false;
}
if (!data.ReadExpectedModificationTime(&out->expected_modification_time_)) {
return false;
}

@ -314,9 +314,6 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
static const base::FilePath& path(const network::DataElement& element) {
return element.path_;
}
static const std::string& blob_uuid(const network::DataElement& element) {
return element.blob_uuid_;
}
static mojo::PendingRemote<network::mojom::DataPipeGetter> data_pipe_getter(
const network::DataElement& element) {
if (element.type_ != network::mojom::DataElementType::kDataPipe)

@ -59,17 +59,13 @@ enum URLRequestReferrerPolicy {
enum DataElementType {
kUnknown = -1,
// Only used for Upload with Network Service as of now:
kDataPipe,
kChunkedDataPipe,
kReadOnceStream,
// Used for Upload when Network Service is disabled:
kBlob,
kFile,
// Commonly used in every case:
kBytes,
// TODO(https://crbug.com/1132362): Remove this.
kFile,
};
// Options that may only be set on URLRequests passed to a URLLoaderFactory
@ -430,9 +426,6 @@ struct DataElement {
array<uint8> buf;
// For kFile
mojo_base.mojom.FilePath path;
// For kBlob
// TODO(richard.li): Deprecate this once NetworkService is fully shipped.
string blob_uuid;
// For kDataPipe
pending_remote<network.mojom.DataPipeGetter>? data_pipe_getter;
// For kChunkedDataPipe

@ -224,10 +224,6 @@ std::unique_ptr<net::UploadDataStream> CreateUploadDataStream(
element_readers.push_back(std::make_unique<FileElementReader>(
body, file_task_runner, element, std::move(*opened_file++)));
break;
case network::mojom::DataElementType::kBlob: {
CHECK(false) << "Network service always uses DATA_PIPE for blobs.";
break;
}
case network::mojom::DataElementType::kDataPipe: {
element_readers.push_back(std::make_unique<DataPipeElementReader>(
body, element.CloneDataPipeGetter()));

@ -26,12 +26,11 @@ bool StructTraits<
blink::mojom::FetchAPIDataElementDataView,
network::DataElement>::Read(blink::mojom::FetchAPIDataElementDataView data,
network::DataElement* out) {
base::Optional<std::string> blob_uuid;
if (!data.ReadPath(&out->path_) || !data.ReadBlobUuid(&blob_uuid) ||
if (!data.ReadPath(&out->path_) ||
!data.ReadExpectedModificationTime(&out->expected_modification_time_)) {
return false;
}
out->blob_uuid_ = std::move(blob_uuid).value_or(std::string());
if (data.type() == network::mojom::DataElementType::kBytes) {
if (!data.ReadBuf(&out->buf_))
return false;

@ -61,9 +61,6 @@ struct BLINK_COMMON_EXPORT
static const base::FilePath& path(const network::DataElement& element) {
return element.path_;
}
static const std::string& blob_uuid(const network::DataElement& element) {
return element.blob_uuid_;
}
static mojo::PendingRemote<network::mojom::DataPipeGetter> data_pipe_getter(
const network::DataElement& element) {
if (element.type_ != network::mojom::DataElementType::kDataPipe)

@ -122,8 +122,6 @@ struct FetchAPIDataElement {
array<uint8> buf;
// For kFile
mojo_base.mojom.FilePath path;
// For kBlob
string? blob_uuid;
// For kDataPipe
pending_remote<network.mojom.DataPipeGetter>? data_pipe_getter;
// For kChunkedDataPipe

@ -62,7 +62,6 @@ class WebHTTPBody {
int64_t file_start;
int64_t file_length; // -1 means to the end of the file.
base::Optional<base::Time> modification_time;
WebString blob_uuid;
uint64_t blob_length;
CrossVariantMojoRemote<mojom::BlobInterfaceBase> optional_blob;
CrossVariantMojoRemote<network::mojom::DataPipeGetterInterfaceBase>

@ -73,7 +73,6 @@ bool WebHTTPBody::ElementAt(size_t index, Element& result) const {
result.file_start = 0;
result.file_length = 0;
result.modification_time = base::nullopt;
result.blob_uuid.Reset();
switch (element.type_) {
case FormDataElement::kData:
@ -89,13 +88,10 @@ bool WebHTTPBody::ElementAt(size_t index, Element& result) const {
break;
case FormDataElement::kEncodedBlob:
result.type = Element::kTypeBlob;
result.blob_uuid = element.blob_uuid_;
result.blob_length = std::numeric_limits<uint64_t>::max();
if (element.optional_blob_data_handle_) {
result.optional_blob =
element.optional_blob_data_handle_->CloneBlobRemote();
result.blob_length = element.optional_blob_data_handle_->size();
}
result.optional_blob =
element.optional_blob_data_handle_->CloneBlobRemote();
result.blob_length = element.optional_blob_data_handle_->size();
break;
case FormDataElement::kDataPipe:
result.type = Element::kTypeDataPipe;

@ -53,25 +53,19 @@ StructTraits<blink::mojom::FetchAPIRequestBodyDataView,
out->expected_modification_time =
element.expected_file_modification_time_.value_or(base::Time());
break;
case blink::FormDataElement::kEncodedBlob:
if (element.optional_blob_data_handle_) {
out->type = network::mojom::DataElementType::kDataPipe;
out->length = element.optional_blob_data_handle_->size();
case blink::FormDataElement::kEncodedBlob: {
out->type = network::mojom::DataElementType::kDataPipe;
out->length = element.optional_blob_data_handle_->size();
mojo::Remote<blink::mojom::blink::Blob> blob_remote(
mojo::PendingRemote<blink::mojom::blink::Blob>(
element.optional_blob_data_handle_->CloneBlobRemote()
.PassPipe(),
blink::mojom::blink::Blob::Version_));
mojo::PendingRemote<network::mojom::blink::DataPipeGetter>
data_pipe_getter_remote;
blob_remote->AsDataPipeGetter(
out->data_pipe_getter.InitWithNewPipeAndPassReceiver());
} else {
out->type = network::mojom::DataElementType::kBlob;
out->blob_uuid = element.blob_uuid_;
}
mojo::Remote<blink::mojom::blink::Blob> blob_remote(
mojo::PendingRemote<blink::mojom::blink::Blob>(
element.optional_blob_data_handle_->CloneBlobRemote()
.PassPipe(),
blink::mojom::blink::Blob::Version_));
blob_remote->AsDataPipeGetter(
out->data_pipe_getter.InitWithNewPipeAndPassReceiver());
break;
}
case blink::FormDataElement::kDataPipe:
out->type = network::mojom::DataElementType::kDataPipe;
if (element.data_pipe_getter_) {
@ -159,7 +153,6 @@ bool StructTraits<blink::mojom::FetchAPIRequestBodyDataView,
break;
}
case network::mojom::DataElementType::kBlob:
case network::mojom::DataElementType::kUnknown:
case network::mojom::DataElementType::kChunkedDataPipe:
case network::mojom::DataElementType::kReadOnceStream:

@ -55,7 +55,9 @@ FormDataElement::FormDataElement(const String& blob_uuid,
scoped_refptr<BlobDataHandle> optional_handle)
: type_(kEncodedBlob),
blob_uuid_(blob_uuid),
optional_blob_data_handle_(std::move(optional_handle)) {}
optional_blob_data_handle_(std::move(optional_handle)) {
DCHECK(optional_blob_data_handle_);
}
FormDataElement::FormDataElement(
scoped_refptr<WrappedDataPipeGetter> data_pipe_getter)

@ -5,16 +5,22 @@
#include <utility>
#include "base/sequenced_task_runner.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/string_traits_wtf.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/blob/blob_registry.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/blob/blob_data.h"
#include "third_party/blink/renderer/platform/network/encoded_form_data.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
using mojom::blink::BlobRegistry;
namespace {
class EncodedFormDataTest : public testing::Test {
@ -44,7 +50,13 @@ TEST_F(EncodedFormDataTest, DeepCopy) {
original->AppendData("Foo", 3);
original->AppendFileRange("example.txt", 12345, 56789,
base::Time::FromDoubleT(9999.0));
original->AppendBlob("originalUUID", nullptr);
mojo::PendingRemote<mojom::blink::Blob> remote;
mojo::PendingReceiver<mojom::blink::Blob> receiver =
remote.InitWithNewPipeAndPassReceiver();
original->AppendBlob(
"originalUUID", BlobDataHandle::Create("uuid", "" /* type */,
0u /* size */, std::move(remote)));
Vector<char> boundary_vector;
boundary_vector.Append("----boundaryForTest", 19);

@ -1817,7 +1817,7 @@ struct FuzzTraits<network::DataElement> {
if (!fuzzer->ShouldGenerate())
return true;
switch (RandInRange(3)) {
switch (RandInRange(2)) {
case 0: {
// network::DataElement::Type::TYPE_BYTES
if (RandEvent(2)) {
@ -1847,20 +1847,6 @@ struct FuzzTraits<network::DataElement> {
p->SetToFilePathRange(path, offset, length, modification_time);
return true;
}
case 2: {
// network::DataElement::Type::TYPE_BLOB
std::string uuid;
uint64_t offset;
uint64_t length;
if (!FuzzParam(&uuid, fuzzer))
return false;
if (!FuzzParam(&offset, fuzzer))
return false;
if (!FuzzParam(&length, fuzzer))
return false;
p->SetToBlobRange(uuid, offset, length);
return true;
}
default: {
NOTREACHED();
return false;