Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: dbus/object_proxy.cc

Issue 2239123002: dbus: Make Bus::GetManagedObjects skip unavailable services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dbus/object_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/object_proxy.h" 5 #include "dbus/object_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void ObjectProxy::WaitForServiceToBeAvailable( 201 void ObjectProxy::WaitForServiceToBeAvailable(
202 WaitForServiceToBeAvailableCallback callback) { 202 WaitForServiceToBeAvailableCallback callback) {
203 bus_->AssertOnOriginThread(); 203 bus_->AssertOnOriginThread();
204 204
205 wait_for_service_to_be_available_callbacks_.push_back(callback); 205 wait_for_service_to_be_available_callbacks_.push_back(callback);
206 bus_->GetDBusTaskRunner()->PostTask( 206 bus_->GetDBusTaskRunner()->PostTask(
207 FROM_HERE, 207 FROM_HERE,
208 base::Bind(&ObjectProxy::WaitForServiceToBeAvailableInternal, this)); 208 base::Bind(&ObjectProxy::WaitForServiceToBeAvailableInternal, this));
209 } 209 }
210 210
211 bool ObjectProxy::ServiceIsAvailable() {
212 return !service_name_owner_.empty();
hashimoto 2016/08/15 07:23:22 This member should be accessed only on the D-Bus t
213 }
214
211 void ObjectProxy::Detach() { 215 void ObjectProxy::Detach() {
212 bus_->AssertOnDBusThread(); 216 bus_->AssertOnDBusThread();
213 217
214 if (bus_->is_connected()) 218 if (bus_->is_connected())
215 bus_->RemoveFilterFunction(&ObjectProxy::HandleMessageThunk, this); 219 bus_->RemoveFilterFunction(&ObjectProxy::HandleMessageThunk, this);
216 220
217 for (const auto& match_rule : match_rules_) { 221 for (const auto& match_rule : match_rules_) {
218 ScopedDBusError error; 222 ScopedDBusError error;
219 bus_->RemoveMatch(match_rule, error.get()); 223 bus_->RemoveMatch(match_rule, error.get());
220 if (error.is_set()) { 224 if (error.is_set()) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 446
443 if (!ConnectToNameOwnerChangedSignal()) { // Failed to connect to the signal. 447 if (!ConnectToNameOwnerChangedSignal()) { // Failed to connect to the signal.
444 const bool service_is_ready = false; 448 const bool service_is_ready = false;
445 bus_->GetOriginTaskRunner()->PostTask( 449 bus_->GetOriginTaskRunner()->PostTask(
446 FROM_HERE, 450 FROM_HERE,
447 base::Bind(&ObjectProxy::RunWaitForServiceToBeAvailableCallbacks, 451 base::Bind(&ObjectProxy::RunWaitForServiceToBeAvailableCallbacks,
448 this, service_is_ready)); 452 this, service_is_ready));
449 return; 453 return;
450 } 454 }
451 455
452 const bool service_is_available = !service_name_owner_.empty(); 456 const bool service_is_available = ServiceIsAvailable();
453 if (service_is_available) { // Service is already available. 457 if (service_is_available) { // Service is already available.
454 bus_->GetOriginTaskRunner()->PostTask( 458 bus_->GetOriginTaskRunner()->PostTask(
455 FROM_HERE, 459 FROM_HERE,
456 base::Bind(&ObjectProxy::RunWaitForServiceToBeAvailableCallbacks, 460 base::Bind(&ObjectProxy::RunWaitForServiceToBeAvailableCallbacks,
457 this, service_is_available)); 461 this, service_is_available));
458 return; 462 return;
459 } 463 }
460 } 464 }
461 465
462 DBusHandlerResult ObjectProxy::HandleMessage( 466 DBusHandlerResult ObjectProxy::HandleMessage(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 bool service_is_available) { 712 bool service_is_available) {
709 bus_->AssertOnOriginThread(); 713 bus_->AssertOnOriginThread();
710 714
711 std::vector<WaitForServiceToBeAvailableCallback> callbacks; 715 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
712 callbacks.swap(wait_for_service_to_be_available_callbacks_); 716 callbacks.swap(wait_for_service_to_be_available_callbacks_);
713 for (size_t i = 0; i < callbacks.size(); ++i) 717 for (size_t i = 0; i < callbacks.size(); ++i)
714 callbacks[i].Run(service_is_available); 718 callbacks[i].Run(service_is_available);
715 } 719 }
716 720
717 } // namespace dbus 721 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/object_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698