diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-13 13:24:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 10:57:25 +0000 |
commit | af3d4809763ef308f08ced947a73b624729ac7ea (patch) | |
tree | 4402b911e30383f6c6dace1e8cf3b8e85355db3a /chromium/dbus | |
parent | 0e8ff63a407fe323e215bb1a2c423c09a4747c8a (diff) | |
download | qtwebengine-chromium-af3d4809763ef308f08ced947a73b624729ac7ea.tar.gz |
BASELINE: Update Chromium to 47.0.2526.14
Also adding in sources needed for spellchecking.
Change-Id: Idd44170fa1616f26315188970a8d5ba7d472b18a
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'chromium/dbus')
-rw-r--r-- | chromium/dbus/BUILD.gn | 1 | ||||
-rw-r--r-- | chromium/dbus/message.cc | 21 | ||||
-rw-r--r-- | chromium/dbus/object_manager.cc | 19 | ||||
-rw-r--r-- | chromium/dbus/property.cc | 49 | ||||
-rw-r--r-- | chromium/dbus/property.h | 268 | ||||
-rw-r--r-- | chromium/dbus/string_util.cc | 10 | ||||
-rw-r--r-- | chromium/dbus/test_proto.proto | 4 |
7 files changed, 259 insertions, 113 deletions
diff --git a/chromium/dbus/BUILD.gn b/chromium/dbus/BUILD.gn index a133e724b64..ee154a85ad8 100644 --- a/chromium/dbus/BUILD.gn +++ b/chromium/dbus/BUILD.gn @@ -124,6 +124,7 @@ executable("dbus_test_server") { ":dbus", "//base", "//base/test:test_support", + "//build/config/sanitizers:deps", ] configs += [ "//build/config/linux:dbus" ] diff --git a/chromium/dbus/message.cc b/chromium/dbus/message.cc index 3b021e50195..0bf76d425a8 100644 --- a/chromium/dbus/message.cc +++ b/chromium/dbus/message.cc @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/format_macros.h" #include "base/logging.h" +#include "base/numerics/safe_conversions.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -38,8 +39,7 @@ void AppendUint32Header(const std::string& header_name, uint32 header_value, std::string* output) { if (header_value != 0) { - *output += (header_name + ": " + base::StringPrintf("%u", header_value) + - "\n"); + *output += (header_name + ": " + base::UintToString(header_value) + "\n"); } } @@ -102,7 +102,7 @@ std::string Message::ToStringInternal(const std::string& indent, uint8 value = 0; if (!reader->PopByte(&value)) return kBrokenMessage; - output += indent + "byte " + base::IntToString(value) + "\n"; + output += indent + "byte " + base::UintToString(value) + "\n"; break; } case BOOL: { @@ -123,7 +123,7 @@ std::string Message::ToStringInternal(const std::string& indent, uint16 value = 0; if (!reader->PopUint16(&value)) return kBrokenMessage; - output += indent + "uint16 " + base::IntToString(value) + "\n"; + output += indent + "uint16 " + base::UintToString(value) + "\n"; break; } case INT32: { @@ -137,30 +137,28 @@ std::string Message::ToStringInternal(const std::string& indent, uint32 value = 0; if (!reader->PopUint32(&value)) return kBrokenMessage; - output += indent + "uint32 " + base::StringPrintf("%u", value) + "\n"; + output += indent + "uint32 " + base::UintToString(value) + "\n"; break; } case INT64: { int64 value = 0; if (!reader->PopInt64(&value)) return kBrokenMessage; - output += (indent + "int64 " + - base::StringPrintf("%" PRId64, value) + "\n"); + output += (indent + "int64 " + base::Int64ToString(value) + "\n"); break; } case UINT64: { uint64 value = 0; if (!reader->PopUint64(&value)) return kBrokenMessage; - output += (indent + "uint64 " + - base::StringPrintf("%" PRIu64, value) + "\n"); + output += (indent + "uint64 " + base::Uint64ToString(value) + "\n"); break; } case DOUBLE: { double value = 0; if (!reader->PopDouble(&value)) return kBrokenMessage; - output += indent + "double " + base::StringPrintf("%f", value) + "\n"; + output += indent + "double " + base::DoubleToString(value) + "\n"; break; } case STRING: { @@ -696,7 +694,8 @@ void MessageWriter::AppendBasic(int dbus_type, const void* value) { } void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) { - const std::string signature = base::StringPrintf("%c", dbus_type); + const std::string signature(1u, // length + base::checked_cast<char>(dbus_type)); MessageWriter variant_writer(message_); OpenVariant(signature, &variant_writer); variant_writer.AppendBasic(dbus_type, value); diff --git a/chromium/dbus/object_manager.cc b/chromium/dbus/object_manager.cc index 851fee44b2e..3f253fa5083 100644 --- a/chromium/dbus/object_manager.cc +++ b/chromium/dbus/object_manager.cc @@ -252,6 +252,9 @@ DBusHandlerResult ObjectManager::HandleMessage(DBusConnection* connection, DCHECK(bus_); bus_->AssertOnDBusThread(); + // Handle the message only if it is a signal. + // Note that the match rule in SetupMatchRuleAndFilter() is configured to + // only accept signals, but we check here just in case. if (dbus_message_get_type(raw_message) != DBUS_MESSAGE_TYPE_SIGNAL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -266,7 +269,9 @@ DBusHandlerResult ObjectManager::HandleMessage(DBusConnection* connection, statistics::AddReceivedSignal(service_name_, interface, member); - // Only handle the PropertiesChanged signal. + // Handle the signal only if it is PropertiesChanged. + // Note that the match rule in SetupMatchRuleAndFilter() is configured to + // only accept PropertiesChanged signals, but we check here just in case. const std::string absolute_signal_name = GetAbsoluteMemberName(interface, member); const std::string properties_changed_signal_name = @@ -276,13 +281,15 @@ DBusHandlerResult ObjectManager::HandleMessage(DBusConnection* connection, VLOG(1) << "Signal received: " << signal->ToString(); - // Make sure that the signal originated from the correct sender. + // Handle the signal only if it is from the service that the ObjectManager + // instance is interested in. + // Note that the match rule in SetupMatchRuleAndFilter() is configured to + // only accept messages from the service name of our interest. However, the + // service='...' filter does not work as intended. See crbug.com/507206#14 + // and #15 for details, hence it's necessary to check the sender here. std::string sender = signal->GetSender(); - if (service_name_owner_ != sender) { - LOG(ERROR) << "Rejecting a message from a wrong sender."; - UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 1); + if (service_name_owner_ != sender) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } const ObjectPath path = signal->GetPath(); diff --git a/chromium/dbus/property.cc b/chromium/dbus/property.cc index 66b86c0486d..234036c35db 100644 --- a/chromium/dbus/property.cc +++ b/chromium/dbus/property.cc @@ -18,6 +18,10 @@ namespace dbus { // PropertyBase implementation. // +PropertyBase::PropertyBase() : property_set_(nullptr), is_valid_(false) {} + +PropertyBase::~PropertyBase() {} + void PropertyBase::Init(PropertySet* property_set, const std::string& name) { DCHECK(!property_set_); property_set_ = property_set; @@ -129,6 +133,35 @@ void PropertySet::OnGet(PropertyBase* property, GetCallback callback, callback.Run(response); } +bool PropertySet::GetAndBlock(PropertyBase* property) { + MethodCall method_call(kPropertiesInterface, kPropertiesGet); + MessageWriter writer(&method_call); + writer.AppendString(interface()); + writer.AppendString(property->name()); + + DCHECK(object_proxy_); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, + ObjectProxy::TIMEOUT_USE_DEFAULT)); + + if (!response.get()) { + LOG(WARNING) << property->name() << ": GetAndBlock: failed."; + return false; + } + + MessageReader reader(response.get()); + if (property->PopValueFromReader(&reader)) { + property->set_valid(true); + NotifyPropertyChanged(property->name()); + } else { + if (property->is_valid()) { + property->set_valid(false); + NotifyPropertyChanged(property->name()); + } + } + return true; +} + void PropertySet::GetAll() { MethodCall method_call(kPropertiesInterface, kPropertiesGetAll); MessageWriter writer(&method_call); @@ -170,6 +203,22 @@ void PropertySet::Set(PropertyBase* property, SetCallback callback) { callback)); } +bool PropertySet::SetAndBlock(PropertyBase* property) { + MethodCall method_call(kPropertiesInterface, kPropertiesSet); + MessageWriter writer(&method_call); + writer.AppendString(interface()); + writer.AppendString(property->name()); + property->AppendSetValueToWriter(&writer); + + DCHECK(object_proxy_); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, + ObjectProxy::TIMEOUT_USE_DEFAULT)); + if (response.get()) + return true; + return false; +} + void PropertySet::OnSet(PropertyBase* property, SetCallback callback, Response* response) { diff --git a/chromium/dbus/property.h b/chromium/dbus/property.h index 321f4dbd078..e379f8a1618 100644 --- a/chromium/dbus/property.h +++ b/chromium/dbus/property.h @@ -132,9 +132,10 @@ class PropertySet; // the Property<> template that are not type-specific, such as the // associated PropertySet, property name, and the type-unsafe parts // used by PropertySet. -class PropertyBase { +class CHROME_DBUS_EXPORT PropertyBase { public: - PropertyBase() : property_set_(nullptr), is_valid_(false) {} + PropertyBase(); + virtual ~PropertyBase(); // Initializes the |property_set| and property |name| so that method // calls may be made from this class. This method is called by @@ -258,6 +259,10 @@ class CHROME_DBUS_EXPORT PropertySet { virtual void OnGet(PropertyBase* property, GetCallback callback, Response* response); + // The synchronous version of Get(). + // This should never be used on an interactive thread. + virtual bool GetAndBlock(PropertyBase* property); + // Queries the remote object for values of all properties and updates // initial values. Sub-classes may override to use a different D-Bus // method, or if the remote object does not support retrieving all @@ -278,6 +283,10 @@ class CHROME_DBUS_EXPORT PropertySet { virtual void OnSet(PropertyBase* property, SetCallback callback, Response* response); + // The synchronous version of Set(). + // This should never be used on an interactive thread. + virtual bool SetAndBlock(PropertyBase* property); + // Update properties by reading an array of dictionary entries, each // containing a string with the name and a variant with the value, from // |message_reader|. Returns false if message is in incorrect format. @@ -367,6 +376,7 @@ template <class T> class CHROME_DBUS_EXPORT Property : public PropertyBase { public: Property() {} + ~Property() override {} // Retrieves the cached value. const T& value() const { return value_; } @@ -378,6 +388,12 @@ class CHROME_DBUS_EXPORT Property : public PropertyBase { property_set()->Get(this, callback); } + // The synchronous version of Get(). + // This should never be used on an interactive thread. + virtual bool GetAndBlock() { + return property_set()->GetAndBlock(this); + } + // Requests that the remote object change the property value to |value|, // |callback| will be called to indicate the success or failure of the // request, however the new value may not be available depending on the @@ -387,6 +403,13 @@ class CHROME_DBUS_EXPORT Property : public PropertyBase { property_set()->Set(this, callback); } + // The synchronous version of Set(). + // This should never be used on an interactive thread. + virtual bool SetAndBlock(const T& value) { + set_value_ = value; + return property_set()->SetAndBlock(this); + } + // Method used by PropertySet to retrieve the value from a MessageReader, // no knowledge of the contained type is required, this method returns // true if its expected type was found, false if not. @@ -424,101 +447,168 @@ class CHROME_DBUS_EXPORT Property : public PropertyBase { T set_value_; }; -template <> Property<uint8>::Property(); -template <> bool Property<uint8>::PopValueFromReader(MessageReader* reader); -template <> void Property<uint8>::AppendSetValueToWriter(MessageWriter* writer); -extern template class Property<uint8>; - -template <> Property<bool>::Property(); -template <> bool Property<bool>::PopValueFromReader(MessageReader* reader); -template <> void Property<bool>::AppendSetValueToWriter(MessageWriter* writer); -extern template class Property<bool>; - -template <> Property<int16>::Property(); -template <> bool Property<int16>::PopValueFromReader(MessageReader* reader); -template <> void Property<int16>::AppendSetValueToWriter(MessageWriter* writer); -extern template class Property<int16>; - -template <> Property<uint16>::Property(); -template <> bool Property<uint16>::PopValueFromReader(MessageReader* reader); -template <> void Property<uint16>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<uint16>; - -template <> Property<int32>::Property(); -template <> bool Property<int32>::PopValueFromReader(MessageReader* reader); -template <> void Property<int32>::AppendSetValueToWriter(MessageWriter* writer); -extern template class Property<int32>; - -template <> Property<uint32>::Property(); -template <> bool Property<uint32>::PopValueFromReader(MessageReader* reader); -template <> void Property<uint32>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<uint32>; - -template <> Property<int64>::Property(); -template <> bool Property<int64>::PopValueFromReader(MessageReader* reader); -template <> void Property<int64>::AppendSetValueToWriter(MessageWriter* writer); -extern template class Property<int64>; - -template <> Property<uint64>::Property(); -template <> bool Property<uint64>::PopValueFromReader(MessageReader* reader); -template <> void Property<uint64>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<uint64>; - -template <> Property<double>::Property(); -template <> bool Property<double>::PopValueFromReader(MessageReader* reader); -template <> void Property<double>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<double>; - -template <> bool Property<std::string>::PopValueFromReader( - MessageReader* reader); -template <> void Property<std::string>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<std::string>; - -template <> bool Property<ObjectPath>::PopValueFromReader( - MessageReader* reader); -template <> void Property<ObjectPath>::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<ObjectPath>; - -template <> bool Property<std::vector<std::string> >::PopValueFromReader( - MessageReader* reader); -template <> void Property<std::vector<std::string> >::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<std::vector<std::string> >; - -template <> bool Property<std::vector<ObjectPath> >::PopValueFromReader( - MessageReader* reader); -template <> void Property<std::vector<ObjectPath> >::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<std::vector<ObjectPath> >; - -template <> bool Property<std::vector<uint8> >::PopValueFromReader( - MessageReader* reader); -template <> void Property<std::vector<uint8> >::AppendSetValueToWriter( - MessageWriter* writer); -extern template class Property<std::vector<uint8> >; - -template <> -bool Property<std::map<std::string, std::string>>::PopValueFromReader( +// Clang and GCC don't agree on how attributes should work for explicitly +// instantiated templates. GCC ignores attributes on explicit instantiations +// (and emits a warning) while Clang requires the visiblity attribute on the +// explicit instantiations for them to be visible to other compilation units. +// Hopefully clang and GCC agree one day, and this can be cleaned up: +// https://llvm.org/bugs/show_bug.cgi?id=24815 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" + +template <> +CHROME_DBUS_EXPORT Property<uint8>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<uint8>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<uint8>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<uint8>; + +template <> +CHROME_DBUS_EXPORT Property<bool>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<bool>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<bool>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<bool>; + +template <> +CHROME_DBUS_EXPORT Property<int16>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<int16>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<int16>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<int16>; + +template <> +CHROME_DBUS_EXPORT Property<uint16>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<uint16>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<uint16>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<uint16>; + +template <> +CHROME_DBUS_EXPORT Property<int32>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<int32>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<int32>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<int32>; + +template <> +CHROME_DBUS_EXPORT Property<uint32>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<uint32>::PopValueFromReader( MessageReader* reader); template <> -void Property<std::map<std::string, std::string>>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<uint32>::AppendSetValueToWriter( MessageWriter* writer); -extern template class Property<std::map<std::string, std::string>>; +extern template class CHROME_DBUS_EXPORT Property<uint32>; template <> -bool Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: +CHROME_DBUS_EXPORT Property<int64>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<int64>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<int64>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<int64>; + +template <> +CHROME_DBUS_EXPORT Property<uint64>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<uint64>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<uint64>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<uint64>; + +template <> +CHROME_DBUS_EXPORT Property<double>::Property(); +template <> +CHROME_DBUS_EXPORT bool Property<double>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<double>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<double>; + +template <> +CHROME_DBUS_EXPORT bool Property<std::string>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<std::string>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<std::string>; + +template <> +CHROME_DBUS_EXPORT bool Property<ObjectPath>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<ObjectPath>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<ObjectPath>; + +template <> +CHROME_DBUS_EXPORT bool Property<std::vector<std::string>>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property< + std::vector<std::string>>::AppendSetValueToWriter(MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<std::vector<std::string>>; + +template <> +CHROME_DBUS_EXPORT bool Property<std::vector<ObjectPath>>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property< + std::vector<ObjectPath>>::AppendSetValueToWriter(MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<std::vector<ObjectPath>>; + +template <> +CHROME_DBUS_EXPORT bool Property<std::vector<uint8>>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void Property<std::vector<uint8>>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT Property<std::vector<uint8>>; + +template <> +CHROME_DBUS_EXPORT bool +Property<std::map<std::string, std::string>>::PopValueFromReader( + MessageReader* reader); +template <> +CHROME_DBUS_EXPORT void +Property<std::map<std::string, std::string>>::AppendSetValueToWriter( + MessageWriter* writer); +extern template class CHROME_DBUS_EXPORT + Property<std::map<std::string, std::string>>; + +template <> +CHROME_DBUS_EXPORT bool +Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: PopValueFromReader(MessageReader* reader); template <> -void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: +CHROME_DBUS_EXPORT void +Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: AppendSetValueToWriter(MessageWriter* writer); -extern template class Property< - std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; +extern template class CHROME_DBUS_EXPORT + Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; + +#pragma GCC diagnostic pop } // namespace dbus diff --git a/chromium/dbus/string_util.cc b/chromium/dbus/string_util.cc index 0b077860308..16e483a5fea 100644 --- a/chromium/dbus/string_util.cc +++ b/chromium/dbus/string_util.cc @@ -8,13 +8,10 @@ namespace dbus { +// This implementation is based upon D-Bus Specification Version 0.19. bool IsValidObjectPath(const std::string& value) { - // This implementation is based upon D-Bus Specification Version 0.19. - - const bool kCaseSensitive = true; - // A valid object path begins with '/'. - if (!base::StartsWithASCII(value, "/", kCaseSensitive)) + if (!base::StartsWith(value, "/", base::CompareCase::SENSITIVE)) return false; // Elements are pieces delimited by '/'. For instance, "org", "chromium", @@ -39,7 +36,8 @@ bool IsValidObjectPath(const std::string& value) { } // A trailing '/' character is not allowed unless the path is the root path. - if (value.size() > 1 && base::EndsWith(value, "/", kCaseSensitive)) + if (value.size() > 1 && + base::EndsWith(value, "/", base::CompareCase::SENSITIVE)) return false; return true; diff --git a/chromium/dbus/test_proto.proto b/chromium/dbus/test_proto.proto index 0a1d06f7ff5..1ec128bf609 100644 --- a/chromium/dbus/test_proto.proto +++ b/chromium/dbus/test_proto.proto @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +syntax = "proto2"; + option optimize_for = LITE_RUNTIME; // This is a simple dummy protocol buffer that is used for testing handling of @@ -10,4 +12,4 @@ option optimize_for = LITE_RUNTIME; message TestProto { optional string text = 1; optional int32 number = 2; -}
\ No newline at end of file +} |