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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 bus_->RequestOwnership("org.chromium.TestService", | 96 bus_->RequestOwnership("org.chromium.TestService", |
97 base::Bind(&TestService::OnOwnership, | 97 base::Bind(&TestService::OnOwnership, |
98 base::Unretained(this))); | 98 base::Unretained(this))); |
99 | 99 |
100 // Use "/" just like dbus-send does. | 100 // Use "/" just like dbus-send does. |
101 ExportedObject* root_object = | 101 ExportedObject* root_object = |
102 bus_->GetExportedObject(dbus::ObjectPath("/")); | 102 bus_->GetExportedObject(dbus::ObjectPath("/")); |
103 root_object->SendSignal(&signal); | 103 root_object->SendSignal(&signal); |
104 } | 104 } |
105 | 105 |
106 void TestService::RequestOwnership() { | |
107 message_loop()->PostTask( | |
satorux1
2012/10/26 05:26:00
Why do you need to post this to the message loop o
Haruki Sato
2012/10/26 05:53:13
Hmm,
Calling bus->RequestOwnership() here causes
| |
108 FROM_HERE, | |
109 base::Bind(&TestService::RequestOwnershipInternal, | |
110 base::Unretained(this))); | |
111 } | |
112 | |
113 void TestService::RequestOwnershipInternal() { | |
114 bus_->RequestOwnership("org.chromium.TestService", | |
115 base::Bind(&TestService::OnOwnership, | |
116 base::Unretained(this))); | |
117 } | |
118 | |
106 void TestService::OnOwnership(const std::string& service_name, | 119 void TestService::OnOwnership(const std::string& service_name, |
107 bool success) { | 120 bool success) { |
108 LOG_IF(ERROR, !success) << "Failed to own: " << service_name; | 121 LOG_IF(ERROR, !success) << "Failed to own: " << service_name; |
109 } | 122 } |
110 | 123 |
111 void TestService::OnExported(const std::string& interface_name, | 124 void TestService::OnExported(const std::string& interface_name, |
112 const std::string& method_name, | 125 const std::string& method_name, |
113 bool success) { | 126 bool success) { |
114 if (!success) { | 127 if (!success) { |
115 LOG(ERROR) << "Failed to export: " << interface_name << "." | 128 LOG(ERROR) << "Failed to export: " << interface_name << "." |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 array_writer.OpenDictEntry(&dict_entry_writer); | 458 array_writer.OpenDictEntry(&dict_entry_writer); |
446 dict_entry_writer.AppendString("Name"); | 459 dict_entry_writer.AppendString("Name"); |
447 dict_entry_writer.AppendVariantOfString(name); | 460 dict_entry_writer.AppendVariantOfString(name); |
448 array_writer.CloseContainer(&dict_entry_writer); | 461 array_writer.CloseContainer(&dict_entry_writer); |
449 writer.CloseContainer(&array_writer); | 462 writer.CloseContainer(&array_writer); |
450 | 463 |
451 exported_object_->SendSignal(&signal); | 464 exported_object_->SendSignal(&signal); |
452 } | 465 } |
453 | 466 |
454 } // namespace dbus | 467 } // namespace dbus |
OLD | NEW |