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

Side by Side Diff: dbus/object_proxy.cc

Issue 9808001: dbus: don't fail when reconnecting object signals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add docs and unit test Created 8 years, 9 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 | Annotate | Revision Log
« 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/bus.h" 5 #include "dbus/bus.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 delete data; 274 delete data;
275 } 275 }
276 276
277 void ObjectProxy::ConnectToSignalInternal( 277 void ObjectProxy::ConnectToSignalInternal(
278 const std::string& interface_name, 278 const std::string& interface_name,
279 const std::string& signal_name, 279 const std::string& signal_name,
280 SignalCallback signal_callback, 280 SignalCallback signal_callback,
281 OnConnectedCallback on_connected_callback) { 281 OnConnectedCallback on_connected_callback) {
282 bus_->AssertOnDBusThread(); 282 bus_->AssertOnDBusThread();
283 283
284 // Check if the object is already connected to the signal.
285 const std::string absolute_signal_name = 284 const std::string absolute_signal_name =
286 GetAbsoluteSignalName(interface_name, signal_name); 285 GetAbsoluteSignalName(interface_name, signal_name);
287 if (method_table_.find(absolute_signal_name) != method_table_.end()) {
288 LOG(ERROR) << "The object proxy is already connected to "
289 << absolute_signal_name;
290 return;
291 }
292 286
293 // Will become true, if everything is successful. 287 // Will become true, if everything is successful.
294 bool success = false; 288 bool success = false;
295 289
296 if (bus_->Connect() && bus_->SetUpAsyncOperations()) { 290 if (bus_->Connect() && bus_->SetUpAsyncOperations()) {
297 // We should add the filter only once. Otherwise, HandleMessage() will 291 // We should add the filter only once. Otherwise, HandleMessage() will
298 // be called more than once. 292 // be called more than once.
299 if (!filter_added_) { 293 if (!filter_added_) {
300 if (bus_->AddFilterFunction(&ObjectProxy::HandleMessageThunk, this)) { 294 if (bus_->AddFilterFunction(&ObjectProxy::HandleMessageThunk, this)) {
301 filter_added_ = true; 295 filter_added_ = true;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void ObjectProxy::LogMethodCallFailure( 423 void ObjectProxy::LogMethodCallFailure(
430 const base::StringPiece& error_name, 424 const base::StringPiece& error_name,
431 const base::StringPiece& error_message) const { 425 const base::StringPiece& error_message) const {
432 if (ignore_service_unknown_errors_ && error_name == kErrorServiceUnknown) 426 if (ignore_service_unknown_errors_ && error_name == kErrorServiceUnknown)
433 return; 427 return;
434 LOG(ERROR) << "Failed to call method: " << error_name 428 LOG(ERROR) << "Failed to call method: " << error_name
435 << ": " << error_message; 429 << ": " << error_message;
436 } 430 }
437 431
438 } // namespace dbus 432 } // 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