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 15 matching lines...) Expand all Loading... |
26 const int TestService::kNumMethodsToExport = 7; | 26 const int TestService::kNumMethodsToExport = 7; |
27 | 27 |
28 TestService::Options::Options() { | 28 TestService::Options::Options() { |
29 } | 29 } |
30 | 30 |
31 TestService::Options::~Options() { | 31 TestService::Options::~Options() { |
32 } | 32 } |
33 | 33 |
34 TestService::TestService(const Options& options) | 34 TestService::TestService(const Options& options) |
35 : base::Thread("TestService"), | 35 : base::Thread("TestService"), |
36 dbus_thread_message_loop_proxy_(options.dbus_thread_message_loop_proxy), | 36 dbus_task_runner_(options.dbus_task_runner), |
37 on_all_methods_exported_(false, false), | 37 on_all_methods_exported_(false, false), |
38 num_exported_methods_(0) { | 38 num_exported_methods_(0) { |
39 } | 39 } |
40 | 40 |
41 TestService::~TestService() { | 41 TestService::~TestService() { |
42 Stop(); | 42 Stop(); |
43 } | 43 } |
44 | 44 |
45 bool TestService::StartService() { | 45 bool TestService::StartService() { |
46 base::Thread::Options thread_options; | 46 base::Thread::Options thread_options; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 ++num_exported_methods_; | 149 ++num_exported_methods_; |
150 if (num_exported_methods_ == kNumMethodsToExport) | 150 if (num_exported_methods_ == kNumMethodsToExport) |
151 on_all_methods_exported_.Signal(); | 151 on_all_methods_exported_.Signal(); |
152 } | 152 } |
153 | 153 |
154 void TestService::Run(MessageLoop* message_loop) { | 154 void TestService::Run(MessageLoop* message_loop) { |
155 Bus::Options bus_options; | 155 Bus::Options bus_options; |
156 bus_options.bus_type = Bus::SESSION; | 156 bus_options.bus_type = Bus::SESSION; |
157 bus_options.connection_type = Bus::PRIVATE; | 157 bus_options.connection_type = Bus::PRIVATE; |
158 bus_options.dbus_thread_message_loop_proxy = dbus_thread_message_loop_proxy_; | 158 bus_options.dbus_task_runner = dbus_task_runner_; |
159 bus_ = new Bus(bus_options); | 159 bus_ = new Bus(bus_options); |
160 | 160 |
161 bus_->RequestOwnership("org.chromium.TestService", | 161 bus_->RequestOwnership("org.chromium.TestService", |
162 base::Bind(&TestService::OnOwnership, | 162 base::Bind(&TestService::OnOwnership, |
163 base::Unretained(this), | 163 base::Unretained(this), |
164 base::Bind(&EmptyCallback))); | 164 base::Bind(&EmptyCallback))); |
165 | 165 |
166 exported_object_ = bus_->GetExportedObject( | 166 exported_object_ = bus_->GetExportedObject( |
167 dbus::ObjectPath("/org/chromium/TestObject")); | 167 dbus::ObjectPath("/org/chromium/TestObject")); |
168 | 168 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 array_writer.OpenDictEntry(&dict_entry_writer); | 472 array_writer.OpenDictEntry(&dict_entry_writer); |
473 dict_entry_writer.AppendString("Name"); | 473 dict_entry_writer.AppendString("Name"); |
474 dict_entry_writer.AppendVariantOfString(name); | 474 dict_entry_writer.AppendVariantOfString(name); |
475 array_writer.CloseContainer(&dict_entry_writer); | 475 array_writer.CloseContainer(&dict_entry_writer); |
476 writer.CloseContainer(&array_writer); | 476 writer.CloseContainer(&array_writer); |
477 | 477 |
478 exported_object_->SendSignal(&signal); | 478 exported_object_->SendSignal(&signal); |
479 } | 479 } |
480 | 480 |
481 } // namespace dbus | 481 } // namespace dbus |
OLD | NEW |