summaryrefslogtreecommitdiff
path: root/chromium/dbus
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 11:38:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 17:16:47 +0000
commit3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch)
tree43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/dbus
parentf61ab1ac7f855cd281809255c0aedbb1895e1823 (diff)
downloadqtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/dbus')
-rw-r--r--chromium/dbus/bus.cc9
-rw-r--r--chromium/dbus/bus.h4
-rw-r--r--chromium/dbus/bus_unittest.cc26
-rw-r--r--chromium/dbus/end_to_end_async_unittest.cc6
-rw-r--r--chromium/dbus/file_descriptor.cc25
-rw-r--r--chromium/dbus/file_descriptor.h13
-rw-r--r--chromium/dbus/message.cc11
-rw-r--r--chromium/dbus/object_manager_unittest.cc4
-rw-r--r--chromium/dbus/property_unittest.cc4
-rw-r--r--chromium/dbus/signal_sender_verification_unittest.cc6
-rw-r--r--chromium/dbus/string_util.cc4
-rw-r--r--chromium/dbus/test_server.cc2
-rw-r--r--chromium/dbus/values_util.cc4
-rw-r--r--chromium/dbus/values_util_unittest.cc6
14 files changed, 93 insertions, 31 deletions
diff --git a/chromium/dbus/bus.cc b/chromium/dbus/bus.cc
index 2f1300a25e3..3a4fe219f74 100644
--- a/chromium/dbus/bus.cc
+++ b/chromium/dbus/bus.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
@@ -201,7 +200,7 @@ Bus::Bus(const Options& options)
// The origin message loop is unnecessary if the client uses synchronous
// functions only.
if (base::MessageLoop::current())
- origin_task_runner_ = base::MessageLoop::current()->message_loop_proxy();
+ origin_task_runner_ = base::MessageLoop::current()->task_runner();
}
Bus::~Bus() {
@@ -1021,6 +1020,12 @@ void Bus::UnlistenForServiceOwnerChangeInternal(
RemoveFilterFunction(Bus::OnServiceOwnerChangedFilter, this);
}
+std::string Bus::GetConnectionName() {
+ if (!connection_)
+ return "";
+ return dbus_bus_get_unique_name(connection_);
+}
+
dbus_bool_t Bus::OnAddWatch(DBusWatch* raw_watch) {
AssertOnDBusThread();
diff --git a/chromium/dbus/bus.h b/chromium/dbus/bus.h
index f9f0dfd9cf6..27d149c4791 100644
--- a/chromium/dbus/bus.h
+++ b/chromium/dbus/bus.h
@@ -586,6 +586,10 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
const std::string& service_name,
const GetServiceOwnerCallback& callback);
+ // Return the unique name of the bus connnection if it is connected to
+ // D-BUS. Otherwise, return an empty string.
+ std::string GetConnectionName();
+
// Returns true if the bus is connected to D-Bus.
bool is_connected() { return connection_ != NULL; }
diff --git a/chromium/dbus/bus_unittest.cc b/chromium/dbus/bus_unittest.cc
index 22ccddc57cd..27d9bb2e3e0 100644
--- a/chromium/dbus/bus_unittest.cc
+++ b/chromium/dbus/bus_unittest.cc
@@ -137,7 +137,7 @@ TEST(BusTest, RemoveObjectProxy) {
// Create the bus.
Bus::Options options;
- options.dbus_task_runner = dbus_thread.message_loop_proxy();
+ options.dbus_task_runner = dbus_thread.task_runner();
scoped_refptr<Bus> bus = new Bus(options);
ASSERT_FALSE(bus->shutdown_completed());
@@ -217,7 +217,7 @@ TEST(BusTest, UnregisterExportedObject) {
// Create the bus.
Bus::Options options;
- options.dbus_task_runner = dbus_thread.message_loop_proxy();
+ options.dbus_task_runner = dbus_thread.task_runner();
scoped_refptr<Bus> bus = new Bus(options);
ASSERT_FALSE(bus->shutdown_completed());
@@ -267,7 +267,7 @@ TEST(BusTest, ShutdownAndBlockWithDBusThread) {
// Create the bus.
Bus::Options options;
- options.dbus_task_runner = dbus_thread.message_loop_proxy();
+ options.dbus_task_runner = dbus_thread.task_runner();
scoped_refptr<Bus> bus = new Bus(options);
ASSERT_FALSE(bus->shutdown_completed());
@@ -394,4 +394,24 @@ TEST(BusTest, ListenForServiceOwnerChange) {
EXPECT_TRUE(bus->shutdown_completed());
}
+TEST(BusTest, GetConnectionName) {
+ Bus::Options options;
+ scoped_refptr<Bus> bus = new Bus(options);
+
+ // Connection name is empty since bus is not connected.
+ EXPECT_FALSE(bus->is_connected());
+ EXPECT_TRUE(bus->GetConnectionName().empty());
+
+ // Connect bus to D-Bus.
+ bus->Connect();
+
+ // Connection name is not empty after connection is established.
+ EXPECT_TRUE(bus->is_connected());
+ EXPECT_FALSE(bus->GetConnectionName().empty());
+
+ // Shut down synchronously.
+ bus->ShutdownAndBlock();
+ EXPECT_TRUE(bus->shutdown_completed());
+}
+
} // namespace dbus
diff --git a/chromium/dbus/end_to_end_async_unittest.cc b/chromium/dbus/end_to_end_async_unittest.cc
index 10516b99971..3854721f257 100644
--- a/chromium/dbus/end_to_end_async_unittest.cc
+++ b/chromium/dbus/end_to_end_async_unittest.cc
@@ -47,7 +47,7 @@ class EndToEndAsyncTest : public testing::Test {
// Start the test service, using the D-Bus thread.
TestService::Options options;
- options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread_->task_runner();
test_service_.reset(new TestService(options));
ASSERT_TRUE(test_service_->StartService());
ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
@@ -57,7 +57,7 @@ class EndToEndAsyncTest : public testing::Test {
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
- bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ bus_options.dbus_task_runner = dbus_thread_->task_runner();
bus_ = new Bus(bus_options);
object_proxy_ = bus_->GetObjectProxy(
"org.chromium.TestService",
@@ -138,7 +138,7 @@ class EndToEndAsyncTest : public testing::Test {
bus_options.bus_type = Bus::CUSTOM_ADDRESS;
bus_options.address = kInvalidAddress;
bus_options.connection_type = Bus::PRIVATE;
- bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ bus_options.dbus_task_runner = dbus_thread_->task_runner();
bus_ = new Bus(bus_options);
ASSERT_TRUE(bus_->HasDBusThread());
diff --git a/chromium/dbus/file_descriptor.cc b/chromium/dbus/file_descriptor.cc
index e607fc01356..c740f280622 100644
--- a/chromium/dbus/file_descriptor.cc
+++ b/chromium/dbus/file_descriptor.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <algorithm>
+
#include "base/bind.h"
#include "base/files/file.h"
#include "base/location.h"
@@ -9,6 +11,8 @@
#include "base/threading/worker_pool.h"
#include "dbus/file_descriptor.h"
+using std::swap;
+
namespace dbus {
void CHROME_DBUS_EXPORT FileDescriptor::Deleter::operator()(
@@ -17,11 +21,21 @@ 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() {
if (owner_)
base::File auto_closer(value_);
}
+FileDescriptor& FileDescriptor::operator=(RValue other) {
+ Swap(other.object);
+ return *this;
+}
+
int FileDescriptor::value() const {
CHECK(valid_);
return value_;
@@ -35,10 +49,21 @@ int FileDescriptor::TakeValue() {
void FileDescriptor::CheckValidity() {
base::File file(value_);
+ if (!file.IsValid()) {
+ valid_ = false;
+ return;
+ }
+
base::File::Info info;
bool ok = file.GetInfo(&info);
file.TakePlatformFile(); // Prevent |value_| from being closed by |file|.
valid_ = (ok && !info.is_directory);
}
+void FileDescriptor::Swap(FileDescriptor* other) {
+ swap(value_, other->value_);
+ swap(owner_, other->owner_);
+ swap(valid_, other->valid_);
+}
+
} // namespace dbus
diff --git a/chromium/dbus/file_descriptor.h b/chromium/dbus/file_descriptor.h
index a01ee6ee011..8a4109789ec 100644
--- a/chromium/dbus/file_descriptor.h
+++ b/chromium/dbus/file_descriptor.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/move.h"
#include "dbus/dbus_export.h"
namespace dbus {
@@ -33,6 +34,8 @@ 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);
+
public:
// This provides a simple way to pass around file descriptors since they must
// be closed on a thread that is allowed to perform I/O.
@@ -46,8 +49,14 @@ 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);
+
virtual ~FileDescriptor();
+ // Move operator= for C++03 move emulation of this type.
+ FileDescriptor& operator=(RValue other);
+
// Retrieves value as an int without affecting ownership.
int value() const;
@@ -70,11 +79,11 @@ class CHROME_DBUS_EXPORT FileDescriptor {
void CheckValidity();
private:
+ void Swap(FileDescriptor* other);
+
int value_;
bool owner_;
bool valid_;
-
- DISALLOW_COPY_AND_ASSIGN(FileDescriptor);
};
using ScopedFileDescriptor =
diff --git a/chromium/dbus/message.cc b/chromium/dbus/message.cc
index ddcf85f4f26..3b021e50195 100644
--- a/chromium/dbus/message.cc
+++ b/chromium/dbus/message.cc
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/format_macros.h"
#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "dbus/object_path.h"
@@ -101,7 +102,7 @@ std::string Message::ToStringInternal(const std::string& indent,
uint8 value = 0;
if (!reader->PopByte(&value))
return kBrokenMessage;
- output += indent + "byte " + base::StringPrintf("%d", value) + "\n";
+ output += indent + "byte " + base::IntToString(value) + "\n";
break;
}
case BOOL: {
@@ -115,21 +116,21 @@ std::string Message::ToStringInternal(const std::string& indent,
int16 value = 0;
if (!reader->PopInt16(&value))
return kBrokenMessage;
- output += indent + "int16 " + base::StringPrintf("%d", value) + "\n";
+ output += indent + "int16 " + base::IntToString(value) + "\n";
break;
}
case UINT16: {
uint16 value = 0;
if (!reader->PopUint16(&value))
return kBrokenMessage;
- output += indent + "uint16 " + base::StringPrintf("%d", value) + "\n";
+ output += indent + "uint16 " + base::IntToString(value) + "\n";
break;
}
case INT32: {
int32 value = 0;
if (!reader->PopInt32(&value))
return kBrokenMessage;
- output += indent + "int32 " + base::StringPrintf("%d", value) + "\n";
+ output += indent + "int32 " + base::IntToString(value) + "\n";
break;
}
case UINT32: {
@@ -228,7 +229,7 @@ std::string Message::ToStringInternal(const std::string& indent,
if (!reader->PopFileDescriptor(&file_descriptor))
return kBrokenMessage;
output += indent + "fd#" +
- base::StringPrintf("%d", file_descriptor.value()) + "\n";
+ base::IntToString(file_descriptor.value()) + "\n";
break;
}
default:
diff --git a/chromium/dbus/object_manager_unittest.cc b/chromium/dbus/object_manager_unittest.cc
index 76ddb85fa8f..34f7ac40853 100644
--- a/chromium/dbus/object_manager_unittest.cc
+++ b/chromium/dbus/object_manager_unittest.cc
@@ -70,7 +70,7 @@ class ObjectManagerTest
// Start the test service, using the D-Bus thread.
TestService::Options options;
- options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread_->task_runner();
test_service_.reset(new TestService(options));
ASSERT_TRUE(test_service_->StartService());
ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
@@ -80,7 +80,7 @@ class ObjectManagerTest
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
- bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ bus_options.dbus_task_runner = dbus_thread_->task_runner();
bus_ = new Bus(bus_options);
ASSERT_TRUE(bus_->HasDBusThread());
diff --git a/chromium/dbus/property_unittest.cc b/chromium/dbus/property_unittest.cc
index 5208f848915..59faa22e1a8 100644
--- a/chromium/dbus/property_unittest.cc
+++ b/chromium/dbus/property_unittest.cc
@@ -61,7 +61,7 @@ class PropertyTest : public testing::Test {
// Start the test service, using the D-Bus thread.
TestService::Options options;
- options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread_->task_runner();
test_service_.reset(new TestService(options));
ASSERT_TRUE(test_service_->StartService());
ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
@@ -71,7 +71,7 @@ class PropertyTest : public testing::Test {
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
- bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ bus_options.dbus_task_runner = dbus_thread_->task_runner();
bus_ = new Bus(bus_options);
object_proxy_ = bus_->GetObjectProxy(
"org.chromium.TestService",
diff --git a/chromium/dbus/signal_sender_verification_unittest.cc b/chromium/dbus/signal_sender_verification_unittest.cc
index 0f718a4817b..0cedda74ae1 100644
--- a/chromium/dbus/signal_sender_verification_unittest.cc
+++ b/chromium/dbus/signal_sender_verification_unittest.cc
@@ -44,7 +44,7 @@ class SignalSenderVerificationTest : public testing::Test {
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
- bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ bus_options.dbus_task_runner = dbus_thread_->task_runner();
bus_ = new Bus(bus_options);
object_proxy_ = bus_->GetObjectProxy(
"org.chromium.TestService",
@@ -71,7 +71,7 @@ class SignalSenderVerificationTest : public testing::Test {
// Start the test service, using the D-Bus thread.
TestService::Options options;
- options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread_->task_runner();
test_service_.reset(new TestService(options));
ASSERT_TRUE(test_service_->StartService());
ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
@@ -278,7 +278,7 @@ TEST_F(SignalSenderVerificationTest, TestOwnerStealing) {
// Start a test service that allows theft, using the D-Bus thread.
TestService::Options options;
- options.dbus_task_runner = dbus_thread_->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread_->task_runner();
options.request_ownership_options = Bus::REQUIRE_PRIMARY_ALLOW_REPLACEMENT;
TestService stealable_test_service(options);
ASSERT_TRUE(stealable_test_service.StartService());
diff --git a/chromium/dbus/string_util.cc b/chromium/dbus/string_util.cc
index f35c9b3a7bc..0b077860308 100644
--- a/chromium/dbus/string_util.cc
+++ b/chromium/dbus/string_util.cc
@@ -14,7 +14,7 @@ bool IsValidObjectPath(const std::string& value) {
const bool kCaseSensitive = true;
// A valid object path begins with '/'.
- if (!StartsWithASCII(value, "/", kCaseSensitive))
+ if (!base::StartsWithASCII(value, "/", kCaseSensitive))
return false;
// Elements are pieces delimited by '/'. For instance, "org", "chromium",
@@ -39,7 +39,7 @@ bool IsValidObjectPath(const std::string& value) {
}
// A trailing '/' character is not allowed unless the path is the root path.
- if (value.size() > 1 && EndsWith(value, "/", kCaseSensitive))
+ if (value.size() > 1 && base::EndsWith(value, "/", kCaseSensitive))
return false;
return true;
diff --git a/chromium/dbus/test_server.cc b/chromium/dbus/test_server.cc
index 7e4722de9e9..1b630648b70 100644
--- a/chromium/dbus/test_server.cc
+++ b/chromium/dbus/test_server.cc
@@ -19,7 +19,7 @@ int main(int argc, char** argv) {
CHECK(dbus_thread->StartWithOptions(thread_options));
dbus::TestService::Options options;
- options.dbus_task_runner = dbus_thread->message_loop_proxy();
+ options.dbus_task_runner = dbus_thread->task_runner();
dbus::TestService* test_service = new dbus::TestService(options);
CHECK(test_service->StartService());
CHECK(test_service->WaitUntilServiceIsStarted());
diff --git a/chromium/dbus/values_util.cc b/chromium/dbus/values_util.cc
index c27c2723b84..c162878ee05 100644
--- a/chromium/dbus/values_util.cc
+++ b/chromium/dbus/values_util.cc
@@ -48,10 +48,10 @@ bool PopDictionaryEntries(MessageReader* reader,
} else {
// If the type of keys is not STRING, convert it to string.
scoped_ptr<base::Value> key(PopDataAsValue(&entry_reader));
- if (!key.get())
+ if (!key)
return false;
// Use JSONWriter to convert an arbitrary value to a string.
- base::JSONWriter::Write(key.get(), &key_string);
+ base::JSONWriter::Write(*key, &key_string);
}
// Get the value and set the key-value pair.
base::Value* value = PopDataAsValue(&entry_reader);
diff --git a/chromium/dbus/values_util_unittest.cc b/chromium/dbus/values_util_unittest.cc
index 27ec2d0c989..6abc56a717a 100644
--- a/chromium/dbus/values_util_unittest.cc
+++ b/chromium/dbus/values_util_unittest.cc
@@ -377,11 +377,9 @@ TEST(ValuesUtilTest, PopDoubleToIntDictionary) {
// Create the expected value.
base::DictionaryValue dictionary_value;
for (size_t i = 0; i != values.size(); ++i) {
- scoped_ptr<base::Value> key_value(new base::FundamentalValue(keys[i]));
std::string key_string;
- base::JSONWriter::Write(key_value.get(), &key_string);
- dictionary_value.SetWithoutPathExpansion(
- key_string, new base::FundamentalValue(values[i]));
+ base::JSONWriter::Write(base::FundamentalValue(keys[i]), &key_string);
+ dictionary_value.SetIntegerWithoutPathExpansion(key_string, values[i]);
}
// Pop a dictionary.