summaryrefslogtreecommitdiff
path: root/chromium/dbus
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 16:23:34 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:37:21 +0000
commit38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch)
treec4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/dbus
parente684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff)
downloadqtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/dbus')
-rw-r--r--chromium/dbus/end_to_end_async_unittest.cc3
-rw-r--r--chromium/dbus/exported_object.cc51
-rw-r--r--chromium/dbus/exported_object.h34
-rw-r--r--chromium/dbus/mock_exported_object.h7
-rw-r--r--chromium/dbus/property_unittest.cc20
-rw-r--r--chromium/dbus/values_util_unittest.cc4
6 files changed, 105 insertions, 14 deletions
diff --git a/chromium/dbus/end_to_end_async_unittest.cc b/chromium/dbus/end_to_end_async_unittest.cc
index 11faf800316..92d4c7a1523 100644
--- a/chromium/dbus/end_to_end_async_unittest.cc
+++ b/chromium/dbus/end_to_end_async_unittest.cc
@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
@@ -310,7 +309,7 @@ TEST_F(EndToEndAsyncTest, EchoWithErrorCallback) {
TEST_F(EndToEndAsyncTest, EchoThreeTimes) {
const char* kMessages[] = { "foo", "bar", "baz" };
- for (size_t i = 0; i < arraysize(kMessages); ++i) {
+ for (size_t i = 0; i < base::size(kMessages); ++i) {
// Create the method call.
MethodCall method_call("org.chromium.TestInterface", "Echo");
MessageWriter writer(&method_call);
diff --git a/chromium/dbus/exported_object.cc b/chromium/dbus/exported_object.cc
index 5fa1b916f25..cabf1a22f32 100644
--- a/chromium/dbus/exported_object.cc
+++ b/chromium/dbus/exported_object.cc
@@ -68,6 +68,23 @@ bool ExportedObject::ExportMethodAndBlock(
return true;
}
+bool ExportedObject::UnexportMethodAndBlock(const std::string& interface_name,
+ const std::string& method_name) {
+ bus_->AssertOnDBusThread();
+
+ const std::string absolute_method_name =
+ GetAbsoluteMemberName(interface_name, method_name);
+ MethodTable::const_iterator iter = method_table_.find(absolute_method_name);
+ if (iter == method_table_.end()) {
+ LOG(ERROR) << absolute_method_name << " is not exported";
+ return false;
+ }
+
+ method_table_.erase(iter);
+
+ return true;
+}
+
void ExportedObject::ExportMethod(const std::string& interface_name,
const std::string& method_name,
MethodCallCallback method_call_callback,
@@ -83,6 +100,18 @@ void ExportedObject::ExportMethod(const std::string& interface_name,
bus_->GetDBusTaskRunner()->PostTask(FROM_HERE, task);
}
+void ExportedObject::UnexportMethod(
+ const std::string& interface_name,
+ const std::string& method_name,
+ OnUnexportedCallback on_unexported_calback) {
+ bus_->AssertOnOriginThread();
+
+ base::Closure task =
+ base::Bind(&ExportedObject::UnexportMethodInternal, this, interface_name,
+ method_name, on_unexported_calback);
+ bus_->GetDBusTaskRunner()->PostTask(FROM_HERE, task);
+}
+
void ExportedObject::SendSignal(Signal* signal) {
// For signals, the object path should be set to the path to the sender
// object, which is this exported object here.
@@ -141,6 +170,19 @@ void ExportedObject::ExportMethodInternal(
success));
}
+void ExportedObject::UnexportMethodInternal(
+ const std::string& interface_name,
+ const std::string& method_name,
+ OnUnexportedCallback on_unexported_calback) {
+ bus_->AssertOnDBusThread();
+
+ const bool success = UnexportMethodAndBlock(interface_name, method_name);
+ bus_->GetOriginTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ExportedObject::OnUnexported, this, on_unexported_calback,
+ interface_name, method_name, success));
+}
+
void ExportedObject::OnExported(OnExportedCallback on_exported_callback,
const std::string& interface_name,
const std::string& method_name,
@@ -150,6 +192,15 @@ void ExportedObject::OnExported(OnExportedCallback on_exported_callback,
on_exported_callback.Run(interface_name, method_name, success);
}
+void ExportedObject::OnUnexported(OnExportedCallback on_unexported_callback,
+ const std::string& interface_name,
+ const std::string& method_name,
+ bool success) {
+ bus_->AssertOnOriginThread();
+
+ on_unexported_callback.Run(interface_name, method_name, success);
+}
+
void ExportedObject::SendSignalInternal(base::TimeTicks start_time,
DBusMessage* signal_message) {
uint32_t serial = 0;
diff --git a/chromium/dbus/exported_object.h b/chromium/dbus/exported_object.h
index 69a63a5e075..d314083430e 100644
--- a/chromium/dbus/exported_object.h
+++ b/chromium/dbus/exported_object.h
@@ -60,6 +60,13 @@ class CHROME_DBUS_EXPORT ExportedObject
bool success)>
OnExportedCallback;
+ // Called when method unexporting is done.
+ // |success| indicates whether unexporting was successful or not.
+ typedef base::Callback<void(const std::string& interface_name,
+ const std::string& method_name,
+ bool success)>
+ OnUnexportedCallback;
+
// Exports the method specified by |interface_name| and |method_name|,
// and blocks until exporting is done. Returns true on success.
//
@@ -81,6 +88,11 @@ class CHROME_DBUS_EXPORT ExportedObject
const std::string& method_name,
MethodCallCallback method_call_callback);
+ // Unexports the method specified by |interface_name| and |method_name|,
+ // and blocks until unexporting is done. Returns true on success.
+ virtual bool UnexportMethodAndBlock(const std::string& interface_name,
+ const std::string& method_name);
+
// Requests to export the method specified by |interface_name| and
// |method_name|. See Also ExportMethodAndBlock().
//
@@ -93,6 +105,17 @@ class CHROME_DBUS_EXPORT ExportedObject
MethodCallCallback method_call_callback,
OnExportedCallback on_exported_callback);
+ // Requests to unexport the method specified by |interface_name| and
+ // |method_name|. See also UnexportMethodAndBlock().
+ //
+ // |on_unexported_callback| is called when the method is unexported or
+ // failed to be unexported, in the origin thread.
+ //
+ // Must be called in the origin thread.
+ virtual void UnexportMethod(const std::string& interface_name,
+ const std::string& method_name,
+ OnUnexportedCallback on_unexported_callback);
+
// Requests to send the signal from this object. The signal will be sent
// synchronously if this method is called from the message loop in the D-Bus
// thread and asynchronously otherwise.
@@ -117,12 +140,23 @@ class CHROME_DBUS_EXPORT ExportedObject
MethodCallCallback method_call_callback,
OnExportedCallback exported_callback);
+ // Helper function for UnexportMethod().
+ void UnexportMethodInternal(const std::string& interface_name,
+ const std::string& method_name,
+ OnUnexportedCallback unexported_callback);
+
// Called when the object is exported.
void OnExported(OnExportedCallback on_exported_callback,
const std::string& interface_name,
const std::string& method_name,
bool success);
+ // Called when a method is unexported.
+ void OnUnexported(OnExportedCallback on_unexported_callback,
+ const std::string& interface_name,
+ const std::string& method_name,
+ bool success);
+
// Helper function for SendSignal().
void SendSignalInternal(base::TimeTicks start_time,
DBusMessage* signal_message);
diff --git a/chromium/dbus/mock_exported_object.h b/chromium/dbus/mock_exported_object.h
index 99c363f9b53..9d5b3a89417 100644
--- a/chromium/dbus/mock_exported_object.h
+++ b/chromium/dbus/mock_exported_object.h
@@ -28,6 +28,13 @@ class MockExportedObject : public ExportedObject {
const std::string& method_name,
MethodCallCallback method_call_callback,
OnExportedCallback on_exported_callback));
+ MOCK_METHOD2(UnexportMethodAndBlock,
+ bool(const std::string& interface_name,
+ const std::string& method_name));
+ MOCK_METHOD3(UnexportMethod,
+ void(const std::string& interface_name,
+ const std::string& method_name,
+ OnUnexportedCallback on_unexported_callback));
MOCK_METHOD1(SendSignal, void(Signal* signal));
MOCK_METHOD0(Unregister, void());
diff --git a/chromium/dbus/property_unittest.cc b/chromium/dbus/property_unittest.cc
index 2368fa05bc5..9d4b447f3a6 100644
--- a/chromium/dbus/property_unittest.cc
+++ b/chromium/dbus/property_unittest.cc
@@ -13,9 +13,9 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
@@ -338,7 +338,7 @@ TEST(PropertyTestStatic, ReadWriteStringMap) {
writer.OpenVariant("a{ss}", &variant_writer);
variant_writer.OpenArray("{ss}", &variant_array_writer);
const char* items[] = {"One", "Two", "Three", "Four"};
- for (unsigned i = 0; i < arraysize(items); ++i) {
+ for (unsigned i = 0; i < base::size(items); ++i) {
variant_array_writer.OpenDictEntry(&struct_entry_writer);
struct_entry_writer.AppendString(items[i]);
struct_entry_writer.AppendString(base::UintToString(i + 1));
@@ -388,7 +388,7 @@ TEST(PropertyTestStatic, ReadWriteNetAddressArray) {
for (uint16_t i = 0; i < 5; ++i) {
variant_array_writer.OpenStruct(&struct_entry_writer);
ip_bytes[4] = 0x30 + i;
- struct_entry_writer.AppendArrayOfBytes(ip_bytes, arraysize(ip_bytes));
+ struct_entry_writer.AppendArrayOfBytes(ip_bytes, base::size(ip_bytes));
struct_entry_writer.AppendUint16(i);
variant_array_writer.CloseContainer(&struct_entry_writer);
}
@@ -416,7 +416,7 @@ TEST(PropertyTestStatic, SerializeNetAddressArray) {
uint8_t ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30};
for (uint16_t i = 0; i < 5; ++i) {
ip_bytes[4] = 0x30 + i;
- std::vector<uint8_t> bytes(ip_bytes, ip_bytes + arraysize(ip_bytes));
+ std::vector<uint8_t> bytes(ip_bytes, ip_bytes + base::size(ip_bytes));
test_list.push_back(make_pair(bytes, 16));
}
@@ -443,7 +443,7 @@ TEST(PropertyTestStatic, ReadWriteStringToByteVectorMap) {
const char* keys[] = {"One", "Two", "Three", "Four"};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < arraysize(keys); ++i) {
+ for (unsigned i = 0; i < base::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -464,8 +464,8 @@ TEST(PropertyTestStatic, ReadWriteStringToByteVectorMap) {
Property<std::map<std::string, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(arraysize(keys), test_property.value().size());
- for (unsigned i = 0; i < arraysize(keys); ++i)
+ ASSERT_EQ(base::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < base::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
@@ -498,7 +498,7 @@ TEST(PropertyTestStatic, ReadWriteUInt16ToByteVectorMap) {
const uint16_t keys[] = {11, 12, 13, 14};
const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
- for (unsigned i = 0; i < arraysize(keys); ++i) {
+ for (unsigned i = 0; i < base::size(keys); ++i) {
MessageWriter entry_writer(nullptr);
dict_writer.OpenDictEntry(&entry_writer);
@@ -519,8 +519,8 @@ TEST(PropertyTestStatic, ReadWriteUInt16ToByteVectorMap) {
Property<std::map<uint16_t, std::vector<uint8_t>>> test_property;
EXPECT_TRUE(test_property.PopValueFromReader(&reader));
- ASSERT_EQ(arraysize(keys), test_property.value().size());
- for (unsigned i = 0; i < arraysize(keys); ++i)
+ ASSERT_EQ(base::size(keys), test_property.value().size());
+ for (unsigned i = 0; i < base::size(keys); ++i)
EXPECT_EQ(values[i], test_property.value().at(keys[i]));
}
diff --git a/chromium/dbus/values_util_unittest.cc b/chromium/dbus/values_util_unittest.cc
index 5a0b81e9f9b..7ced1c60e01 100644
--- a/chromium/dbus/values_util_unittest.cc
+++ b/chromium/dbus/values_util_unittest.cc
@@ -13,7 +13,7 @@
#include <vector>
#include "base/json/json_writer.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/values.h"
#include "dbus/message.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -352,7 +352,7 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) {
TEST(ValuesUtilTest, PopDoubleToIntDictionary) {
// Create test data.
const int32_t kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
- const std::vector<int32_t> values(kValues, kValues + arraysize(kValues));
+ const std::vector<int32_t> values(kValues, kValues + base::size(kValues));
std::vector<double> keys(values.size());
for (size_t i = 0; i != values.size(); ++i)
keys[i] = std::sqrt(values[i]);