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

Side by Side Diff: dbus/object_manager.cc

Issue 2239123002: dbus: Make Bus::GetManagedObjects skip unavailable services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove call to WaitForServiceToBeAvailable Created 4 years, 3 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_manager.h ('k') | device/bluetooth/dbus/bluez_dbus_manager.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_manager.h" 5 #include "dbus/object_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bus_->RemoveFilterFunction(&ObjectManager::HandleMessageThunk, this); 160 bus_->RemoveFilterFunction(&ObjectManager::HandleMessageThunk, this);
161 161
162 ScopedDBusError error; 162 ScopedDBusError error;
163 bus_->RemoveMatch(match_rule_, error.get()); 163 bus_->RemoveMatch(match_rule_, error.get());
164 if (error.is_set()) 164 if (error.is_set())
165 LOG(ERROR) << "Failed to remove match rule: " << match_rule_; 165 LOG(ERROR) << "Failed to remove match rule: " << match_rule_;
166 166
167 match_rule_.clear(); 167 match_rule_.clear();
168 } 168 }
169 169
170 void ObjectManager::InitializeObjects() {
171 DCHECK(bus_);
172 DCHECK(object_proxy_);
173 DCHECK(setup_success_);
174
175 // |object_proxy_| is no longer valid if the Bus was shut down before this
176 // call. Don't initiate any other action from the origin thread.
177 if (cleanup_called_)
178 return;
179
180 object_proxy_->ConnectToSignal(
181 kObjectManagerInterface,
182 kObjectManagerInterfacesAdded,
183 base::Bind(&ObjectManager::InterfacesAddedReceived,
184 weak_ptr_factory_.GetWeakPtr()),
185 base::Bind(&ObjectManager::InterfacesAddedConnected,
186 weak_ptr_factory_.GetWeakPtr()));
187
188 object_proxy_->ConnectToSignal(
189 kObjectManagerInterface,
190 kObjectManagerInterfacesRemoved,
191 base::Bind(&ObjectManager::InterfacesRemovedReceived,
192 weak_ptr_factory_.GetWeakPtr()),
193 base::Bind(&ObjectManager::InterfacesRemovedConnected,
194 weak_ptr_factory_.GetWeakPtr()));
195
196 GetManagedObjects();
197 }
198
199 bool ObjectManager::SetupMatchRuleAndFilter() { 170 bool ObjectManager::SetupMatchRuleAndFilter() {
200 DCHECK(bus_); 171 DCHECK(bus_);
201 DCHECK(!setup_success_); 172 DCHECK(!setup_success_);
202 bus_->AssertOnDBusThread(); 173 bus_->AssertOnDBusThread();
203 174
204 if (cleanup_called_) 175 if (cleanup_called_)
205 return false; 176 return false;
206 177
207 if (!bus_->Connect() || !bus_->SetUpAsyncOperations()) 178 if (!bus_->Connect() || !bus_->SetUpAsyncOperations())
208 return false; 179 return false;
(...skipping 19 matching lines...) Expand all
228 return false; 199 return false;
229 } 200 }
230 201
231 match_rule_ = match_rule; 202 match_rule_ = match_rule;
232 setup_success_ = true; 203 setup_success_ = true;
233 204
234 return true; 205 return true;
235 } 206 }
236 207
237 void ObjectManager::OnSetupMatchRuleAndFilterComplete(bool success) { 208 void ObjectManager::OnSetupMatchRuleAndFilterComplete(bool success) {
238 LOG_IF(WARNING, !success) << service_name_ << " " << object_path_.value() 209 if (!success) {
239 << ": Failed to set up match rule."; 210 LOG(WARNING) << service_name_ << " " << object_path_.value()
240 if (success) 211 << ": Failed to set up match rule.";
241 InitializeObjects(); 212 return;
213 }
214
215 DCHECK(bus_);
216 DCHECK(object_proxy_);
217 DCHECK(setup_success_);
218
219 // |object_proxy_| is no longer valid if the Bus was shut down before this
220 // call. Don't initiate any other action from the origin thread.
221 if (cleanup_called_)
222 return;
223
224 object_proxy_->ConnectToSignal(
225 kObjectManagerInterface,
226 kObjectManagerInterfacesAdded,
227 base::Bind(&ObjectManager::InterfacesAddedReceived,
228 weak_ptr_factory_.GetWeakPtr()),
229 base::Bind(&ObjectManager::InterfacesAddedConnected,
230 weak_ptr_factory_.GetWeakPtr()));
231
232 object_proxy_->ConnectToSignal(
233 kObjectManagerInterface,
234 kObjectManagerInterfacesRemoved,
235 base::Bind(&ObjectManager::InterfacesRemovedReceived,
236 weak_ptr_factory_.GetWeakPtr()),
237 base::Bind(&ObjectManager::InterfacesRemovedConnected,
238 weak_ptr_factory_.GetWeakPtr()));
239
240 if (!service_name_owner_.empty())
241 GetManagedObjects();
242 } 242 }
243 243
244 // static 244 // static
245 DBusHandlerResult ObjectManager::HandleMessageThunk(DBusConnection* connection, 245 DBusHandlerResult ObjectManager::HandleMessageThunk(DBusConnection* connection,
246 DBusMessage* raw_message, 246 DBusMessage* raw_message,
247 void* user_data) { 247 void* user_data) {
248 ObjectManager* self = reinterpret_cast<ObjectManager*>(user_data); 248 ObjectManager* self = reinterpret_cast<ObjectManager*>(user_data);
249 return self->HandleMessage(connection, raw_message); 249 return self->HandleMessage(connection, raw_message);
250 } 250 }
251 251
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 RemoveInterface(object_path, *iiter); 526 RemoveInterface(object_path, *iiter);
527 } 527 }
528 528
529 } 529 }
530 530
531 if (!new_owner.empty()) 531 if (!new_owner.empty())
532 GetManagedObjects(); 532 GetManagedObjects();
533 } 533 }
534 534
535 } // namespace dbus 535 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/object_manager.h ('k') | device/bluetooth/dbus/bluez_dbus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698