Chromium Code Reviews| Index: dbus/object_proxy.cc |
| diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc |
| index 5da5901f888c0b5dbc73f0d81b4670d15662fec8..675c025198816f6240165eb3fca48bf88c82c41b 100644 |
| --- a/dbus/object_proxy.cc |
| +++ b/dbus/object_proxy.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <string.h> |
| + |
| #include "dbus/bus.h" |
| #include "base/bind.h" |
| @@ -17,6 +19,8 @@ |
| namespace { |
| +const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown"; |
| + |
| // Used for success ratio histograms. 1 for success, 0 for failure. |
| const int kSuccessRatioHistogramMaxValue = 2; |
| @@ -39,11 +43,14 @@ namespace dbus { |
| ObjectProxy::ObjectProxy(Bus* bus, |
| const std::string& service_name, |
| - const std::string& object_path) |
| + const std::string& object_path, |
| + ServiceUnknownBehavior service_unknown_behavior) |
| : bus_(bus), |
| service_name_(service_name), |
| object_path_(object_path), |
| - filter_added_(false) { |
| + filter_added_(false), |
| + log_unknown_service_errors_( |
| + service_unknown_behavior == LOG_SERVICE_UNKNOWN_ERRORS) { |
| } |
| ObjectProxy::~ObjectProxy() { |
| @@ -75,8 +82,13 @@ Response* ObjectProxy::CallMethodAndBlock(MethodCall* method_call, |
| kSuccessRatioHistogramMaxValue); |
| if (!response_message) { |
| - LOG(ERROR) << "Failed to call method: " |
| - << (error.is_set() ? error.message() : ""); |
| + const bool error_is_set = error.is_set(); |
|
satorux1
2012/02/10 08:12:52
The caching is unnecessary. You'll only save two b
adamk
2012/02/10 17:57:16
It wasn't obvious to me that error.is_set() was ch
|
| + const char* error_name = error_is_set ? error.name() : ""; |
| + if (log_unknown_service_errors_ || |
| + strcmp(error_name, kErrorServiceUnknown)) { |
|
satorux1
2012/02/10 08:12:52
strcmp() is hard to read. Please make it something
adamk
2012/02/10 17:57:16
Changed error_name to be a base::StringPiece.
|
| + LOG(ERROR) << "Failed to call method: " |
| + << (error_is_set ? error.message() : ""); |
| + } |
| return NULL; |
| } |
| // Record time spent for the method call. Don't include failures. |
| @@ -234,10 +246,13 @@ void ObjectProxy::RunResponseCallback(ResponseCallback response_callback, |
| dbus::ErrorResponse::FromRawMessage(response_message)); |
| // Error message may contain the error message as string. |
| dbus::MessageReader reader(error_response.get()); |
| - std::string error_message; |
| - reader.PopString(&error_message); |
| - LOG(ERROR) << "Failed to call method: " << error_response->GetErrorName() |
| - << ": " << error_message; |
| + std::string error_name = error_response->GetErrorName(); |
| + if (log_unknown_service_errors_ || error_name != kErrorServiceUnknown) { |
| + std::string error_message; |
| + reader.PopString(&error_message); |
| + LOG(ERROR) << "Failed to call method: " << error_name |
| + << ": " << error_message; |
| + } |
| // We don't give the error message to the callback. |
| response_callback.Run(NULL); |
| } else { |