Skip to content

Commit

Permalink
dbus: Use base::MessageLoop.
Browse files Browse the repository at this point in the history
BUG=236029
R=keybuk@chromium.org

Review URL: https://chromiumcodereview.appspot.com/14386016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197629 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
xhwang@chromium.org committed May 1, 2013
1 parent 89ba386 commit ff33b18
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 30 deletions.
20 changes: 8 additions & 12 deletions dbus/bus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,19 @@ class Watch : public base::MessagePumpLibevent::Watcher {
const int file_descriptor = dbus_watch_get_unix_fd(raw_watch_);
const int flags = dbus_watch_get_flags(raw_watch_);

MessageLoopForIO::Mode mode = MessageLoopForIO::WATCH_READ;
base::MessageLoopForIO::Mode mode = base::MessageLoopForIO::WATCH_READ;
if ((flags & DBUS_WATCH_READABLE) && (flags & DBUS_WATCH_WRITABLE))
mode = MessageLoopForIO::WATCH_READ_WRITE;
mode = base::MessageLoopForIO::WATCH_READ_WRITE;
else if (flags & DBUS_WATCH_READABLE)
mode = MessageLoopForIO::WATCH_READ;
mode = base::MessageLoopForIO::WATCH_READ;
else if (flags & DBUS_WATCH_WRITABLE)
mode = MessageLoopForIO::WATCH_WRITE;
mode = base::MessageLoopForIO::WATCH_WRITE;
else
NOTREACHED();

const bool persistent = true; // Watch persistently.
const bool success = MessageLoopForIO::current()->WatchFileDescriptor(
file_descriptor,
persistent,
mode,
&file_descriptor_watcher_,
this);
const bool success = base::MessageLoopForIO::current()->WatchFileDescriptor(
file_descriptor, persistent, mode, &file_descriptor_watcher_, this);
CHECK(success) << "Unable to allocate memory";
}

Expand Down Expand Up @@ -196,8 +192,8 @@ Bus::Bus(const Options& options)
dbus_threads_init_default();
// The origin message loop is unnecessary if the client uses synchronous
// functions only.
if (MessageLoop::current())
origin_task_runner_ = MessageLoop::current()->message_loop_proxy();
if (base::MessageLoop::current())
origin_task_runner_ = base::MessageLoop::current()->message_loop_proxy();
}

