Chromium Code Reviews| 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/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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "dbus/dbus_statistics.h" | 16 #include "dbus/dbus_statistics.h" |
| 17 #include "dbus/message.h" | 17 #include "dbus/message.h" |
| 18 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
| 19 #include "dbus/object_proxy.h" | 19 #include "dbus/object_proxy.h" |
| 20 #include "dbus/scoped_dbus_error.h" | 20 #include "dbus/scoped_dbus_error.h" |
| 21 | 21 |
| 22 namespace dbus { | 22 namespace dbus { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown"; | 26 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown"; |
| 27 const char kErrorObjectUnknown[] = "org.freedesktop.DBus.Error.UnknownObject"; | |
| 27 | 28 |
| 28 // Used for success ratio histograms. 1 for success, 0 for failure. | 29 // Used for success ratio histograms. 1 for success, 0 for failure. |
| 29 const int kSuccessRatioHistogramMaxValue = 2; | 30 const int kSuccessRatioHistogramMaxValue = 2; |
| 30 | 31 |
| 31 // The path of D-Bus Object sending NameOwnerChanged signal. | 32 // The path of D-Bus Object sending NameOwnerChanged signal. |
| 32 const char kDBusSystemObjectPath[] = "/org/freedesktop/DBus"; | 33 const char kDBusSystemObjectPath[] = "/org/freedesktop/DBus"; |
| 33 | 34 |
| 34 // The D-Bus Object interface. | 35 // The D-Bus Object interface. |
| 35 const char kDBusSystemObjectInterface[] = "org.freedesktop.DBus"; | 36 const char kDBusSystemObjectInterface[] = "org.freedesktop.DBus"; |
| 36 | 37 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 void* user_data) { | 555 void* user_data) { |
| 555 ObjectProxy* self = reinterpret_cast<ObjectProxy*>(user_data); | 556 ObjectProxy* self = reinterpret_cast<ObjectProxy*>(user_data); |
| 556 return self->HandleMessage(connection, raw_message); | 557 return self->HandleMessage(connection, raw_message); |
| 557 } | 558 } |
| 558 | 559 |
| 559 void ObjectProxy::LogMethodCallFailure( | 560 void ObjectProxy::LogMethodCallFailure( |
| 560 const base::StringPiece& interface_name, | 561 const base::StringPiece& interface_name, |
| 561 const base::StringPiece& method_name, | 562 const base::StringPiece& method_name, |
| 562 const base::StringPiece& error_name, | 563 const base::StringPiece& error_name, |
| 563 const base::StringPiece& error_message) const { | 564 const base::StringPiece& error_message) const { |
| 564 if (ignore_service_unknown_errors_ && error_name == kErrorServiceUnknown) | 565 if (ignore_service_unknown_errors_ && |
| 566 (error_name == kErrorServiceUnknown || error_name == kErrorObjectUnknown)) | |
| 565 return; | 567 return; |
| 568 logging::LogSeverity severity = logging::LOG_ERROR; | |
| 569 // "UnknownObject" indicates that an object or service is no longer available, | |
| 570 // e.g. a Shill network service has gone out of range. Treat these as warnings | |
| 571 // not errors. | |
| 572 if (error_name == kErrorObjectUnknown) | |
| 573 severity = logging::LOG_WARNING; | |
|
hashimoto
2014/08/08 02:46:31
This variable looks unused and it seems we never r
hashimoto
2014/08/08 07:28:46
Sorry, I dismissed "ignore_service_unknown_errors_
stevenjb
2014/08/08 16:31:58
Oops, thanks for catching, fixed.
| |
| 566 LOG(ERROR) << "Failed to call method: " | 574 LOG(ERROR) << "Failed to call method: " |
| 567 << interface_name << "." << method_name | 575 << interface_name << "." << method_name |
| 568 << ": object_path= " << object_path_.value() | 576 << ": object_path= " << object_path_.value() |
| 569 << ": " << error_name << ": " << error_message; | 577 << ": " << error_name << ": " << error_message; |
| 570 } | 578 } |
| 571 | 579 |
| 572 void ObjectProxy::OnCallMethodError(const std::string& interface_name, | 580 void ObjectProxy::OnCallMethodError(const std::string& interface_name, |
| 573 const std::string& method_name, | 581 const std::string& method_name, |
| 574 ResponseCallback response_callback, | 582 ResponseCallback response_callback, |
| 575 ErrorResponse* error_response) { | 583 ErrorResponse* error_response) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 bool service_is_available) { | 702 bool service_is_available) { |
| 695 bus_->AssertOnOriginThread(); | 703 bus_->AssertOnOriginThread(); |
| 696 | 704 |
| 697 std::vector<WaitForServiceToBeAvailableCallback> callbacks; | 705 std::vector<WaitForServiceToBeAvailableCallback> callbacks; |
| 698 callbacks.swap(wait_for_service_to_be_available_callbacks_); | 706 callbacks.swap(wait_for_service_to_be_available_callbacks_); |
| 699 for (size_t i = 0; i < callbacks.size(); ++i) | 707 for (size_t i = 0; i < callbacks.size(); ++i) |
| 700 callbacks[i].Run(service_is_available); | 708 callbacks[i].Run(service_is_available); |
| 701 } | 709 } |
| 702 | 710 |
| 703 } // namespace dbus | 711 } // namespace dbus |
| OLD | NEW |