diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-25 11:39:07 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-01-25 15:20:42 +0000 |
commit | 6c91641271e536ffaa88a1dff5127e42ee99a91e (patch) | |
tree | 703d9dd49602377ddc90cbf886aad37913f2496b /chromium/dbus | |
parent | b145b7fafd36f0c260d6a768c81fc14e32578099 (diff) | |
download | qtwebengine-chromium-6c91641271e536ffaa88a1dff5127e42ee99a91e.tar.gz |
BASELINE: Update Chromium to 49.0.2623.23
Also adds missing printing sources.
Change-Id: I3726b8f0c7d6751c9fc846096c571fadca7108cd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/dbus')
33 files changed, 405 insertions, 376 deletions
diff --git a/chromium/dbus/BUILD.gn b/chromium/dbus/BUILD.gn index ee154a85ad8..dbeee0c1dda 100644 --- a/chromium/dbus/BUILD.gn +++ b/chromium/dbus/BUILD.gn @@ -90,7 +90,6 @@ test("dbus_unittests") { "object_manager_unittest.cc", "object_proxy_unittest.cc", "property_unittest.cc", - "run_all_unittests.cc", "signal_sender_verification_unittest.cc", "string_util_unittest.cc", "test_service.cc", @@ -103,6 +102,7 @@ test("dbus_unittests") { ":dbus", ":test_proto", ":test_support", + "//base/test:run_all_unittests", "//base/test:test_support", "//testing/gmock", "//testing/gtest", diff --git a/chromium/dbus/bus.cc b/chromium/dbus/bus.cc index 3a4fe219f74..554ccb829d1 100644 --- a/chromium/dbus/bus.cc +++ b/chromium/dbus/bus.cc @@ -4,6 +4,8 @@ #include "dbus/bus.h" +#include <stddef.h> + #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -678,7 +680,7 @@ void Bus::SendWithReply(DBusMessage* request, CHECK(success) << "Unable to allocate memory"; } -void Bus::Send(DBusMessage* request, uint32* serial) { +void Bus::Send(DBusMessage* request, uint32_t* serial) { DCHECK(connection_); AssertOnDBusThread(); diff --git a/chromium/dbus/bus.h b/chromium/dbus/bus.h index 27d149c4791..e5e0b1c6a99 100644 --- a/chromium/dbus/bus.h +++ b/chromium/dbus/bus.h @@ -6,6 +6,7 @@ #define DBUS_BUS_H_ #include <dbus/dbus.h> +#include <stdint.h> #include <map> #include <set> @@ -14,6 +15,7 @@ #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" @@ -462,7 +464,7 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { // be stored in |serial|. // // BLOCKING CALL. - virtual void Send(DBusMessage* request, uint32* serial); + virtual void Send(DBusMessage* request, uint32_t* serial); // Adds the message filter function. |filter_function| will be called // when incoming messages are received. diff --git a/chromium/dbus/bus_unittest.cc b/chromium/dbus/bus_unittest.cc index 27d9bb2e3e0..250717ecee1 100644 --- a/chromium/dbus/bus_unittest.cc +++ b/chromium/dbus/bus_unittest.cc @@ -5,6 +5,7 @@ #include "dbus/bus.h" #include "base/bind.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" diff --git a/chromium/dbus/dbus.gyp b/chromium/dbus/dbus.gyp index daac2e26a3e..264383ee4ba 100644 --- a/chromium/dbus/dbus.gyp +++ b/chromium/dbus/dbus.gyp @@ -89,6 +89,7 @@ 'target_name': 'dbus_unittests', 'type': 'executable', 'dependencies': [ + '../base/base.gyp:run_all_unittests', '../base/base.gyp:test_support_base', '../build/linux/system.gyp:dbus', '../testing/gmock.gyp:gmock', @@ -107,7 +108,6 @@ 'object_manager_unittest.cc', 'object_proxy_unittest.cc', 'property_unittest.cc', - 'run_all_unittests.cc', 'signal_sender_verification_unittest.cc', 'string_util_unittest.cc', 'test_service.cc', diff --git a/chromium/dbus/dbus_statistics.cc b/chromium/dbus/dbus_statistics.cc index 9abec65e3de..e6eb5a2f5b5 100644 --- a/chromium/dbus/dbus_statistics.cc +++ b/chromium/dbus/dbus_statistics.cc @@ -7,6 +7,7 @@ #include <set> #include "base/logging.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" diff --git a/chromium/dbus/dbus_statistics_unittest.cc b/chromium/dbus/dbus_statistics_unittest.cc index 6260a63ebe9..e39b9b529b0 100644 --- a/chromium/dbus/dbus_statistics_unittest.cc +++ b/chromium/dbus/dbus_statistics_unittest.cc @@ -4,8 +4,8 @@ #include "dbus/dbus_statistics.h" -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" namespace dbus { diff --git a/chromium/dbus/end_to_end_async_unittest.cc b/chromium/dbus/end_to_end_async_unittest.cc index 3854721f257..8f628649d6f 100644 --- a/chromium/dbus/end_to_end_async_unittest.cc +++ b/chromium/dbus/end_to_end_async_unittest.cc @@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> + #include <algorithm> #include <string> #include <vector> #include "base/bind.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -60,7 +63,7 @@ class EndToEndAsyncTest : public testing::Test { bus_options.dbus_task_runner = dbus_thread_->task_runner(); bus_ = new Bus(bus_options); object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); ASSERT_TRUE(bus_->HasDBusThread()); @@ -94,7 +97,7 @@ class EndToEndAsyncTest : public testing::Test { run_loop_->Run(); // Create a second object proxy for the root object. - root_object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", + root_object_proxy_ = bus_->GetObjectProxy(test_service_->service_name(), ObjectPath("/")); ASSERT_TRUE(bus_->HasDBusThread()); @@ -144,7 +147,7 @@ class EndToEndAsyncTest : public testing::Test { // Create new object proxy. object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); } @@ -432,7 +435,7 @@ TEST_F(EndToEndAsyncTest, CancelPendingCalls) { // Remove the object proxy before receiving the result. // This results in cancelling the pending method call. - bus_->RemoveObjectProxy("org.chromium.TestService", + bus_->RemoveObjectProxy(test_service_->service_name(), ObjectPath("/org/chromium/TestObject"), base::Bind(&base::DoNothing)); @@ -514,7 +517,7 @@ TEST_F(EndToEndAsyncTest, InvalidObjectPath) { const ObjectPath invalid_object_path("/org/chromium/TestObject/"); // Replace object proxy with new one. - object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", + object_proxy_ = bus_->GetObjectProxy(test_service_->service_name(), invalid_object_path); MethodCall method_call("org.chromium.TestInterface", "Echo"); diff --git a/chromium/dbus/end_to_end_sync_unittest.cc b/chromium/dbus/end_to_end_sync_unittest.cc index 1167d96650b..47dc9b1207f 100644 --- a/chromium/dbus/end_to_end_sync_unittest.cc +++ b/chromium/dbus/end_to_end_sync_unittest.cc @@ -35,7 +35,7 @@ class EndToEndSyncTest : public testing::Test { client_bus_options.connection_type = Bus::PRIVATE; client_bus_ = new Bus(client_bus_options); object_proxy_ = client_bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); ASSERT_FALSE(client_bus_->HasDBusThread()); } @@ -112,7 +112,7 @@ TEST_F(EndToEndSyncTest, InvalidObjectPath) { const ObjectPath invalid_object_path("/org/chromium/TestObject/"); // Replace object proxy with new one. - object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService", + object_proxy_ = client_bus_->GetObjectProxy(test_service_->service_name(), invalid_object_path); MethodCall method_call("org.chromium.TestInterface", "Echo"); diff --git a/chromium/dbus/exported_object.cc b/chromium/dbus/exported_object.cc index 669b871e35b..e4cd1a4219f 100644 --- a/chromium/dbus/exported_object.cc +++ b/chromium/dbus/exported_object.cc @@ -4,6 +4,9 @@ #include "dbus/exported_object.h" +#include <stdint.h> +#include <utility> + #include "base/bind.h" #include "base/logging.h" #include "base/memory/ref_counted.h" @@ -148,7 +151,7 @@ void ExportedObject::OnExported(OnExportedCallback on_exported_callback, void ExportedObject::SendSignalInternal(base::TimeTicks start_time, DBusMessage* signal_message) { - uint32 serial = 0; + uint32_t serial = 0; bus_->Send(signal_message, &serial); dbus_message_unref(signal_message); // Record time spent to send the the signal. This is not accurate as the @@ -262,7 +265,7 @@ void ExportedObject::SendResponse(base::TimeTicks start_time, base::Passed(&response), start_time)); } else { - OnMethodCompleted(method_call.Pass(), response.Pass(), start_time); + OnMethodCompleted(std::move(method_call), std::move(response), start_time); } } diff --git a/chromium/dbus/file_descriptor.cc b/chromium/dbus/file_descriptor.cc index c740f280622..b690881749f 100644 --- a/chromium/dbus/file_descriptor.cc +++ b/chromium/dbus/file_descriptor.cc @@ -21,9 +21,8 @@ void CHROME_DBUS_EXPORT FileDescriptor::Deleter::operator()( FROM_HERE, base::Bind(&base::DeletePointer<FileDescriptor>, fd), false); } -FileDescriptor::FileDescriptor(RValue other) - : value_(-1), owner_(false), valid_(false) { - Swap(other.object); +FileDescriptor::FileDescriptor(FileDescriptor&& other) : FileDescriptor() { + Swap(&other); } FileDescriptor::~FileDescriptor() { @@ -31,8 +30,8 @@ FileDescriptor::~FileDescriptor() { base::File auto_closer(value_); } -FileDescriptor& FileDescriptor::operator=(RValue other) { - Swap(other.object); +FileDescriptor& FileDescriptor::operator=(FileDescriptor&& other) { + Swap(&other); return *this; } diff --git a/chromium/dbus/file_descriptor.h b/chromium/dbus/file_descriptor.h index 8a4109789ec..b4f95cb593c 100644 --- a/chromium/dbus/file_descriptor.h +++ b/chromium/dbus/file_descriptor.h @@ -5,7 +5,6 @@ #ifndef DBUS_FILE_DESCRIPTOR_H_ #define DBUS_FILE_DESCRIPTOR_H_ -#include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/move.h" #include "dbus/dbus_export.h" @@ -34,7 +33,7 @@ namespace dbus { // also allows the caller to do this work on the File thread to conform // with i/o restrictions. class CHROME_DBUS_EXPORT FileDescriptor { - MOVE_ONLY_TYPE_FOR_CPP_03(FileDescriptor, RValue); + MOVE_ONLY_TYPE_FOR_CPP_03(FileDescriptor); public: // This provides a simple way to pass around file descriptors since they must @@ -49,13 +48,11 @@ class CHROME_DBUS_EXPORT FileDescriptor { explicit FileDescriptor(int value) : value_(value), owner_(false), valid_(false) {} - // Move constructor for C++03 move emulation of this type. - FileDescriptor(RValue other); + FileDescriptor(FileDescriptor&& other); virtual ~FileDescriptor(); - // Move operator= for C++03 move emulation of this type. - FileDescriptor& operator=(RValue other); + FileDescriptor& operator=(FileDescriptor&& other); // Retrieves value as an int without affecting ownership. int value() const; diff --git a/chromium/dbus/message.cc b/chromium/dbus/message.cc index 0bf76d425a8..8a58dbaa3bf 100644 --- a/chromium/dbus/message.cc +++ b/chromium/dbus/message.cc @@ -6,7 +6,6 @@ #include <string> -#include "base/basictypes.h" #include "base/format_macros.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" @@ -36,7 +35,7 @@ void AppendStringHeader(const std::string& header_name, // Appends the header name and the value to |output|, if the value is // nonzero. void AppendUint32Header(const std::string& header_name, - uint32 header_value, + uint32_t header_value, std::string* output) { if (header_value != 0) { *output += (header_name + ": " + base::UintToString(header_value) + "\n"); @@ -99,7 +98,7 @@ std::string Message::ToStringInternal(const std::string& indent, const DataType type = reader->GetDataType(); switch (type) { case BYTE: { - uint8 value = 0; + uint8_t value = 0; if (!reader->PopByte(&value)) return kBrokenMessage; output += indent + "byte " + base::UintToString(value) + "\n"; @@ -113,45 +112,45 @@ std::string Message::ToStringInternal(const std::string& indent, break; } case INT16: { - int16 value = 0; + int16_t value = 0; if (!reader->PopInt16(&value)) return kBrokenMessage; - output += indent + "int16 " + base::IntToString(value) + "\n"; + output += indent + "int16_t " + base::IntToString(value) + "\n"; break; } case UINT16: { - uint16 value = 0; + uint16_t value = 0; if (!reader->PopUint16(&value)) return kBrokenMessage; - output += indent + "uint16 " + base::UintToString(value) + "\n"; + output += indent + "uint16_t " + base::UintToString(value) + "\n"; break; } case INT32: { - int32 value = 0; + int32_t value = 0; if (!reader->PopInt32(&value)) return kBrokenMessage; - output += indent + "int32 " + base::IntToString(value) + "\n"; + output += indent + "int32_t " + base::IntToString(value) + "\n"; break; } case UINT32: { - uint32 value = 0; + uint32_t value = 0; if (!reader->PopUint32(&value)) return kBrokenMessage; - output += indent + "uint32 " + base::UintToString(value) + "\n"; + output += indent + "uint32_t " + base::UintToString(value) + "\n"; break; } case INT64: { - int64 value = 0; + int64_t value = 0; if (!reader->PopInt64(&value)) return kBrokenMessage; - output += (indent + "int64 " + base::Int64ToString(value) + "\n"); + output += (indent + "int64_t " + base::Int64ToString(value) + "\n"); break; } case UINT64: { - uint64 value = 0; + uint64_t value = 0; if (!reader->PopUint64(&value)) return kBrokenMessage; - output += (indent + "uint64 " + base::Uint64ToString(value) + "\n"); + output += (indent + "uint64_t " + base::Uint64ToString(value) + "\n"); break; } case DOUBLE: { @@ -294,11 +293,11 @@ bool Message::SetSender(const std::string& sender) { return dbus_message_set_sender(raw_message_, sender.c_str()); } -void Message::SetSerial(uint32 serial) { +void Message::SetSerial(uint32_t serial) { dbus_message_set_serial(raw_message_, serial); } -void Message::SetReplySerial(uint32 reply_serial) { +void Message::SetReplySerial(uint32_t reply_serial) { dbus_message_set_reply_serial(raw_message_, reply_serial); } @@ -337,11 +336,11 @@ std::string Message::GetSignature() { return signature ? signature : ""; } -uint32 Message::GetSerial() { +uint32_t Message::GetSerial() { return dbus_message_get_serial(raw_message_); } -uint32 Message::GetReplySerial() { +uint32_t Message::GetReplySerial() { return dbus_message_get_reply_serial(raw_message_); } @@ -405,19 +404,19 @@ scoped_ptr<Response> Response::FromRawMessage(DBusMessage* raw_message) { scoped_ptr<Response> response(new Response); response->Init(raw_message); - return response.Pass(); + return response; } scoped_ptr<Response> Response::FromMethodCall(MethodCall* method_call) { scoped_ptr<Response> response(new Response); response->Init(dbus_message_new_method_return(method_call->raw_message())); - return response.Pass(); + return response; } scoped_ptr<Response> Response::CreateEmpty() { scoped_ptr<Response> response(new Response); response->Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); - return response.Pass(); + return response; } // @@ -433,7 +432,7 @@ scoped_ptr<ErrorResponse> ErrorResponse::FromRawMessage( scoped_ptr<ErrorResponse> response(new ErrorResponse); response->Init(raw_message); - return response.Pass(); + return response; } scoped_ptr<ErrorResponse> ErrorResponse::FromMethodCall( @@ -444,7 +443,7 @@ scoped_ptr<ErrorResponse> ErrorResponse::FromMethodCall( response->Init(dbus_message_new_error(method_call->raw_message(), error_name.c_str(), error_message.c_str())); - return response.Pass(); + return response; } // @@ -462,7 +461,7 @@ MessageWriter::MessageWriter(Message* message) MessageWriter::~MessageWriter() { } -void MessageWriter::AppendByte(uint8 value) { +void MessageWriter::AppendByte(uint8_t value) { AppendBasic(DBUS_TYPE_BYTE, &value); } @@ -476,27 +475,27 @@ void MessageWriter::AppendBool(bool value) { AppendBasic(DBUS_TYPE_BOOLEAN, &dbus_value); } -void MessageWriter::AppendInt16(int16 value) { +void MessageWriter::AppendInt16(int16_t value) { AppendBasic(DBUS_TYPE_INT16, &value); } -void MessageWriter::AppendUint16(uint16 value) { +void MessageWriter::AppendUint16(uint16_t value) { AppendBasic(DBUS_TYPE_UINT16, &value); } -void MessageWriter::AppendInt32(int32 value) { +void MessageWriter::AppendInt32(int32_t value) { AppendBasic(DBUS_TYPE_INT32, &value); } -void MessageWriter::AppendUint32(uint32 value) { +void MessageWriter::AppendUint32(uint32_t value) { AppendBasic(DBUS_TYPE_UINT32, &value); } -void MessageWriter::AppendInt64(int64 value) { +void MessageWriter::AppendInt64(int64_t value) { AppendBasic(DBUS_TYPE_INT64, &value); } -void MessageWriter::AppendUint64(uint64 value) { +void MessageWriter::AppendUint64(uint64_t value) { AppendBasic(DBUS_TYPE_UINT64, &value); } @@ -587,7 +586,7 @@ void MessageWriter::CloseContainer(MessageWriter* writer) { container_is_open_ = false; } -void MessageWriter::AppendArrayOfBytes(const uint8* values, size_t length) { +void MessageWriter::AppendArrayOfBytes(const uint8_t* values, size_t length) { DCHECK(!container_is_open_); MessageWriter array_writer(message_); OpenArray("y", &array_writer); @@ -629,12 +628,12 @@ bool MessageWriter::AppendProtoAsArrayOfBytes( LOG(ERROR) << "Unable to serialize supplied protocol buffer"; return false; } - AppendArrayOfBytes(reinterpret_cast<const uint8*>(serialized_proto.data()), + AppendArrayOfBytes(reinterpret_cast<const uint8_t*>(serialized_proto.data()), serialized_proto.size()); return true; } -void MessageWriter::AppendVariantOfByte(uint8 value) { +void MessageWriter::AppendVariantOfByte(uint8_t value) { AppendVariantOfBasic(DBUS_TYPE_BYTE, &value); } @@ -644,27 +643,27 @@ void MessageWriter::AppendVariantOfBool(bool value) { AppendVariantOfBasic(DBUS_TYPE_BOOLEAN, &dbus_value); } -void MessageWriter::AppendVariantOfInt16(int16 value) { +void MessageWriter::AppendVariantOfInt16(int16_t value) { AppendVariantOfBasic(DBUS_TYPE_INT16, &value); } -void MessageWriter::AppendVariantOfUint16(uint16 value) { +void MessageWriter::AppendVariantOfUint16(uint16_t value) { AppendVariantOfBasic(DBUS_TYPE_UINT16, &value); } -void MessageWriter::AppendVariantOfInt32(int32 value) { +void MessageWriter::AppendVariantOfInt32(int32_t value) { AppendVariantOfBasic(DBUS_TYPE_INT32, &value); } -void MessageWriter::AppendVariantOfUint32(uint32 value) { +void MessageWriter::AppendVariantOfUint32(uint32_t value) { AppendVariantOfBasic(DBUS_TYPE_UINT32, &value); } -void MessageWriter::AppendVariantOfInt64(int64 value) { +void MessageWriter::AppendVariantOfInt64(int64_t value) { AppendVariantOfBasic(DBUS_TYPE_INT64, &value); } -void MessageWriter::AppendVariantOfUint64(uint64 value) { +void MessageWriter::AppendVariantOfUint64(uint64_t value) { AppendVariantOfBasic(DBUS_TYPE_UINT64, &value); } @@ -733,7 +732,7 @@ bool MessageReader::HasMoreData() { return dbus_type != DBUS_TYPE_INVALID; } -bool MessageReader::PopByte(uint8* value) { +bool MessageReader::PopByte(uint8_t* value) { return PopBasic(DBUS_TYPE_BYTE, value); } @@ -747,27 +746,27 @@ bool MessageReader::PopBool(bool* value) { return success; } -bool MessageReader::PopInt16(int16* value) { +bool MessageReader::PopInt16(int16_t* value) { return PopBasic(DBUS_TYPE_INT16, value); } -bool MessageReader::PopUint16(uint16* value) { +bool MessageReader::PopUint16(uint16_t* value) { return PopBasic(DBUS_TYPE_UINT16, value); } -bool MessageReader::PopInt32(int32* value) { +bool MessageReader::PopInt32(int32_t* value) { return PopBasic(DBUS_TYPE_INT32, value); } -bool MessageReader::PopUint32(uint32* value) { +bool MessageReader::PopUint32(uint32_t* value) { return PopBasic(DBUS_TYPE_UINT32, value); } -bool MessageReader::PopInt64(int64* value) { +bool MessageReader::PopInt64(int64_t* value) { return PopBasic(DBUS_TYPE_INT64, value); } -bool MessageReader::PopUint64(uint64* value) { +bool MessageReader::PopUint64(uint64_t* value) { return PopBasic(DBUS_TYPE_UINT64, value); } @@ -807,7 +806,7 @@ bool MessageReader::PopVariant(MessageReader* sub_reader) { return PopContainer(DBUS_TYPE_VARIANT, sub_reader); } -bool MessageReader::PopArrayOfBytes(const uint8** bytes, size_t* length) { +bool MessageReader::PopArrayOfBytes(const uint8_t** bytes, size_t* length) { MessageReader array_reader(message_); if (!PopArray(&array_reader)) return false; @@ -862,8 +861,8 @@ bool MessageReader::PopArrayOfBytesAsProto( DCHECK(protobuf != NULL); const char* serialized_buf = NULL; size_t buf_size = 0; - if (!PopArrayOfBytes( - reinterpret_cast<const uint8**>(&serialized_buf), &buf_size)) { + if (!PopArrayOfBytes(reinterpret_cast<const uint8_t**>(&serialized_buf), + &buf_size)) { LOG(ERROR) << "Error reading array of bytes"; return false; } @@ -874,7 +873,7 @@ bool MessageReader::PopArrayOfBytesAsProto( return true; } -bool MessageReader::PopVariantOfByte(uint8* value) { +bool MessageReader::PopVariantOfByte(uint8_t* value) { return PopVariantOfBasic(DBUS_TYPE_BYTE, value); } @@ -886,27 +885,27 @@ bool MessageReader::PopVariantOfBool(bool* value) { return success; } -bool MessageReader::PopVariantOfInt16(int16* value) { +bool MessageReader::PopVariantOfInt16(int16_t* value) { return PopVariantOfBasic(DBUS_TYPE_INT16, value); } -bool MessageReader::PopVariantOfUint16(uint16* value) { +bool MessageReader::PopVariantOfUint16(uint16_t* value) { return PopVariantOfBasic(DBUS_TYPE_UINT16, value); } -bool MessageReader::PopVariantOfInt32(int32* value) { +bool MessageReader::PopVariantOfInt32(int32_t* value) { return PopVariantOfBasic(DBUS_TYPE_INT32, value); } -bool MessageReader::PopVariantOfUint32(uint32* value) { +bool MessageReader::PopVariantOfUint32(uint32_t* value) { return PopVariantOfBasic(DBUS_TYPE_UINT32, value); } -bool MessageReader::PopVariantOfInt64(int64* value) { +bool MessageReader::PopVariantOfInt64(int64_t* value) { return PopVariantOfBasic(DBUS_TYPE_INT64, value); } -bool MessageReader::PopVariantOfUint64(uint64* value) { +bool MessageReader::PopVariantOfUint64(uint64_t* value) { return PopVariantOfBasic(DBUS_TYPE_UINT64, value); } diff --git a/chromium/dbus/message.h b/chromium/dbus/message.h index 780e6c5b466..7dffe0e0f60 100644 --- a/chromium/dbus/message.h +++ b/chromium/dbus/message.h @@ -5,11 +5,13 @@ #ifndef DBUS_MESSAGE_H_ #define DBUS_MESSAGE_H_ +#include <dbus/dbus.h> +#include <stddef.h> +#include <stdint.h> #include <string> #include <vector> -#include <dbus/dbus.h> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "dbus/dbus_export.h" #include "dbus/file_descriptor.h" @@ -99,8 +101,8 @@ class CHROME_DBUS_EXPORT Message { bool SetMember(const std::string& member); bool SetErrorName(const std::string& error_name); bool SetSender(const std::string& sender); - void SetSerial(uint32 serial); - void SetReplySerial(uint32 reply_serial); + void SetSerial(uint32_t serial); + void SetReplySerial(uint32_t reply_serial); // SetSignature() does not exist as we cannot do it. // Gets the destination, the path, the interface, the member, etc. @@ -113,8 +115,8 @@ class CHROME_DBUS_EXPORT Message { std::string GetSender(); std::string GetSignature(); // Gets the serial and reply serial numbers. Returns 0 if not set. - uint32 GetSerial(); - uint32 GetReplySerial(); + uint32_t GetSerial(); + uint32_t GetReplySerial(); // Returns the string representation of this message. Useful for // debugging. The output is truncated as needed (ex. strings are truncated @@ -270,14 +272,14 @@ class CHROME_DBUS_EXPORT MessageWriter { ~MessageWriter(); // Appends a byte to the message. - void AppendByte(uint8 value); + void AppendByte(uint8_t value); void AppendBool(bool value); - void AppendInt16(int16 value); - void AppendUint16(uint16 value); - void AppendInt32(int32 value); - void AppendUint32(uint32 value); - void AppendInt64(int64 value); - void AppendUint64(uint64 value); + void AppendInt16(int16_t value); + void AppendUint16(uint16_t value); + void AppendInt32(int32_t value); + void AppendUint32(uint32_t value); + void AppendInt64(int64_t value); + void AppendUint64(uint64_t value); void AppendDouble(double value); void AppendString(const std::string& value); void AppendObjectPath(const ObjectPath& value); @@ -308,7 +310,7 @@ class CHROME_DBUS_EXPORT MessageWriter { // Appends the array of bytes. Arrays of bytes are often used for // exchanging binary blobs hence it's worth having a specialized // function. - void AppendArrayOfBytes(const uint8* values, size_t length); + void AppendArrayOfBytes(const uint8_t* values, size_t length); // Appends the array of strings. Arrays of strings are often used for // exchanging lists of names hence it's worth having a specialized @@ -332,14 +334,14 @@ class CHROME_DBUS_EXPORT MessageWriter { // widely used in D-Bus services so it's worth having a specialized // function. For instance, The third parameter of // "org.freedesktop.DBus.Properties.Set" is a variant. - void AppendVariantOfByte(uint8 value); + void AppendVariantOfByte(uint8_t value); void AppendVariantOfBool(bool value); - void AppendVariantOfInt16(int16 value); - void AppendVariantOfUint16(uint16 value); - void AppendVariantOfInt32(int32 value); - void AppendVariantOfUint32(uint32 value); - void AppendVariantOfInt64(int64 value); - void AppendVariantOfUint64(uint64 value); + void AppendVariantOfInt16(int16_t value); + void AppendVariantOfUint16(uint16_t value); + void AppendVariantOfInt32(int32_t value); + void AppendVariantOfUint32(uint32_t value); + void AppendVariantOfInt64(int64_t value); + void AppendVariantOfUint64(uint64_t value); void AppendVariantOfDouble(double value); void AppendVariantOfString(const std::string& value); void AppendVariantOfObjectPath(const ObjectPath& value); @@ -380,14 +382,14 @@ class CHROME_DBUS_EXPORT MessageReader { // Gets the byte at the current iterator position. // Returns true and advances the iterator on success. // Returns false if the data type is not a byte. - bool PopByte(uint8* value); + bool PopByte(uint8_t* value); bool PopBool(bool* value); - bool PopInt16(int16* value); - bool PopUint16(uint16* value); - bool PopInt32(int32* value); - bool PopUint32(uint32* value); - bool PopInt64(int64* value); - bool PopUint64(uint64* value); + bool PopInt16(int16_t* value); + bool PopUint16(uint16_t* value); + bool PopInt32(int32_t* value); + bool PopUint32(uint32_t* value); + bool PopInt64(int64_t* value); + bool PopUint64(uint64_t* value); bool PopDouble(double* value); bool PopString(std::string* value); bool PopObjectPath(ObjectPath* value); @@ -411,7 +413,7 @@ class CHROME_DBUS_EXPORT MessageReader { // Ownership of the memory pointed to by |bytes| remains with the // MessageReader; |bytes| must be copied if the contents will be referenced // after the MessageReader is destroyed. - bool PopArrayOfBytes(const uint8** bytes, size_t* length); + bool PopArrayOfBytes(const uint8_t** bytes, size_t* length); // Gets the array of strings at the current iterator position. |strings| is // cleared before being modified. Returns true and advances the iterator on @@ -446,14 +448,14 @@ class CHROME_DBUS_EXPORT MessageReader { // Variants are widely used in D-Bus services so it's worth having a // specialized function. For instance, The return value type of // "org.freedesktop.DBus.Properties.Get" is a variant. - bool PopVariantOfByte(uint8* value); + bool PopVariantOfByte(uint8_t* value); bool PopVariantOfBool(bool* value); - bool PopVariantOfInt16(int16* value); - bool PopVariantOfUint16(uint16* value); - bool PopVariantOfInt32(int32* value); - bool PopVariantOfUint32(uint32* value); - bool PopVariantOfInt64(int64* value); - bool PopVariantOfUint64(uint64* value); + bool PopVariantOfInt16(int16_t* value); + bool PopVariantOfUint16(uint16_t* value); + bool PopVariantOfInt32(int32_t* value); + bool PopVariantOfUint32(uint32_t* value); + bool PopVariantOfInt64(int64_t* value); + bool PopVariantOfUint64(uint64_t* value); bool PopVariantOfDouble(double* value); bool PopVariantOfString(std::string* value); bool PopVariantOfObjectPath(ObjectPath* value); diff --git a/chromium/dbus/message_unittest.cc b/chromium/dbus/message_unittest.cc index 2c13d08c6b9..efe54005530 100644 --- a/chromium/dbus/message_unittest.cc +++ b/chromium/dbus/message_unittest.cc @@ -4,9 +4,9 @@ #include "dbus/message.h" +#include <stddef.h> #include <stdint.h> -#include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/posix/eintr_wrapper.h" @@ -32,7 +32,7 @@ TEST(MessageTest, AppendAndPopByte) { // Should fail as the type is not bool here. ASSERT_FALSE(reader.PopBool(&bool_value)); - uint8 byte_value = 0; + uint8_t byte_value = 0; ASSERT_TRUE(reader.PopByte(&byte_value)); EXPECT_EQ(123, byte_value); // Should match with the input. ASSERT_FALSE(reader.HasMoreData()); // Should not have more data to read. @@ -59,14 +59,14 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) { writer.AppendString("string"); writer.AppendObjectPath(ObjectPath("/object/path")); - uint8 byte_value = 0; + uint8_t byte_value = 0; bool bool_value = false; - int16 int16_value = 0; - uint16 uint16_value = 0; - int32 int32_value = 0; - uint32 uint32_value = 0; - int64 int64_value = 0; - uint64 uint64_value = 0; + int16_t int16_value = 0; + uint16_t uint16_value = 0; + int32_t int32_value = 0; + uint32_t uint32_value = 0; + int64_t int64_value = 0; + uint64_t uint64_value = 0; double double_value = 0; std::string string_value; ObjectPath object_path_value; @@ -174,14 +174,14 @@ TEST(MessageTest, AppendAndPopVariantDataTypes) { writer.AppendVariantOfString("string"); writer.AppendVariantOfObjectPath(ObjectPath("/object/path")); - uint8 byte_value = 0; + uint8_t byte_value = 0; bool bool_value = false; - int16 int16_value = 0; - uint16 uint16_value = 0; - int32 int32_value = 0; - uint32 uint32_value = 0; - int64 int64_value = 0; - uint64 uint64_value = 0; + int16_t int16_value = 0; + uint16_t uint16_value = 0; + int32_t int32_value = 0; + uint32_t uint32_value = 0; + int64_t int64_value = 0; + uint64_t uint64_value = 0; double double_value = 0; std::string string_value; ObjectPath object_path_value; @@ -230,14 +230,14 @@ TEST(MessageTest, AppendAndPopVariantDataTypes) { TEST(MessageTest, ArrayOfBytes) { scoped_ptr<Response> message(Response::CreateEmpty()); MessageWriter writer(message.get()); - std::vector<uint8> bytes; + std::vector<uint8_t> bytes; bytes.push_back(1); bytes.push_back(2); bytes.push_back(3); writer.AppendArrayOfBytes(bytes.data(), bytes.size()); MessageReader reader(message.get()); - const uint8* output_bytes = NULL; + const uint8_t* output_bytes = NULL; size_t length = 0; ASSERT_EQ("ay", reader.GetDataSignature()); ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); @@ -251,11 +251,11 @@ TEST(MessageTest, ArrayOfBytes) { TEST(MessageTest, ArrayOfBytes_Empty) { scoped_ptr<Response> message(Response::CreateEmpty()); MessageWriter writer(message.get()); - std::vector<uint8> bytes; + std::vector<uint8_t> bytes; writer.AppendArrayOfBytes(bytes.data(), bytes.size()); MessageReader reader(message.get()); - const uint8* output_bytes = NULL; + const uint8_t* output_bytes = NULL; size_t length = 0; ASSERT_EQ("ay", reader.GetDataSignature()); ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); @@ -376,7 +376,7 @@ TEST(MessageTest, CreateComplexMessageAndReadIt) { // The second value in the array. { MessageWriter variant_writer(NULL); - // Open a variant of a struct that contains a string and an int32. + // Open a variant of a struct that contains a string and an int32_t. array_writer.OpenVariant("(si)", &variant_writer); { MessageWriter struct_writer(NULL); @@ -391,14 +391,14 @@ TEST(MessageTest, CreateComplexMessageAndReadIt) { // The third value in the array. { MessageWriter variant_writer(NULL); - // Open a variant of an array of string-to-int64 dict entries. + // Open a variant of an array of string-to-int64_t dict entries. array_writer.OpenVariant("a{sx}", &variant_writer); { - // Opens an array of string-to-int64 dict entries. + // Opens an array of string-to-int64_t dict entries. MessageWriter dict_array_writer(NULL); variant_writer.OpenArray("{sx}", &dict_array_writer); { - // Opens a string-to-int64 dict entries. + // Opens a string-to-int64_t dict entries. MessageWriter dict_entry_writer(NULL); dict_array_writer.OpenDictEntry(&dict_entry_writer); dict_entry_writer.AppendString("foo"); @@ -413,23 +413,24 @@ TEST(MessageTest, CreateComplexMessageAndReadIt) { writer.CloseContainer(&array_writer); } // What we have created looks like this: - EXPECT_EQ("message_type: MESSAGE_METHOD_RETURN\n" - "signature: av\n" - "\n" - "array [\n" - " variant bool true\n" - " variant struct {\n" - " string \"string\"\n" - " int32 123\n" - " }\n" - " variant array [\n" - " dict entry {\n" - " string \"foo\"\n" - " int64 1234567890123456789\n" - " }\n" - " ]\n" - "]\n", - message->ToString()); + EXPECT_EQ( + "message_type: MESSAGE_METHOD_RETURN\n" + "signature: av\n" + "\n" + "array [\n" + " variant bool true\n" + " variant struct {\n" + " string \"string\"\n" + " int32_t 123\n" + " }\n" + " variant array [\n" + " dict entry {\n" + " string \"foo\"\n" + " int64_t 1234567890123456789\n" + " }\n" + " ]\n" + "]\n", + message->ToString()); MessageReader reader(message.get()); ASSERT_EQ("av", reader.GetDataSignature()); @@ -453,7 +454,7 @@ TEST(MessageTest, CreateComplexMessageAndReadIt) { std::string string_value; ASSERT_TRUE(struct_reader.PopString(&string_value)); EXPECT_EQ("string", string_value); - int32 int32_value = 0; + int32_t int32_value = 0; ASSERT_TRUE(struct_reader.PopInt32(&int32_value)); EXPECT_EQ(123, int32_value); ASSERT_FALSE(struct_reader.HasMoreData()); @@ -475,7 +476,7 @@ TEST(MessageTest, CreateComplexMessageAndReadIt) { std::string string_value; ASSERT_TRUE(dict_entry_reader.PopString(&string_value)); EXPECT_EQ("foo", string_value); - int64 int64_value = 0; + int64_t int64_value = 0; ASSERT_TRUE(dict_entry_reader.PopInt64(&int64_value)); EXPECT_EQ(INT64_C(1234567890123456789), int64_value); } @@ -557,7 +558,7 @@ TEST(MessageTest, Response) { } TEST(MessageTest, Response_FromMethodCall) { - const uint32 kSerial = 123; + const uint32_t kSerial = 123; MethodCall method_call("com.example.Interface", "SomeMethod"); method_call.SetSerial(kSerial); @@ -570,7 +571,7 @@ TEST(MessageTest, Response_FromMethodCall) { } TEST(MessageTest, ErrorResponse_FromMethodCall) { - const uint32 kSerial = 123; + const uint32_t kSerial = 123; const char kErrorMessage[] = "error message"; MethodCall method_call("com.example.Interface", "SomeMethod"); diff --git a/chromium/dbus/mock_bus.h b/chromium/dbus/mock_bus.h index 60000672e11..40b090b1567 100644 --- a/chromium/dbus/mock_bus.h +++ b/chromium/dbus/mock_bus.h @@ -5,6 +5,8 @@ #ifndef DBUS_MOCK_BUS_H_ #define DBUS_MOCK_BUS_H_ +#include <stdint.h> + #include "dbus/bus.h" #include "dbus/object_path.h" #include "testing/gmock/include/gmock/gmock.h" @@ -45,8 +47,7 @@ class MockBus : public Bus { MOCK_METHOD3(SendWithReply, void(DBusMessage* request, DBusPendingCall** pending_call, int timeout_ms)); - MOCK_METHOD2(Send, void(DBusMessage* request, - uint32* serial)); + MOCK_METHOD2(Send, void(DBusMessage* request, uint32_t* serial)); MOCK_METHOD2(AddFilter, void(DBusHandleMessageFunction handle_message, void* user_data)); MOCK_METHOD2(RemoveFilter, void(DBusHandleMessageFunction handle_message, diff --git a/chromium/dbus/object_manager.cc b/chromium/dbus/object_manager.cc index 3f253fa5083..9215d84ecf0 100644 --- a/chromium/dbus/object_manager.cc +++ b/chromium/dbus/object_manager.cc @@ -4,6 +4,8 @@ #include "dbus/object_manager.h" +#include <stddef.h> + #include "base/bind.h" #include "base/location.h" #include "base/logging.h" diff --git a/chromium/dbus/object_manager.h b/chromium/dbus/object_manager.h index 23a88cdc893..266b53eb9a0 100644 --- a/chromium/dbus/object_manager.h +++ b/chromium/dbus/object_manager.h @@ -5,8 +5,11 @@ #ifndef DBUS_OBJECT_MANAGER_H_ #define DBUS_OBJECT_MANAGER_H_ +#include <stdint.h> + #include <map> +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "dbus/object_path.h" @@ -36,7 +39,7 @@ // public: // struct Properties : public dbus::PropertySet { // dbus::Property<std::string> name; -// dbus::Property<uint16> version; +// dbus::Property<uint16_t> version; // dbus::Property<dbus::ObjectPath> parent; // dbus::Property<std::vector<std::string> > children; // diff --git a/chromium/dbus/object_manager_unittest.cc b/chromium/dbus/object_manager_unittest.cc index 34f7ac40853..443210c98e2 100644 --- a/chromium/dbus/object_manager_unittest.cc +++ b/chromium/dbus/object_manager_unittest.cc @@ -4,10 +4,12 @@ #include "dbus/object_manager.h" +#include <stddef.h> +#include <stdint.h> + #include <string> #include <vector> -#include "base/basictypes.h" #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -33,7 +35,7 @@ class ObjectManagerTest struct Properties : public PropertySet { Property<std::string> name; - Property<int16> version; + Property<int16_t> version; Property<std::vector<std::string> > methods; Property<std::vector<ObjectPath> > objects; @@ -85,7 +87,7 @@ class ObjectManagerTest ASSERT_TRUE(bus_->HasDBusThread()); object_manager_ = bus_->GetObjectManager( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestService")); object_manager_->RegisterInterface("org.chromium.TestInterface", this); @@ -187,7 +189,7 @@ class ObjectManagerTest void PerformAction(const std::string& action, const ObjectPath& object_path) { ObjectProxy* object_proxy = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); MethodCall method_call("org.chromium.TestInterface", "PerformAction"); @@ -286,7 +288,7 @@ TEST_F(ObjectManagerTest, GetObjectsWithUnknownInterface) { TEST_F(ObjectManagerTest, SameObject) { ObjectManager* object_manager = bus_->GetObjectManager( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestService")); EXPECT_EQ(object_manager_, object_manager); } @@ -300,7 +302,7 @@ TEST_F(ObjectManagerTest, DifferentObjectForService) { TEST_F(ObjectManagerTest, DifferentObjectForPath) { ObjectManager* object_manager = bus_->GetObjectManager( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/DifferentService")); EXPECT_NE(object_manager_, object_manager); } @@ -385,7 +387,7 @@ TEST_F(ObjectManagerTest, PropertiesChangedAsObjectsReceived) { object_manager_->UnregisterInterface("org.chromium.TestInterface"); run_loop_.reset(new base::RunLoop); EXPECT_TRUE(bus_->RemoveObjectManager( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestService"), run_loop_->QuitClosure())); run_loop_->Run(); @@ -394,7 +396,7 @@ TEST_F(ObjectManagerTest, PropertiesChangedAsObjectsReceived) { ObjectPath("/org/chromium/TestService")); object_manager_ = bus_->GetObjectManager( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestService")); object_manager_->RegisterInterface("org.chromium.TestInterface", this); diff --git a/chromium/dbus/object_proxy.cc b/chromium/dbus/object_proxy.cc index 441dc757bd7..e7d1f22f162 100644 --- a/chromium/dbus/object_proxy.cc +++ b/chromium/dbus/object_proxy.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "dbus/bus.h" +#include "dbus/object_proxy.h" + +#include <stddef.h> +#include <utility> #include "base/bind.h" #include "base/logging.h" @@ -13,10 +16,10 @@ #include "base/task_runner_util.h" #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" +#include "dbus/bus.h" #include "dbus/dbus_statistics.h" #include "dbus/message.h" #include "dbus/object_path.h" -#include "dbus/object_proxy.h" #include "dbus/scoped_dbus_error.h" #include "dbus/util.h" @@ -474,7 +477,7 @@ DBusHandlerResult ObjectProxy::HandleMessage( if (path.value() == kDBusSystemObjectPath && signal->GetMember() == kNameOwnerChangedMember) { // Handle NameOwnerChanged separately - return HandleNameOwnerChanged(signal.Pass()); + return HandleNameOwnerChanged(std::move(signal)); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/chromium/dbus/object_proxy.h b/chromium/dbus/object_proxy.h index c0211b1db61..edb97a5be71 100644 --- a/chromium/dbus/object_proxy.h +++ b/chromium/dbus/object_proxy.h @@ -13,6 +13,7 @@ #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/strings/string_piece.h" #include "base/time/time.h" @@ -146,8 +147,7 @@ class CHROME_DBUS_EXPORT ObjectProxy ResponseCallback callback, ErrorCallback error_callback); - // Requests to connect to the signal from the remote object, replacing - // any previous |signal_callback| connected to that signal. + // Requests to connect to the signal from the remote object. // // |signal_callback| will be called in the origin thread, when the // signal is received from the remote object. As it's called in the @@ -157,6 +157,11 @@ class CHROME_DBUS_EXPORT ObjectProxy // |on_connected_callback| is called when the object proxy is connected // to the signal, or failed to be connected, in the origin thread. // + // If a SignalCallback has already been registered for the given + // |interface_name| and |signal_name|, |signal_callback| will be + // added to the list of callbacks for |interface_name| and + // |signal_name|. + // // Must be called in the origin thread. virtual void ConnectToSignal(const std::string& interface_name, const std::string& signal_name, diff --git a/chromium/dbus/object_proxy_unittest.cc b/chromium/dbus/object_proxy_unittest.cc index 22130b64bc3..05c12943496 100644 --- a/chromium/dbus/object_proxy_unittest.cc +++ b/chromium/dbus/object_proxy_unittest.cc @@ -20,16 +20,12 @@ class ObjectProxyTest : public testing::Test { bus_options.bus_type = Bus::SESSION; bus_options.connection_type = Bus::PRIVATE; bus_ = new Bus(bus_options); - - object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", ObjectPath("/org/chromium/TestObject")); } void TearDown() override { bus_->ShutdownAndBlock(); } base::MessageLoopForIO message_loop_; scoped_refptr<Bus> bus_; - ObjectProxy* object_proxy_; }; // Used as a WaitForServiceToBeAvailableCallback. @@ -43,14 +39,17 @@ void OnServiceIsAvailable(scoped_ptr<base::RunLoop>* run_loop, TEST_F(ObjectProxyTest, WaitForServiceToBeAvailable) { scoped_ptr<base::RunLoop> run_loop; + TestService::Options options; + TestService test_service(options); + // Callback is not yet called because the service is not available. - object_proxy_->WaitForServiceToBeAvailable( + ObjectProxy* object_proxy = bus_->GetObjectProxy( + test_service.service_name(), ObjectPath("/org/chromium/TestObject")); + object_proxy->WaitForServiceToBeAvailable( base::Bind(&OnServiceIsAvailable, &run_loop)); base::RunLoop().RunUntilIdle(); // Start the service. - TestService::Options options; - TestService test_service(options); ASSERT_TRUE(test_service.StartService()); ASSERT_TRUE(test_service.WaitUntilServiceIsStarted()); ASSERT_TRUE(test_service.has_ownership()); @@ -61,7 +60,7 @@ TEST_F(ObjectProxyTest, WaitForServiceToBeAvailable) { // Callback is called because the service is already available. run_loop.reset(new base::RunLoop); - object_proxy_->WaitForServiceToBeAvailable( + object_proxy->WaitForServiceToBeAvailable( base::Bind(&OnServiceIsAvailable, &run_loop)); run_loop->Run(); diff --git a/chromium/dbus/property.cc b/chromium/dbus/property.cc index 234036c35db..66af86676cb 100644 --- a/chromium/dbus/property.cc +++ b/chromium/dbus/property.cc @@ -4,7 +4,8 @@ #include "dbus/property.h" -#include "base/basictypes.h" +#include <stddef.h> + #include "base/bind.h" #include "base/logging.h" @@ -302,16 +303,16 @@ void PropertySet::NotifyPropertyChanged(const std::string& name) { // template <> -Property<uint8>::Property() : value_(0) { -} +Property<uint8_t>::Property() + : value_(0) {} template <> -bool Property<uint8>::PopValueFromReader(MessageReader* reader) { +bool Property<uint8_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfByte(&value_); } template <> -void Property<uint8>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<uint8_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfByte(set_value_); } @@ -334,110 +335,110 @@ void Property<bool>::AppendSetValueToWriter(MessageWriter* writer) { } // -// Property<int16> specialization. +// Property<int16_t> specialization. // template <> -Property<int16>::Property() : value_(0) { -} +Property<int16_t>::Property() + : value_(0) {} template <> -bool Property<int16>::PopValueFromReader(MessageReader* reader) { +bool Property<int16_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfInt16(&value_); } template <> -void Property<int16>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<int16_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfInt16(set_value_); } // -// Property<uint16> specialization. +// Property<uint16_t> specialization. // template <> -Property<uint16>::Property() : value_(0) { -} +Property<uint16_t>::Property() + : value_(0) {} template <> -bool Property<uint16>::PopValueFromReader(MessageReader* reader) { +bool Property<uint16_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfUint16(&value_); } template <> -void Property<uint16>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<uint16_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfUint16(set_value_); } // -// Property<int32> specialization. +// Property<int32_t> specialization. // template <> -Property<int32>::Property() : value_(0) { -} +Property<int32_t>::Property() + : value_(0) {} template <> -bool Property<int32>::PopValueFromReader(MessageReader* reader) { +bool Property<int32_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfInt32(&value_); } template <> -void Property<int32>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<int32_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfInt32(set_value_); } // -// Property<uint32> specialization. +// Property<uint32_t> specialization. // template <> -Property<uint32>::Property() : value_(0) { -} +Property<uint32_t>::Property() + : value_(0) {} template <> -bool Property<uint32>::PopValueFromReader(MessageReader* reader) { +bool Property<uint32_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfUint32(&value_); } template <> -void Property<uint32>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<uint32_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfUint32(set_value_); } // -// Property<int64> specialization. +// Property<int64_t> specialization. // template <> -Property<int64>::Property() : value_(0), set_value_(0) { -} +Property<int64_t>::Property() + : value_(0), set_value_(0) {} template <> -bool Property<int64>::PopValueFromReader(MessageReader* reader) { +bool Property<int64_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfInt64(&value_); } template <> -void Property<int64>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<int64_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfInt64(set_value_); } // -// Property<uint64> specialization. +// Property<uint64_t> specialization. // template <> -Property<uint64>::Property() : value_(0) { -} +Property<uint64_t>::Property() + : value_(0) {} template <> -bool Property<uint64>::PopValueFromReader(MessageReader* reader) { +bool Property<uint64_t>::PopValueFromReader(MessageReader* reader) { return reader->PopVariantOfUint64(&value_); } template <> -void Property<uint64>::AppendSetValueToWriter(MessageWriter* writer) { +void Property<uint64_t>::AppendSetValueToWriter(MessageWriter* writer) { writer->AppendVariantOfUint64(set_value_); } @@ -536,17 +537,17 @@ void Property<std::vector<ObjectPath> >::AppendSetValueToWriter( } // -// Property<std::vector<uint8> > specialization. +// Property<std::vector<uint8_t> > specialization. // template <> -bool Property<std::vector<uint8> >::PopValueFromReader(MessageReader* reader) { +bool Property<std::vector<uint8_t>>::PopValueFromReader(MessageReader* reader) { MessageReader variant_reader(NULL); if (!reader->PopVariant(&variant_reader)) return false; value_.clear(); - const uint8* bytes = NULL; + const uint8_t* bytes = NULL; size_t length = 0; if (!variant_reader.PopArrayOfBytes(&bytes, &length)) return false; @@ -555,7 +556,7 @@ bool Property<std::vector<uint8> >::PopValueFromReader(MessageReader* reader) { } template <> -void Property<std::vector<uint8> >::AppendSetValueToWriter( +void Property<std::vector<uint8_t>>::AppendSetValueToWriter( MessageWriter* writer) { MessageWriter variant_writer(NULL); writer->OpenVariant("ay", &variant_writer); @@ -629,7 +630,7 @@ bool Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: return false; std::pair<std::vector<uint8_t>, uint16_t> entry; - const uint8* bytes = NULL; + const uint8_t* bytes = NULL; size_t length = 0; if (!struct_reader.PopArrayOfBytes(&bytes, &length)) return false; @@ -660,20 +661,20 @@ void Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>:: writer->CloseContainer(&variant_writer); } -template class Property<uint8>; +template class Property<uint8_t>; template class Property<bool>; -template class Property<int16>; -template class Property<uint16>; -template class Property<int32>; -template class Property<uint32>; -template class Property<int64>; -template class Property<uint64>; +template class Property<int16_t>; +template class Property<uint16_t>; +template class Property<int32_t>; +template class Property<uint32_t>; +template class Property<int64_t>; +template class Property<uint64_t>; template class Property<double>; template class Property<std::string>; template class Property<ObjectPath>; template class Property<std::vector<std::string> >; template class Property<std::vector<ObjectPath> >; -template class Property<std::vector<uint8> >; +template class Property<std::vector<uint8_t>>; template class Property<std::map<std::string, std::string>>; template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; diff --git a/chromium/dbus/property.h b/chromium/dbus/property.h index e379f8a1618..efbad226a69 100644 --- a/chromium/dbus/property.h +++ b/chromium/dbus/property.h @@ -5,14 +5,16 @@ #ifndef DBUS_PROPERTY_H_ #define DBUS_PROPERTY_H_ +#include <stdint.h> + #include <map> #include <string> #include <utility> #include <vector> -#include "base/basictypes.h" #include "base/bind.h" #include "base/callback.h" +#include "base/macros.h" #include "dbus/dbus_export.h" #include "dbus/message.h" #include "dbus/object_proxy.h" @@ -36,7 +38,7 @@ // public: // struct Properties : public dbus::PropertySet { // dbus::Property<std::string> name; -// dbus::Property<uint16> version; +// dbus::Property<uint16_t> version; // dbus::Property<dbus::ObjectPath> parent; // dbus::Property<std::vector<std::string> > children; // @@ -457,14 +459,14 @@ class CHROME_DBUS_EXPORT Property : public PropertyBase { #pragma GCC diagnostic ignored "-Wattributes" template <> -CHROME_DBUS_EXPORT Property<uint8>::Property(); +CHROME_DBUS_EXPORT Property<uint8_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<uint8>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<uint8_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<uint8>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<uint8_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<uint8>; +extern template class CHROME_DBUS_EXPORT Property<uint8_t>; template <> CHROME_DBUS_EXPORT Property<bool>::Property(); @@ -477,64 +479,64 @@ CHROME_DBUS_EXPORT void Property<bool>::AppendSetValueToWriter( extern template class CHROME_DBUS_EXPORT Property<bool>; template <> -CHROME_DBUS_EXPORT Property<int16>::Property(); +CHROME_DBUS_EXPORT Property<int16_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<int16>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<int16_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<int16>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<int16_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<int16>; +extern template class CHROME_DBUS_EXPORT Property<int16_t>; template <> -CHROME_DBUS_EXPORT Property<uint16>::Property(); +CHROME_DBUS_EXPORT Property<uint16_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<uint16>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<uint16_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<uint16>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<uint16_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<uint16>; +extern template class CHROME_DBUS_EXPORT Property<uint16_t>; template <> -CHROME_DBUS_EXPORT Property<int32>::Property(); +CHROME_DBUS_EXPORT Property<int32_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<int32>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<int32_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<int32>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<int32_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<int32>; +extern template class CHROME_DBUS_EXPORT Property<int32_t>; template <> -CHROME_DBUS_EXPORT Property<uint32>::Property(); +CHROME_DBUS_EXPORT Property<uint32_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<uint32>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<uint32_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<uint32>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<uint32_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<uint32>; +extern template class CHROME_DBUS_EXPORT Property<uint32_t>; template <> -CHROME_DBUS_EXPORT Property<int64>::Property(); +CHROME_DBUS_EXPORT Property<int64_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<int64>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<int64_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<int64>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<int64_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<int64>; +extern template class CHROME_DBUS_EXPORT Property<int64_t>; template <> -CHROME_DBUS_EXPORT Property<uint64>::Property(); +CHROME_DBUS_EXPORT Property<uint64_t>::Property(); template <> -CHROME_DBUS_EXPORT bool Property<uint64>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<uint64_t>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<uint64>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<uint64_t>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<uint64>; +extern template class CHROME_DBUS_EXPORT Property<uint64_t>; template <> CHROME_DBUS_EXPORT Property<double>::Property(); @@ -579,12 +581,12 @@ CHROME_DBUS_EXPORT void Property< extern template class CHROME_DBUS_EXPORT Property<std::vector<ObjectPath>>; template <> -CHROME_DBUS_EXPORT bool Property<std::vector<uint8>>::PopValueFromReader( +CHROME_DBUS_EXPORT bool Property<std::vector<uint8_t>>::PopValueFromReader( MessageReader* reader); template <> -CHROME_DBUS_EXPORT void Property<std::vector<uint8>>::AppendSetValueToWriter( +CHROME_DBUS_EXPORT void Property<std::vector<uint8_t>>::AppendSetValueToWriter( MessageWriter* writer); -extern template class CHROME_DBUS_EXPORT Property<std::vector<uint8>>; +extern template class CHROME_DBUS_EXPORT Property<std::vector<uint8_t>>; template <> CHROME_DBUS_EXPORT bool diff --git a/chromium/dbus/property_unittest.cc b/chromium/dbus/property_unittest.cc index 59faa22e1a8..f1592849aef 100644 --- a/chromium/dbus/property_unittest.cc +++ b/chromium/dbus/property_unittest.cc @@ -4,12 +4,15 @@ #include "dbus/property.h" +#include <stddef.h> +#include <stdint.h> + #include <string> #include <vector> -#include "base/basictypes.h" #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/strings/string_number_conversions.h" @@ -31,10 +34,10 @@ class PropertyTest : public testing::Test { struct Properties : public PropertySet { Property<std::string> name; - Property<int16> version; + Property<int16_t> version; Property<std::vector<std::string> > methods; Property<std::vector<ObjectPath> > objects; - Property<std::vector<uint8> > bytes; + Property<std::vector<uint8_t>> bytes; Properties(ObjectProxy* object_proxy, PropertyChangedCallback property_changed_callback) @@ -74,7 +77,7 @@ class PropertyTest : public testing::Test { bus_options.dbus_task_runner = dbus_thread_->task_runner(); bus_ = new Bus(bus_options); object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); ASSERT_TRUE(bus_->HasDBusThread()); @@ -189,7 +192,7 @@ TEST_F(PropertyTest, InitialValues) { ASSERT_EQ(1U, objects.size()); EXPECT_EQ(ObjectPath("/TestObjectPath"), objects[0]); - std::vector<uint8> bytes = properties_->bytes.value(); + std::vector<uint8_t> bytes = properties_->bytes.value(); ASSERT_EQ(4U, bytes.size()); EXPECT_EQ('T', bytes[0]); EXPECT_EQ('e', bytes[1]); @@ -253,7 +256,7 @@ TEST_F(PropertyTest, UpdatedValues) { WaitForCallback("Bytes"); WaitForUpdates(1); - std::vector<uint8> bytes = properties_->bytes.value(); + std::vector<uint8_t> bytes = properties_->bytes.value(); ASSERT_EQ(4U, bytes.size()); EXPECT_EQ('T', bytes[0]); EXPECT_EQ('e', bytes[1]); @@ -380,8 +383,8 @@ TEST(PropertyTestStatic, ReadWriteNetAddressArray) { writer.OpenVariant("a(ayq)", &variant_writer); variant_writer.OpenArray("(ayq)", &variant_array_writer); - uint8 ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30}; - for (uint16 i = 0; i < 5; ++i) { + uint8_t ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30}; + 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)); @@ -392,7 +395,7 @@ TEST(PropertyTestStatic, ReadWriteNetAddressArray) { writer.CloseContainer(&variant_writer); MessageReader reader(message.get()); - Property<std::vector<std::pair<std::vector<uint8>, uint16>>> ip_list; + Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>> ip_list; EXPECT_TRUE(ip_list.PopValueFromReader(&reader)); ASSERT_EQ(5U, ip_list.value().size()); @@ -407,19 +410,19 @@ TEST(PropertyTestStatic, ReadWriteNetAddressArray) { } TEST(PropertyTestStatic, SerializeNetAddressArray) { - std::vector<std::pair<std::vector<uint8>, uint16>> test_list; + std::vector<std::pair<std::vector<uint8_t>, uint16_t>> test_list; - uint8 ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30}; - for (uint16 i = 0; i < 5; ++i) { + 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> bytes(ip_bytes, ip_bytes + arraysize(ip_bytes)); + std::vector<uint8_t> bytes(ip_bytes, ip_bytes + arraysize(ip_bytes)); test_list.push_back(make_pair(bytes, 16)); } scoped_ptr<Response> message(Response::CreateEmpty()); MessageWriter writer(message.get()); - Property<std::vector<std::pair<std::vector<uint8>, uint16>>> ip_list; + Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>> ip_list; ip_list.ReplaceSetValueForTesting(test_list); ip_list.AppendSetValueToWriter(&writer); diff --git a/chromium/dbus/run_all_unittests.cc b/chromium/dbus/run_all_unittests.cc deleted file mode 100644 index e90849c1c2f..00000000000 --- a/chromium/dbus/run_all_unittests.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/at_exit.h" -#include "base/bind.h" -#include "base/test/launcher/unit_test_launcher.h" -#include "base/test/test_suite.h" - -namespace { - -class NoAtExitBaseTestSuite : public base::TestSuite { - public: - NoAtExitBaseTestSuite(int argc, char** argv) - : base::TestSuite(argc, argv, false) { - } -}; - -int RunTestSuite(int argc, char** argv) { - return NoAtExitBaseTestSuite(argc, argv).Run(); -} - -} // namespace - -int main(int argc, char** argv) { - base::AtExitManager at_exit; - return base::LaunchUnitTestsSerially(argc, - argv, - base::Bind(&RunTestSuite, argc, argv)); -} diff --git a/chromium/dbus/signal_sender_verification_unittest.cc b/chromium/dbus/signal_sender_verification_unittest.cc index 0cedda74ae1..785948a1f2b 100644 --- a/chromium/dbus/signal_sender_verification_unittest.cc +++ b/chromium/dbus/signal_sender_verification_unittest.cc @@ -40,6 +40,11 @@ class SignalSenderVerificationTest : public testing::Test { thread_options.message_loop_type = base::MessageLoop::TYPE_IO; ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); + // Create the test service, using the D-Bus thread. + TestService::Options options; + options.dbus_task_runner = dbus_thread_->task_runner(); + test_service_.reset(new TestService(options)); + // Create the client, using the D-Bus thread. Bus::Options bus_options; bus_options.bus_type = Bus::SESSION; @@ -47,7 +52,7 @@ class SignalSenderVerificationTest : public testing::Test { bus_options.dbus_task_runner = dbus_thread_->task_runner(); bus_ = new Bus(bus_options); object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/TestObject")); ASSERT_TRUE(bus_->HasDBusThread()); @@ -69,10 +74,7 @@ class SignalSenderVerificationTest : public testing::Test { run_loop_.reset(new base::RunLoop); run_loop_->Run(); - // Start the test service, using the D-Bus thread. - TestService::Options options; - options.dbus_task_runner = dbus_thread_->task_runner(); - test_service_.reset(new TestService(options)); + // Start the test service. ASSERT_TRUE(test_service_->StartService()); ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); ASSERT_TRUE(test_service_->HasDBusThread()); @@ -80,6 +82,7 @@ class SignalSenderVerificationTest : public testing::Test { // Same setup for the second TestService. This service should not have the // ownership of the name at this point. + options.service_name = test_service_->service_name(); test_service2_.reset(new TestService(options)); ASSERT_TRUE(test_service2_->StartService()); ASSERT_TRUE(test_service2_->WaitUntilServiceIsStarted()); @@ -280,6 +283,7 @@ TEST_F(SignalSenderVerificationTest, TestOwnerStealing) { TestService::Options options; options.dbus_task_runner = dbus_thread_->task_runner(); options.request_ownership_options = Bus::REQUIRE_PRIMARY_ALLOW_REPLACEMENT; + options.service_name = test_service_->service_name(); TestService stealable_test_service(options); ASSERT_TRUE(stealable_test_service.StartService()); ASSERT_TRUE(stealable_test_service.WaitUntilServiceIsStarted()); @@ -331,7 +335,7 @@ TEST_F(SignalSenderVerificationTest, DISABLED_TestMultipleObjects) { const char kMessage[] = "hello, world"; ObjectProxy* object_proxy2 = bus_->GetObjectProxy( - "org.chromium.TestService", + test_service_->service_name(), ObjectPath("/org/chromium/DifferentObject")); bool second_name_owner_changed_called = false; diff --git a/chromium/dbus/string_util.cc b/chromium/dbus/string_util.cc index 16e483a5fea..7f71015c480 100644 --- a/chromium/dbus/string_util.cc +++ b/chromium/dbus/string_util.cc @@ -4,6 +4,8 @@ #include "dbus/string_util.h" +#include <stddef.h> + #include "base/strings/string_util.h" namespace dbus { diff --git a/chromium/dbus/test_service.cc b/chromium/dbus/test_service.cc index 2c148697d23..7b36082b66c 100644 --- a/chromium/dbus/test_service.cc +++ b/chromium/dbus/test_service.cc @@ -4,10 +4,13 @@ #include "dbus/test_service.h" +#include <stdint.h> #include <string> +#include <utility> #include <vector> #include "base/bind.h" +#include "base/guid.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "dbus/bus.h" @@ -39,6 +42,7 @@ TestService::Options::~Options() { TestService::TestService(const Options& options) : base::Thread("TestService"), + service_name_(options.service_name), request_ownership_options_(options.request_ownership_options), dbus_task_runner_(options.dbus_task_runner), on_name_obtained_(false, false), @@ -47,6 +51,9 @@ TestService::TestService(const Options& options) has_ownership_(false), exported_object_(NULL), exported_object_manager_(NULL) { + if (service_name_.empty()) { + service_name_ = "org.chromium.TestService-" + base::GenerateGUID(); + } } TestService::~TestService() { @@ -111,7 +118,7 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { MessageWriter writer(&signal); writer.AppendString(message); - bus_->RequestOwnership("org.chromium.TestService", + bus_->RequestOwnership(service_name_, request_ownership_options_, base::Bind(&TestService::OnOwnership, base::Unretained(this), @@ -132,7 +139,7 @@ void TestService::RequestOwnership(base::Callback<void(bool)> callback) { void TestService::RequestOwnershipInternal( base::Callback<void(bool)> callback) { - bus_->RequestOwnership("org.chromium.TestService", + bus_->RequestOwnership(service_name_, request_ownership_options_, base::Bind(&TestService::OnOwnership, base::Unretained(this), @@ -159,7 +166,7 @@ void TestService::ReleaseOwnership(base::Closure callback) { void TestService::ReleaseOwnershipInternal( base::Closure callback) { - bus_->ReleaseOwnership("org.chromium.TestService"); + bus_->ReleaseOwnership(service_name_); has_ownership_ = false; bus_->GetOriginTaskRunner()->PostTask( @@ -186,7 +193,7 @@ void TestService::OnExported(const std::string& interface_name, if (num_exported_methods_ == kNumMethodsToExport) { // As documented in exported_object.h, the service name should be // requested after all methods are exposed. - bus_->RequestOwnership("org.chromium.TestService", + bus_->RequestOwnership(service_name_, request_ownership_options_, base::Bind(&TestService::OnOwnership, base::Unretained(this), @@ -309,7 +316,7 @@ void TestService::Echo(MethodCall* method_call, scoped_ptr<Response> response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); writer.AppendString(text_message); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } void TestService::SlowEcho(MethodCall* method_call, @@ -350,7 +357,7 @@ void TestService::GetAllProperties( AddPropertiesToWriter(&writer); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } void TestService::GetProperty(MethodCall* method_call, @@ -376,7 +383,7 @@ void TestService::GetProperty(MethodCall* method_call, writer.AppendVariantOfString("TestService"); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } else if (name == "Version") { // Return a new value for the "Version" property: // Variant<20> @@ -385,7 +392,7 @@ void TestService::GetProperty(MethodCall* method_call, writer.AppendVariantOfInt16(20); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } else if (name == "Methods") { // Return the previous value for the "Methods" property: // Variant<["Echo", "SlowEcho", "AsyncEcho", "BrokenMethod"]> @@ -403,7 +410,7 @@ void TestService::GetProperty(MethodCall* method_call, variant_writer.CloseContainer(&variant_array_writer); writer.CloseContainer(&variant_writer); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } else if (name == "Objects") { // Return the previous value for the "Objects" property: // Variant<[objectpath:"/TestObjectPath"]> @@ -418,7 +425,7 @@ void TestService::GetProperty(MethodCall* method_call, variant_writer.CloseContainer(&variant_array_writer); writer.CloseContainer(&variant_writer); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } else if (name == "Bytes") { // Return the previous value for the "Bytes" property: // Variant<[0x54, 0x65, 0x73, 0x74]> @@ -428,11 +435,11 @@ void TestService::GetProperty(MethodCall* method_call, MessageWriter variant_array_writer(NULL); writer.OpenVariant("ay", &variant_writer); - const uint8 bytes[] = { 0x54, 0x65, 0x73, 0x74 }; + const uint8_t bytes[] = {0x54, 0x65, 0x73, 0x74}; variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes)); writer.CloseContainer(&variant_writer); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } else { // Return error. response_sender.Run(scoped_ptr<Response>()); @@ -503,14 +510,14 @@ void TestService::PerformAction( } scoped_ptr<Response> response = Response::FromMethodCall(method_call); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } void TestService::PerformActionResponse( MethodCall* method_call, ExportedObject::ResponseSender response_sender) { scoped_ptr<Response> response = Response::FromMethodCall(method_call); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); } void TestService::OwnershipReleased( @@ -570,7 +577,7 @@ void TestService::GetManagedObjects( array_writer.CloseContainer(&dict_entry_writer); writer.CloseContainer(&array_writer); - response_sender.Run(response.Pass()); + response_sender.Run(std::move(response)); if (send_immediate_properties_changed_) SendPropertyChangedSignal("ChangedTestServiceName"); @@ -630,7 +637,7 @@ void TestService::AddPropertiesToWriter(MessageWriter* writer) { array_writer.OpenDictEntry(&dict_entry_writer); dict_entry_writer.AppendString("Bytes"); dict_entry_writer.OpenVariant("ay", &variant_writer); - const uint8 bytes[] = { 0x54, 0x65, 0x73, 0x74 }; + const uint8_t bytes[] = {0x54, 0x65, 0x73, 0x74}; variant_writer.AppendArrayOfBytes(bytes, sizeof(bytes)); dict_entry_writer.CloseContainer(&variant_writer); array_writer.CloseContainer(&dict_entry_writer); diff --git a/chromium/dbus/test_service.h b/chromium/dbus/test_service.h index de4aa720ac7..e2ed480e9d3 100644 --- a/chromium/dbus/test_service.h +++ b/chromium/dbus/test_service.h @@ -40,6 +40,9 @@ class TestService : public base::Thread { // Flags governing parameters of service ownership request. Bus::ServiceOwnershipOptions request_ownership_options; + + // Name of this service (randomly generated name will be used if empty). + std::string service_name; }; // The number of methods we'll export. @@ -78,6 +81,9 @@ class TestService : public base::Thread { // |callback| will be called when the ownership has been released. void ReleaseOwnership(base::Closure callback); + // Returns the name of this service. + const std::string& service_name() const { return service_name_; } + // Returns whether this instance has the name ownership or not. bool has_ownership() const { return has_ownership_; } @@ -199,6 +205,9 @@ class TestService : public base::Thread { dbus::ExportedObject::ResponseSender response_sender, bool success); + // Name of this service. + std::string service_name_; + // Options to use when requesting service ownership. Bus::ServiceOwnershipOptions request_ownership_options_; diff --git a/chromium/dbus/values_util.cc b/chromium/dbus/values_util.cc index c162878ee05..e932312e692 100644 --- a/chromium/dbus/values_util.cc +++ b/chromium/dbus/values_util.cc @@ -94,7 +94,7 @@ base::Value* PopDataAsValue(MessageReader* reader) { // Do nothing. break; case Message::BYTE: { - uint8 value = 0; + uint8_t value = 0; if (reader->PopByte(&value)) result = new base::FundamentalValue(value); break; @@ -106,31 +106,31 @@ base::Value* PopDataAsValue(MessageReader* reader) { break; } case Message::INT16: { - int16 value = 0; + int16_t value = 0; if (reader->PopInt16(&value)) result = new base::FundamentalValue(value); break; } case Message::UINT16: { - uint16 value = 0; + uint16_t value = 0; if (reader->PopUint16(&value)) result = new base::FundamentalValue(value); break; } case Message::INT32: { - int32 value = 0; + int32_t value = 0; if (reader->PopInt32(&value)) result = new base::FundamentalValue(value); break; } case Message::UINT32: { - uint32 value = 0; + uint32_t value = 0; if (reader->PopUint32(&value)) result = new base::FundamentalValue(static_cast<double>(value)); break; } case Message::INT64: { - int64 value = 0; + int64_t value = 0; if (reader->PopInt64(&value)) { DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << value << " is not exactly representable by double"; @@ -139,7 +139,7 @@ base::Value* PopDataAsValue(MessageReader* reader) { break; } case Message::UINT64: { - uint64 value = 0; + uint64_t value = 0; if (reader->PopUint64(&value)) { DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) << value << " is not exactly representable by double"; diff --git a/chromium/dbus/values_util.h b/chromium/dbus/values_util.h index 9ece9b9be55..b6f4ff3b10e 100644 --- a/chromium/dbus/values_util.h +++ b/chromium/dbus/values_util.h @@ -5,6 +5,8 @@ #ifndef DBUS_VALUES_UTIL_H_ #define DBUS_VALUES_UTIL_H_ +#include <stdint.h> + #include "dbus/dbus_export.h" namespace base { @@ -18,8 +20,8 @@ class MessageWriter; // Pops a value from |reader| as a base::Value. // Returns NULL if an error occurs. -// Note: Integer values larger than int32 (including uint32) are converted to -// double. Non-string diciontary keys are converted to strings. +// Note: Integer values larger than int32_t (including uint32_t) are converted +// to double. Non-string dictionary keys are converted to strings. CHROME_DBUS_EXPORT base::Value* PopDataAsValue(MessageReader* reader); // Appends a basic type value to |writer|. Basic types are BOOLEAN, INTEGER, diff --git a/chromium/dbus/values_util_unittest.cc b/chromium/dbus/values_util_unittest.cc index 6abc56a717a..b2f1404da45 100644 --- a/chromium/dbus/values_util_unittest.cc +++ b/chromium/dbus/values_util_unittest.cc @@ -4,10 +4,14 @@ #include "dbus/values_util.h" +#include <stddef.h> +#include <stdint.h> + #include <cmath> #include <vector> #include "base/json/json_writer.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "dbus/message.h" @@ -19,21 +23,21 @@ TEST(ValuesUtilTest, PopBasicTypes) { scoped_ptr<Response> response(Response::CreateEmpty()); // Append basic type values. MessageWriter writer(response.get()); - const uint8 kByteValue = 42; + const uint8_t kByteValue = 42; writer.AppendByte(kByteValue); const bool kBoolValue = true; writer.AppendBool(kBoolValue); - const int16 kInt16Value = -43; + const int16_t kInt16Value = -43; writer.AppendInt16(kInt16Value); - const uint16 kUint16Value = 44; + const uint16_t kUint16Value = 44; writer.AppendUint16(kUint16Value); - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; writer.AppendInt32(kInt32Value); - const uint32 kUint32Value = 46; + const uint32_t kUint32Value = 46; writer.AppendUint32(kUint32Value); - const int64 kInt64Value = -47; + const int64_t kInt64Value = -47; writer.AppendInt64(kInt64Value); - const uint64 kUint64Value = 48; + const uint64_t kUint64Value = 48; writer.AppendUint64(kUint64Value); const double kDoubleValue = 4.9; writer.AppendDouble(kDoubleValue); @@ -57,34 +61,34 @@ TEST(ValuesUtilTest, PopBasicTypes) { ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kBoolValue)); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop an int16. + // Pop an int16_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kInt16Value)); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop a uint16. + // Pop a uint16_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kUint16Value)); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop an int32. + // Pop an int32_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kInt32Value)); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop a uint32. + // Pop a uint32_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset( new base::FundamentalValue(static_cast<double>(kUint32Value))); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop an int64. + // Pop an int64_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset( new base::FundamentalValue(static_cast<double>(kInt64Value))); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop a uint64. + // Pop a uint64_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset( @@ -118,7 +122,7 @@ TEST(ValuesUtilTest, PopVariant) { MessageWriter writer(response.get()); const bool kBoolValue = true; writer.AppendVariantOfBool(kBoolValue); - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; writer.AppendVariantOfInt32(kInt32Value); const double kDoubleValue = 4.9; writer.AppendVariantOfDouble(kDoubleValue); @@ -133,7 +137,7 @@ TEST(ValuesUtilTest, PopVariant) { ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kBoolValue)); EXPECT_TRUE(value->Equals(expected_value.get())); - // Pop an int32. + // Pop an int32_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset(new base::FundamentalValue(kInt32Value)); @@ -156,39 +160,39 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) { scoped_ptr<Response> response(Response::CreateEmpty()); // Append large integers. MessageWriter writer(response.get()); - const int64 kInt64Value = -123456789012345689LL; + const int64_t kInt64Value = -123456789012345689LL; writer.AppendInt64(kInt64Value); - const uint64 kUint64Value = 9876543210987654321ULL; + const uint64_t kUint64Value = 9876543210987654321ULL; writer.AppendUint64(kUint64Value); MessageReader reader(response.get()); scoped_ptr<base::Value> value; scoped_ptr<base::Value> expected_value; double double_value = 0; - // Pop an int64. + // Pop an int64_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset( new base::FundamentalValue(static_cast<double>(kInt64Value))); EXPECT_TRUE(value->Equals(expected_value.get())); ASSERT_TRUE(value->GetAsDouble(&double_value)); - EXPECT_NE(kInt64Value, static_cast<int64>(double_value)); - // Pop a uint64. + EXPECT_NE(kInt64Value, static_cast<int64_t>(double_value)); + // Pop a uint64_t. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); expected_value.reset( new base::FundamentalValue(static_cast<double>(kUint64Value))); EXPECT_TRUE(value->Equals(expected_value.get())); ASSERT_TRUE(value->GetAsDouble(&double_value)); - EXPECT_NE(kUint64Value, static_cast<uint64>(double_value)); + EXPECT_NE(kUint64Value, static_cast<uint64_t>(double_value)); } TEST(ValuesUtilTest, PopIntArray) { scoped_ptr<Response> response(Response::CreateEmpty()); - // Append an int32 array. + // Append an int32_t array. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); - std::vector<int32> data; + std::vector<int32_t> data; data.push_back(0); data.push_back(1); data.push_back(2); @@ -202,7 +206,7 @@ TEST(ValuesUtilTest, PopIntArray) { for (size_t i = 0; i != data.size(); ++i) list_value->Append(new base::FundamentalValue(data[i])); - // Pop an int32 array. + // Pop an int32_t array. MessageReader reader(response.get()); scoped_ptr<base::Value> value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); @@ -240,7 +244,7 @@ TEST(ValuesUtilTest, PopStruct) { writer.OpenStruct(&sub_writer); const bool kBoolValue = true; sub_writer.AppendBool(kBoolValue); - const int32 kInt32Value = -123; + const int32_t kInt32Value = -123; sub_writer.AppendInt32(kInt32Value); const double kDoubleValue = 1.23; sub_writer.AppendDouble(kDoubleValue); @@ -278,7 +282,7 @@ TEST(ValuesUtilTest, PopStringToVariantDictionary) { sub_writer.OpenDictEntry(&entry_writer); const std::string kKey2 = "two"; entry_writer.AppendString(kKey2); - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; entry_writer.AppendVariantOfInt32(kInt32Value); sub_writer.CloseContainer(&entry_writer); sub_writer.OpenDictEntry(&entry_writer); @@ -325,7 +329,7 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) { sub_writer.OpenDictEntry(&entry_writer); const std::string kKey2 = ".example"; // String starting with a dot. entry_writer.AppendString(kKey2); - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; entry_writer.AppendVariantOfInt32(kInt32Value); sub_writer.CloseContainer(&entry_writer); sub_writer.OpenDictEntry(&entry_writer); @@ -354,8 +358,8 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) { TEST(ValuesUtilTest, PopDoubleToIntDictionary) { // Create test data. - const int32 kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21}; - const std::vector<int32> values(kValues, kValues + arraysize(kValues)); + const int32_t kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21}; + const std::vector<int32_t> values(kValues, kValues + arraysize(kValues)); std::vector<double> keys(values.size()); for (size_t i = 0; i != values.size(); ++i) keys[i] = std::sqrt(values[i]); @@ -515,7 +519,7 @@ TEST(ValuesUtilTest, AppendDictionary) { const std::string kKey6 = "six"; const bool kBoolValue = true; - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; const double kDoubleValue = 4.9; const std::string kStringValue = "fifty"; @@ -562,7 +566,7 @@ TEST(ValuesUtilTest, AppendDictionaryAsVariant) { const std::string kKey6 = "six"; const bool kBoolValue = true; - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; const double kDoubleValue = 4.9; const std::string kStringValue = "fifty"; @@ -605,7 +609,7 @@ TEST(ValuesUtilTest, AppendList) { const std::string kKey2 = "two"; const bool kBoolValue = true; - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; const double kDoubleValue = 4.9; const std::string kStringValue = "fifty"; @@ -648,7 +652,7 @@ TEST(ValuesUtilTest, AppendListAsVariant) { const std::string kKey2 = "two"; const bool kBoolValue = true; - const int32 kInt32Value = -45; + const int32_t kInt32Value = -45; const double kDoubleValue = 4.9; const std::string kStringValue = "fifty"; |