Chromium Code Reviews| Index: dbus/exported_object.cc |
| diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc |
| index 8d36d155df797f37b3c2fda87b203ec0286e9abd..f706121bfe6080600a551a4efcb31819e4373000 100644 |
| --- a/dbus/exported_object.cc |
| +++ b/dbus/exported_object.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/logging.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/message_loop.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "base/time.h" |
| #include "dbus/bus.h" |
| @@ -100,11 +101,13 @@ void ExportedObject::SendSignal(Signal* signal) { |
| DBusMessage* signal_message = signal->raw_message(); |
| dbus_message_ref(signal_message); |
| + const base::TimeTicks start_time = base::TimeTicks::Now(); |
| // Bind() won't compile if we pass signal_message. See the comment at |
| // ObjectProxy::CallMethod() for details. |
| bus_->PostTaskToDBusThread(FROM_HERE, |
| base::Bind(&ExportedObject::SendSignalInternal, |
| this, |
| + start_time, |
| static_cast<void*>(signal_message))); |
| } |
| @@ -146,12 +149,18 @@ void ExportedObject::OnExported(OnExportedCallback on_exported_callback, |
| on_exported_callback.Run(interface_name, method_name, success); |
| } |
| -void ExportedObject::SendSignalInternal(void* in_signal_message) { |
| +void ExportedObject::SendSignalInternal(base::TimeTicks start_time, |
| + void* in_signal_message) { |
| DBusMessage* signal_message = |
| static_cast<DBusMessage*>(in_signal_message); |
| uint32 serial = 0; |
| bus_->Send(signal_message, &serial); |
| dbus_message_unref(signal_message); |
| + // Record time spent to send the the signal. This is not accurate as the |
| + // signal will actually be sent from the next run of the message loop, |
| + // but we can at least tell the number of signals sent. |
| + UMA_HISTOGRAM_TIMES("DBus.SignalSendTime", |
| + base::TimeTicks::Now() - start_time); |
| } |
| bool ExportedObject::Register() { |
| @@ -195,6 +204,7 @@ DBusHandlerResult ExportedObject::HandleMessage( |
| if (interface.empty()) { |
| // We don't support method calls without interface. |
| + LOG(WARNING) << "Interface is missing: " << method_call->ToString(); |
| return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| } |
| @@ -204,9 +214,11 @@ DBusHandlerResult ExportedObject::HandleMessage( |
| MethodTable::const_iterator iter = method_table_.find(absolute_method_name); |
| if (iter == method_table_.end()) { |
| // Don't know about the method. |
| + LOG(WARNING) << "Unknown method: " << method_call->ToString(); |
| return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
| } |
| + const base::TimeTicks start_time = base::TimeTicks::Now(); |
| Response* response = NULL; |
| if (bus_->HasDBusThread()) { |
| response_from_method_ = NULL; |
| @@ -237,6 +249,9 @@ DBusHandlerResult ExportedObject::HandleMessage( |
| // complete. |
| response = iter->second.Run(method_call.get()); |
| } |
| + // Record if the method call is successful, or not. 1 if successful. |
| + UMA_HISTOGRAM_ENUMERATION("DBus.ExportedMethodHandleSuccess", |
| + response ? 1 : 0, 2); |
|
stevenjb
2011/09/02 20:43:26
nit: What does the '2' refer to?
satorux1
2011/09/02 21:57:11
2 means this enumeration histogram takes values le
stevenjb
2011/09/06 16:51:04
const int histogram_max_value = 2;
On the other ha
satorux1
2011/09/06 17:32:04
You were right that 2 was cryptic. Introduced kSuc
|
| if (!response) { |
| // Something bad happened in the method call. |
| @@ -251,6 +266,9 @@ DBusHandlerResult ExportedObject::HandleMessage( |
| // The method call was successful. |
| dbus_connection_send(connection, response->raw_message(), NULL); |
| delete response; |
| + // Record time spent to handle the the method call. Don't include failures. |
| + UMA_HISTOGRAM_TIMES("DBus.ExportedMethodHandleTime", |
| + base::TimeTicks::Now() - start_time); |
| return DBUS_HANDLER_RESULT_HANDLED; |
| } |