OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "dbus/test_service.h" | 5 #include "dbus/test_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 on_all_methods_exported_(false, false), | 39 on_all_methods_exported_(false, false), |
40 num_exported_methods_(0) { | 40 num_exported_methods_(0) { |
41 } | 41 } |
42 | 42 |
43 TestService::~TestService() { | 43 TestService::~TestService() { |
44 Stop(); | 44 Stop(); |
45 } | 45 } |
46 | 46 |
47 bool TestService::StartService() { | 47 bool TestService::StartService() { |
48 base::Thread::Options thread_options; | 48 base::Thread::Options thread_options; |
49 thread_options.message_loop_type = MessageLoop::TYPE_IO; | 49 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
50 return StartWithOptions(thread_options); | 50 return StartWithOptions(thread_options); |
51 } | 51 } |
52 | 52 |
53 bool TestService::WaitUntilServiceIsStarted() { | 53 bool TestService::WaitUntilServiceIsStarted() { |
54 const base::TimeDelta timeout(TestTimeouts::action_max_timeout()); | 54 const base::TimeDelta timeout(TestTimeouts::action_max_timeout()); |
55 // Wait until all methods are exported. | 55 // Wait until all methods are exported. |
56 return on_all_methods_exported_.TimedWait(timeout); | 56 return on_all_methods_exported_.TimedWait(timeout); |
57 } | 57 } |
58 | 58 |
59 void TestService::ShutdownAndBlock() { | 59 void TestService::ShutdownAndBlock() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Returning here will make WaitUntilServiceIsStarted() to time out | 146 // Returning here will make WaitUntilServiceIsStarted() to time out |
147 // and return false. | 147 // and return false. |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 ++num_exported_methods_; | 151 ++num_exported_methods_; |
152 if (num_exported_methods_ == kNumMethodsToExport) | 152 if (num_exported_methods_ == kNumMethodsToExport) |
153 on_all_methods_exported_.Signal(); | 153 on_all_methods_exported_.Signal(); |
154 } | 154 } |
155 | 155 |
156 void TestService::Run(MessageLoop* message_loop) { | 156 void TestService::Run(base::MessageLoop* message_loop) { |
157 Bus::Options bus_options; | 157 Bus::Options bus_options; |
158 bus_options.bus_type = Bus::SESSION; | 158 bus_options.bus_type = Bus::SESSION; |
159 bus_options.connection_type = Bus::PRIVATE; | 159 bus_options.connection_type = Bus::PRIVATE; |
160 bus_options.dbus_task_runner = dbus_task_runner_; | 160 bus_options.dbus_task_runner = dbus_task_runner_; |
161 bus_ = new Bus(bus_options); | 161 bus_ = new Bus(bus_options); |
162 | 162 |
163 bus_->RequestOwnership("org.chromium.TestService", | 163 bus_->RequestOwnership("org.chromium.TestService", |
164 base::Bind(&TestService::OnOwnership, | 164 base::Bind(&TestService::OnOwnership, |
165 base::Unretained(this), | 165 base::Unretained(this), |
166 base::Bind(&EmptyCallback))); | 166 base::Bind(&EmptyCallback))); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 array_writer.OpenDictEntry(&dict_entry_writer); | 611 array_writer.OpenDictEntry(&dict_entry_writer); |
612 dict_entry_writer.AppendString("Name"); | 612 dict_entry_writer.AppendString("Name"); |
613 dict_entry_writer.AppendVariantOfString(name); | 613 dict_entry_writer.AppendVariantOfString(name); |
614 array_writer.CloseContainer(&dict_entry_writer); | 614 array_writer.CloseContainer(&dict_entry_writer); |
615 writer.CloseContainer(&array_writer); | 615 writer.CloseContainer(&array_writer); |
616 | 616 |
617 exported_object_->SendSignal(&signal); | 617 exported_object_->SendSignal(&signal); |
618 } | 618 } |
619 | 619 |
620 } // namespace dbus | 620 } // namespace dbus |
OLD | NEW |