From c551f43206405019121bd2b2c93714319a0a3300 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 23 Jan 2020 17:21:03 +0100 Subject: BASELINE: Update Chromium to 79.0.3945.139 Change-Id: I336b7182fab9bca80b709682489c07db112eaca5 Reviewed-by: Allan Sandfeld Jensen --- .../data_decoder/bundled_exchanges_parser.cc | 8 ++--- .../bundled_exchanges_parser_unittest.cc | 3 +- .../services/data_decoder/data_decoder_service.cc | 35 ++++++++++++---------- .../services/data_decoder/data_decoder_service.h | 11 +++---- .../data_decoder/public/cpp/android/BUILD.gn | 2 ++ .../services/data_decoder/JsonSanitizer.java | 13 ++++---- .../data_decoder/public/cpp/decode_image.cc | 23 +++++++------- .../public/cpp/safe_json_parser_impl.cc | 12 ++++---- .../public/cpp/safe_json_parser_impl.h | 3 +- .../data_decoder/public/cpp/safe_xml_parser.cc | 16 +++++----- .../public/cpp/test_data_decoder_service.cc | 23 +++++++------- .../public/cpp/test_data_decoder_service.h | 6 ++-- chromium/services/data_decoder/xml_parser.cc | 2 +- 13 files changed, 84 insertions(+), 73 deletions(-) (limited to 'chromium/services/data_decoder') diff --git a/chromium/services/data_decoder/bundled_exchanges_parser.cc b/chromium/services/data_decoder/bundled_exchanges_parser.cc index 3fab28ba478..043795edd7e 100644 --- a/chromium/services/data_decoder/bundled_exchanges_parser.cc +++ b/chromium/services/data_decoder/bundled_exchanges_parser.cc @@ -596,16 +596,12 @@ class BundledExchangesParser::MetadataParser // Step 23. "Assert: metadata has an entry with the key "primaryUrl"." DCHECK(!metadata_->primary_url.is_empty()); - // Step 24. "If metadata doesn't have entries with keys "requests" and - // "manifest", return a "format error" with fallbackUrl." + // Step 24. "If metadata doesn't have an entry with the key "requests", + // return a "format error" with fallbackUrl." if (metadata_->requests.empty()) { RunErrorCallbackAndDestroy("Bundle must have an index section."); return; } - if (metadata_->manifest_url.is_empty()) { - RunErrorCallbackAndDestroy("Bundle must have a manifest URL."); - return; - } // Step 25. "Return metadata." RunSuccessCallbackAndDestroy(); diff --git a/chromium/services/data_decoder/bundled_exchanges_parser_unittest.cc b/chromium/services/data_decoder/bundled_exchanges_parser_unittest.cc index 2a666c1e956..d44c50c20a0 100644 --- a/chromium/services/data_decoder/bundled_exchanges_parser_unittest.cc +++ b/chromium/services/data_decoder/bundled_exchanges_parser_unittest.cc @@ -635,7 +635,8 @@ TEST_F(BundledExchangeParserTest, NoManifest) { "payload"); TestDataSource data_source(builder.CreateBundle()); - ExpectFormatErrorWithFallbackURL(ParseBundle(&data_source)); + mojom::BundleMetadataPtr metadata = ParseBundle(&data_source).first; + ASSERT_TRUE(metadata); } TEST_F(BundledExchangeParserTest, InvalidManifestURL) { diff --git a/chromium/services/data_decoder/data_decoder_service.cc b/chromium/services/data_decoder/data_decoder_service.cc index bfcbd1730f2..1884666403c 100644 --- a/chromium/services/data_decoder/data_decoder_service.cc +++ b/chromium/services/data_decoder/data_decoder_service.cc @@ -10,7 +10,7 @@ #include "base/macros.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" -#include "mojo/public/cpp/bindings/strong_binding.h" +#include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "services/data_decoder/bundled_exchanges_parser_factory.h" #include "services/data_decoder/image_decoder_impl.h" #include "services/data_decoder/json_parser_impl.h" @@ -69,35 +69,38 @@ void DataDecoderService::OnBindInterface( #ifdef OS_CHROMEOS void DataDecoderService::BindBleScanParser( - mojom::BleScanParserRequest request) { - mojo::MakeStrongBinding( + mojo::PendingReceiver receiver) { + mojo::MakeSelfOwnedReceiver( std::make_unique(keepalive_.CreateRef()), - std::move(request)); + std::move(receiver)); } #endif // OS_CHROMEOS -void DataDecoderService::BindImageDecoder(mojom::ImageDecoderRequest request) { - mojo::MakeStrongBinding( +void DataDecoderService::BindImageDecoder( + mojo::PendingReceiver receiver) { + mojo::MakeSelfOwnedReceiver( std::make_unique(keepalive_.CreateRef()), - std::move(request)); + std::move(receiver)); } -void DataDecoderService::BindJsonParser(mojom::JsonParserRequest request) { - mojo::MakeStrongBinding( +void DataDecoderService::BindJsonParser( + mojo::PendingReceiver receiver) { + mojo::MakeSelfOwnedReceiver( std::make_unique(keepalive_.CreateRef()), - std::move(request)); + std::move(receiver)); } -void DataDecoderService::BindXmlParser(mojom::XmlParserRequest request) { - mojo::MakeStrongBinding(std::make_unique(keepalive_.CreateRef()), - std::move(request)); +void DataDecoderService::BindXmlParser( + mojo::PendingReceiver receiver) { + mojo::MakeSelfOwnedReceiver( + std::make_unique(keepalive_.CreateRef()), std::move(receiver)); } void DataDecoderService::BindBundledExchangesParserFactory( - mojom::BundledExchangesParserFactoryRequest request) { - mojo::MakeStrongBinding( + mojo::PendingReceiver receiver) { + mojo::MakeSelfOwnedReceiver( std::make_unique(keepalive_.CreateRef()), - std::move(request)); + std::move(receiver)); } } // namespace data_decoder diff --git a/chromium/services/data_decoder/data_decoder_service.h b/chromium/services/data_decoder/data_decoder_service.h index 04e5caf9ea0..928fce202d4 100644 --- a/chromium/services/data_decoder/data_decoder_service.h +++ b/chromium/services/data_decoder/data_decoder_service.h @@ -8,6 +8,7 @@ #include #include "base/macros.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" #include "services/data_decoder/public/mojom/bundled_exchanges_parser.mojom.h" #include "services/data_decoder/public/mojom/image_decoder.mojom.h" #include "services/data_decoder/public/mojom/json_parser.mojom.h" @@ -41,13 +42,13 @@ class DataDecoderService : public service_manager::Service { private: void BindBundledExchangesParserFactory( - mojom::BundledExchangesParserFactoryRequest request); - void BindImageDecoder(mojom::ImageDecoderRequest request); - void BindJsonParser(mojom::JsonParserRequest request); - void BindXmlParser(mojom::XmlParserRequest request); + mojo::PendingReceiver receiver); + void BindImageDecoder(mojo::PendingReceiver receiver); + void BindJsonParser(mojo::PendingReceiver receiver); + void BindXmlParser(mojo::PendingReceiver receiver); #ifdef OS_CHROMEOS - void BindBleScanParser(mojom::BleScanParserRequest request); + void BindBleScanParser(mojo::PendingReceiver receiver); #endif // OS_CHROMEOS service_manager::ServiceBinding binding_{this}; diff --git a/chromium/services/data_decoder/public/cpp/android/BUILD.gn b/chromium/services/data_decoder/public/cpp/android/BUILD.gn index 3474ecf2fb5..8db1e96c850 100644 --- a/chromium/services/data_decoder/public/cpp/android/BUILD.gn +++ b/chromium/services/data_decoder/public/cpp/android/BUILD.gn @@ -15,7 +15,9 @@ if (current_toolchain == default_toolchain) { android_library("safe_json_java") { deps = [ "//base:base_java", + "//base:jni_java", ] + annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] java_files = [] + _jni_sources } } diff --git a/chromium/services/data_decoder/public/cpp/android/java/src/org/chromium/services/data_decoder/JsonSanitizer.java b/chromium/services/data_decoder/public/cpp/android/java/src/org/chromium/services/data_decoder/JsonSanitizer.java index b3c4bfaa15f..f398f4115d3 100644 --- a/chromium/services/data_decoder/public/cpp/android/java/src/org/chromium/services/data_decoder/JsonSanitizer.java +++ b/chromium/services/data_decoder/public/cpp/android/java/src/org/chromium/services/data_decoder/JsonSanitizer.java @@ -12,6 +12,7 @@ import android.util.MalformedJsonException; import org.chromium.base.StreamUtil; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; +import org.chromium.base.annotations.NativeMethods; import java.io.IOException; import java.io.StringReader; @@ -115,10 +116,10 @@ public class JsonSanitizer { try { result = sanitize(unsafeJson); } catch (IOException | IllegalStateException e) { - nativeOnError(nativePtr, e.getMessage()); + JsonSanitizerJni.get().onError(nativePtr, e.getMessage()); return; } - nativeOnSuccess(nativePtr, result); + JsonSanitizerJni.get().onSuccess(nativePtr, result); } /** @@ -189,7 +190,9 @@ public class JsonSanitizer { || (codePoint > 0xFDEF && codePoint <= 0x10FFFF && (codePoint & 0xFFFE) != 0xFFFE); } - private static native void nativeOnSuccess(long id, String json); - - private static native void nativeOnError(long id, String error); + @NativeMethods + interface Natives { + void onSuccess(long id, String json); + void onError(long id, String error); + } } diff --git a/chromium/services/data_decoder/public/cpp/decode_image.cc b/chromium/services/data_decoder/public/cpp/decode_image.cc index 0ae9eafc403..0f672958d67 100644 --- a/chromium/services/data_decoder/public/cpp/decode_image.cc +++ b/chromium/services/data_decoder/public/cpp/decode_image.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "mojo/public/cpp/bindings/remote.h" #include "services/data_decoder/public/mojom/constants.mojom.h" #include "services/service_manager/public/cpp/connector.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -16,16 +17,16 @@ namespace data_decoder { namespace { -// Helper callback which owns an ImageDecoderPtr until invoked. This keeps the -// ImageDecoder pipe open just long enough to dispatch a reply, at which point -// the reply is forwarded to the wrapped |callback|. -void OnDecodeImage(mojom::ImageDecoderPtr decoder, +// Helper callback which owns a mojo::Remote until invoked. This +// keeps the ImageDecoder pipe open just long enough to dispatch a reply, at +// which point the reply is forwarded to the wrapped |callback|. +void OnDecodeImage(mojo::Remote decoder, mojom::ImageDecoder::DecodeImageCallback callback, const SkBitmap& bitmap) { std::move(callback).Run(bitmap); } -void OnDecodeImages(mojom::ImageDecoderPtr decoder, +void OnDecodeImages(mojo::Remote decoder, mojom::ImageDecoder::DecodeAnimationCallback callback, std::vector bitmaps) { std::move(callback).Run(std::move(bitmaps)); @@ -40,12 +41,12 @@ void DecodeImage(service_manager::Connector* connector, uint64_t max_size_in_bytes, const gfx::Size& desired_image_frame_size, mojom::ImageDecoder::DecodeImageCallback callback) { - mojom::ImageDecoderPtr decoder; - connector->BindInterface(mojom::kServiceName, &decoder); + mojo::Remote decoder; + connector->Connect(mojom::kServiceName, decoder.BindNewPipeAndPassReceiver()); // |call_once| runs |callback| on its first invocation. auto call_once = base::AdaptCallbackForRepeating(std::move(callback)); - decoder.set_connection_error_handler(base::Bind(call_once, SkBitmap())); + decoder.set_disconnect_handler(base::Bind(call_once, SkBitmap())); mojom::ImageDecoder* raw_decoder = decoder.get(); raw_decoder->DecodeImage( @@ -59,12 +60,12 @@ void DecodeAnimation(service_manager::Connector* connector, bool shrink_to_fit, uint64_t max_size_in_bytes, mojom::ImageDecoder::DecodeAnimationCallback callback) { - mojom::ImageDecoderPtr decoder; - connector->BindInterface(mojom::kServiceName, &decoder); + mojo::Remote decoder; + connector->Connect(mojom::kServiceName, decoder.BindNewPipeAndPassReceiver()); // |call_once| runs |callback| on its first invocation. auto call_once = base::AdaptCallbackForRepeating(std::move(callback)); - decoder.set_connection_error_handler(base::Bind( + decoder.set_disconnect_handler(base::Bind( call_once, base::Passed(std::vector()))); mojom::ImageDecoder* raw_decoder = decoder.get(); diff --git a/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.cc b/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.cc index 382ea64759d..f2c5eb683ce 100644 --- a/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.cc +++ b/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.cc @@ -27,10 +27,10 @@ SafeJsonParserImpl::SafeJsonParserImpl( error_callback_(std::move(error_callback)) { // If no batch ID has been provided, use a random instance ID to guarantee the // connection is to a new service running in its own process. - connector->BindInterface( + connector->Connect( service_manager::ServiceFilter::ByNameWithId( mojom::kServiceName, batch_id.value_or(base::Token::CreateRandom())), - &json_parser_ptr_); + json_parser_.BindNewPipeAndPassReceiver()); } SafeJsonParserImpl::~SafeJsonParserImpl() = default; @@ -38,9 +38,9 @@ SafeJsonParserImpl::~SafeJsonParserImpl() = default; void SafeJsonParserImpl::Start() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - json_parser_ptr_.set_connection_error_handler(base::Bind( + json_parser_.set_disconnect_handler(base::Bind( &SafeJsonParserImpl::OnConnectionError, base::Unretained(this))); - json_parser_ptr_->Parse( + json_parser_->Parse( std::move(unsafe_json_), base::Bind(&SafeJsonParserImpl::OnParseDone, base::Unretained(this))); } @@ -49,7 +49,7 @@ void SafeJsonParserImpl::OnConnectionError() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // Shut down the utility process. - json_parser_ptr_.reset(); + json_parser_.reset(); ReportResults(base::nullopt, "Connection error with the json parser process."); @@ -60,7 +60,7 @@ void SafeJsonParserImpl::OnParseDone(base::Optional result, DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // Shut down the utility process. - json_parser_ptr_.reset(); + json_parser_.reset(); ReportResults(std::move(result), error.value_or("")); } diff --git a/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.h b/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.h index eb04331734d..a43fbf98f02 100644 --- a/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.h +++ b/chromium/services/data_decoder/public/cpp/safe_json_parser_impl.h @@ -15,6 +15,7 @@ #include "base/threading/thread_checker.h" #include "base/token.h" #include "base/values.h" +#include "mojo/public/cpp/bindings/remote.h" #include "services/data_decoder/public/cpp/safe_json_parser.h" #include "services/data_decoder/public/mojom/json_parser.mojom.h" @@ -54,7 +55,7 @@ class SafeJsonParserImpl : public SafeJsonParser { SuccessCallback success_callback_; ErrorCallback error_callback_; - mojom::JsonParserPtr json_parser_ptr_; + mojo::Remote json_parser_; SEQUENCE_CHECKER(sequence_checker_); diff --git a/chromium/services/data_decoder/public/cpp/safe_xml_parser.cc b/chromium/services/data_decoder/public/cpp/safe_xml_parser.cc index 680264d9b43..f21f7f542a6 100644 --- a/chromium/services/data_decoder/public/cpp/safe_xml_parser.cc +++ b/chromium/services/data_decoder/public/cpp/safe_xml_parser.cc @@ -9,6 +9,7 @@ #include "base/macros.h" #include "base/threading/thread_checker.h" #include "base/values.h" +#include "mojo/public/cpp/bindings/remote.h" #include "services/data_decoder/public/mojom/constants.mojom.h" #include "services/data_decoder/public/mojom/xml_parser.mojom.h" #include "services/service_manager/public/cpp/connector.h" @@ -31,7 +32,7 @@ class SafeXmlParser { const base::Optional& error); XmlParserCallback callback_; - mojom::XmlParserPtr xml_parser_ptr_; + mojo::Remote xml_parser_; SEQUENCE_CHECKER(sequence_checker_); DISALLOW_COPY_AND_ASSIGN(SafeXmlParser); @@ -46,21 +47,20 @@ SafeXmlParser::SafeXmlParser(service_manager::Connector* connector, // If no batch ID has been provided, use a random instance ID to guarantee the // connection is to a new service running in its own process. - connector->BindInterface( + connector->Connect( service_manager::ServiceFilter::ByNameWithId( mojom::kServiceName, batch_id.is_zero() ? base::Token::CreateRandom() : batch_id), - &xml_parser_ptr_); + xml_parser_.BindNewPipeAndPassReceiver()); - // Unretained(this) is safe as the xml_parser_ptr_ is owned by this class. - xml_parser_ptr_.set_connection_error_handler(base::BindOnce( + // Unretained(this) is safe as the xml_parser_ is owned by this class. + xml_parser_.set_disconnect_handler(base::BindOnce( &SafeXmlParser::ReportResults, base::Unretained(this), /*parsed_xml=*/base::nullopt, base::make_optional( std::string("Connection error with the XML parser process.")))); - xml_parser_ptr_->Parse( - unsafe_xml, - base::BindOnce(&SafeXmlParser::ReportResults, base::Unretained(this))); + xml_parser_->Parse(unsafe_xml, base::BindOnce(&SafeXmlParser::ReportResults, + base::Unretained(this))); } SafeXmlParser::~SafeXmlParser() = default; diff --git a/chromium/services/data_decoder/public/cpp/test_data_decoder_service.cc b/chromium/services/data_decoder/public/cpp/test_data_decoder_service.cc index 02cc6d7a6af..dd573ce9602 100644 --- a/chromium/services/data_decoder/public/cpp/test_data_decoder_service.cc +++ b/chromium/services/data_decoder/public/cpp/test_data_decoder_service.cc @@ -4,6 +4,7 @@ #include "services/data_decoder/public/cpp/test_data_decoder_service.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" #include "services/data_decoder/data_decoder_service.h" #include "services/data_decoder/public/mojom/constants.mojom.h" @@ -37,16 +38,18 @@ void CrashyDataDecoderService::OnBindInterface( DCHECK(interface_name == mojom::JsonParser::Name_ || interface_name == mojom::ImageDecoder::Name_); if (interface_name == mojom::JsonParser::Name_ && crash_json_) { - DCHECK(!json_parser_binding_); - json_parser_binding_ = std::make_unique>( - this, mojom::JsonParserRequest(std::move(interface_pipe))); + DCHECK(!json_parser_receiver_); + json_parser_receiver_ = std::make_unique>( + this, + mojo::PendingReceiver(std::move(interface_pipe))); return; } if (interface_name == mojom::ImageDecoder::Name_ && crash_image_) { - DCHECK(!image_decoder_binding_); - image_decoder_binding_ = - std::make_unique>( - this, mojom::ImageDecoderRequest(std::move(interface_pipe))); + DCHECK(!image_decoder_receiver_); + image_decoder_receiver_ = + std::make_unique>( + this, mojo::PendingReceiver( + std::move(interface_pipe))); return; } real_service_.OnBindInterface(source_info, interface_name, @@ -61,7 +64,7 @@ void CrashyDataDecoderService::DecodeImage( int64_t max_size_in_bytes, const gfx::Size& desired_image_frame_size, DecodeImageCallback callback) { - image_decoder_binding_.reset(); + image_decoder_receiver_.reset(); } void CrashyDataDecoderService::DecodeAnimation( @@ -69,12 +72,12 @@ void CrashyDataDecoderService::DecodeAnimation( bool shrink_to_fit, int64_t max_size_in_bytes, DecodeAnimationCallback callback) { - image_decoder_binding_.reset(); + image_decoder_receiver_.reset(); } void CrashyDataDecoderService::Parse(const std::string& json, ParseCallback callback) { - json_parser_binding_.reset(); + json_parser_receiver_.reset(); } } // namespace data_decoder diff --git a/chromium/services/data_decoder/public/cpp/test_data_decoder_service.h b/chromium/services/data_decoder/public/cpp/test_data_decoder_service.h index 36b92f2a226..ab99a4a459f 100644 --- a/chromium/services/data_decoder/public/cpp/test_data_decoder_service.h +++ b/chromium/services/data_decoder/public/cpp/test_data_decoder_service.h @@ -8,7 +8,7 @@ #include #include "base/macros.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/receiver.h" #include "services/data_decoder/data_decoder_service.h" #include "services/data_decoder/public/mojom/image_decoder.mojom.h" #include "services/data_decoder/public/mojom/json_parser.mojom.h" @@ -78,8 +78,8 @@ class CrashyDataDecoderService : public service_manager::Service, private: service_manager::ServiceBinding binding_; - std::unique_ptr> image_decoder_binding_; - std::unique_ptr> json_parser_binding_; + std::unique_ptr> image_decoder_receiver_; + std::unique_ptr> json_parser_receiver_; // An instance of the actual DataDecoderService we forward requests to for // interfaces that should not crash. diff --git a/chromium/services/data_decoder/xml_parser.cc b/chromium/services/data_decoder/xml_parser.cc index 53254a6e5d1..d2f81d7823a 100644 --- a/chromium/services/data_decoder/xml_parser.cc +++ b/chromium/services/data_decoder/xml_parser.cc @@ -69,7 +69,7 @@ base::Value* AddChildToElement(base::Value* element, base::Value child) { if (!children) children = element->SetKey(mojom::XmlParser::kChildrenKey, base::Value(base::Value::Type::LIST)); - children->GetList().push_back(std::move(child)); + children->Append(std::move(child)); return &children->GetList().back(); } -- cgit v1.2.1