Bus::~Bus() {
Expand Down
8 changes: 4 additions & 4 deletions dbus/bus_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ TEST(BusTest, GetObjectProxyIgnoreUnknownService) {

TEST(BusTest, RemoveObjectProxy) {
// Setup the current thread's MessageLoop.
MessageLoop message_loop;
base::MessageLoop message_loop;

// Start the D-Bus thread.
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
base::Thread dbus_thread("D-Bus thread");
dbus_thread.StartWithOptions(thread_options);

Expand Down Expand Up @@ -171,7 +171,7 @@ TEST(BusTest, GetExportedObject) {
TEST(BusTest, UnregisterExportedObject) {
// Start the D-Bus thread.
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
base::Thread dbus_thread("D-Bus thread");
dbus_thread.StartWithOptions(thread_options);

Expand Down Expand Up @@ -221,7 +221,7 @@ TEST(BusTest, ShutdownAndBlock) {
TEST(BusTest, ShutdownAndBlockWithDBusThread) {
// Start the D-Bus thread.
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
base::Thread dbus_thread("D-Bus thread");
dbus_thread.StartWithOptions(thread_options);

Expand Down
6 changes: 3 additions & 3 deletions dbus/end_to_end_async_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EndToEndAsyncTest : public testing::Test {
// Start the D-Bus thread.
dbus_thread_.reset(new base::Thread("D-Bus Thread"));
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));

// Start the test service, using the D-Bus thread.
Expand Down Expand Up @@ -253,7 +253,7 @@ class EndToEndAsyncTest : public testing::Test {
message_loop_.Run();
}

MessageLoop message_loop_;
base::MessageLoop message_loop_;
std::vector<std::string> response_strings_;
std::vector<std::string> error_names_;
scoped_ptr<base::Thread> dbus_thread_;
Expand Down Expand Up @@ -537,7 +537,7 @@ TEST_F(EndToEndAsyncTest, EmptyResponseCallback) {
dbus::ObjectProxy::EmptyResponseCallback());
// Post a delayed task to quit the message loop.
message_loop_.PostDelayedTask(FROM_HERE,
MessageLoop::QuitClosure(),
base::MessageLoop::QuitClosure(),
TestTimeouts::tiny_timeout());
message_loop_.Run();
// We cannot tell if the empty callback is called, but at least we can
Expand Down
2 changes: 1 addition & 1 deletion dbus/mock_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MockTest : public testing::Test {

protected:
std::string response_string_;
MessageLoop message_loop_;
base::MessageLoop message_loop_;
scoped_refptr<dbus::MockBus> mock_bus_;
scoped_refptr<dbus::MockObjectProxy> mock_proxy_;

Expand Down
4 changes: 2 additions & 2 deletions dbus/object_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ObjectManagerTest
// Start the D-Bus thread.
dbus_thread_.reset(new base::Thread("D-Bus Thread"));
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));

// Start the test service, using the D-Bus thread.
Expand Down Expand Up @@ -176,7 +176,7 @@ class ObjectManagerTest
WaitForMethodCallback();
}

MessageLoop message_loop_;
base::MessageLoop message_loop_;
scoped_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> bus_;
dbus::ObjectManager* object_manager_;
Expand Down
4 changes: 2 additions & 2 deletions dbus/property_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PropertyTest : public testing::Test {
// Start the D-Bus thread.
dbus_thread_.reset(new base::Thread("D-Bus Thread"));
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));

// Start the test service, using the D-Bus thread.
Expand Down Expand Up @@ -136,7 +136,7 @@ class PropertyTest : public testing::Test {
}
}

MessageLoop message_loop_;
base::MessageLoop message_loop_;
scoped_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> bus_;
dbus::ObjectProxy* object_proxy_;
Expand Down
4 changes: 2 additions & 2 deletions dbus/signal_sender_verification_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SignalSenderVerificationTest : public testing::Test {
// Start the D-Bus thread.
dbus_thread_.reset(new base::Thread("D-Bus Thread"));
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));

// Create the client, using the D-Bus thread.
Expand Down Expand Up @@ -152,7 +152,7 @@ class SignalSenderVerificationTest : public testing::Test {
message_loop_.Run();
}

MessageLoop message_loop_;
base::MessageLoop message_loop_;
scoped_ptr<base::Thread> dbus_thread_;
scoped_refptr<dbus::Bus> bus_;
dbus::ObjectProxy* object_proxy_;
Expand Down
2 changes: 1 addition & 1 deletion dbus/test_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char** argv) {

base::Thread* dbus_thread = new base::Thread("D-Bus Thread");
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
CHECK(dbus_thread->StartWithOptions(thread_options));

dbus::TestService::Options options;
Expand Down
4 changes: 2 additions & 2 deletions dbus/test_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TestService::~TestService() {

bool TestService::StartService() {
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
return StartWithOptions(thread_options);
}

Expand Down Expand Up @@ -153,7 +153,7 @@ void TestService::OnExported(const std::string& interface_name,
on_all_methods_exported_.Signal();
}

void TestService::Run(MessageLoop* message_loop) {
void TestService::Run(base::MessageLoop* message_loop) {
Bus::Options bus_options;
bus_options.bus_type = Bus::SESSION;
bus_options.connection_type = Bus::PRIVATE;
Expand Down
2 changes: 1 addition & 1 deletion dbus/test_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TestService : public base::Thread {
bool success);

// base::Thread override.
virtual void Run(MessageLoop* message_loop) OVERRIDE;
virtual void Run(base::MessageLoop* message_loop) OVERRIDE;

//
// Exported methods.
Expand Down

0 comments on commit ff33b18

Please sign in to comment.