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

Side by Side Diff: dbus/object_proxy.cc

Issue 11363173: Add DBusStatistics and DBusLogSource to log and show dbus stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
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"
11 #include "base/string_piece.h" 11 #include "base/string_piece.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "dbus/dbus_statistics.h"
15 #include "dbus/message.h" 16 #include "dbus/message.h"
16 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
17 #include "dbus/object_proxy.h" 18 #include "dbus/object_proxy.h"
18 #include "dbus/scoped_dbus_error.h" 19 #include "dbus/scoped_dbus_error.h"
19 20
20 namespace { 21 namespace {
21 22
22 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown"; 23 const char kErrorServiceUnknown[] = "org.freedesktop.DBus.Error.ServiceUnknown";
23 24
24 // Used for success ratio histograms. 1 for success, 0 for failure. 25 // Used for success ratio histograms. 1 for success, 0 for failure.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ScopedDBusError error; 77 ScopedDBusError error;
77 78
78 // Send the message synchronously. 79 // Send the message synchronously.
79 const base::TimeTicks start_time = base::TimeTicks::Now(); 80 const base::TimeTicks start_time = base::TimeTicks::Now();
80 DBusMessage* response_message = 81 DBusMessage* response_message =
81 bus_->SendWithReplyAndBlock(request_message, timeout_ms, error.get()); 82 bus_->SendWithReplyAndBlock(request_message, timeout_ms, error.get());
82 // Record if the method call is successful, or not. 1 if successful. 83 // Record if the method call is successful, or not. 1 if successful.
83 UMA_HISTOGRAM_ENUMERATION("DBus.SyncMethodCallSuccess", 84 UMA_HISTOGRAM_ENUMERATION("DBus.SyncMethodCallSuccess",
84 response_message ? 1 : 0, 85 response_message ? 1 : 0,
85 kSuccessRatioHistogramMaxValue); 86 kSuccessRatioHistogramMaxValue);
87 DbusStatistics::AddSentCall(service_name_,
satorux1 2012/11/12 00:40:43 This is a synchronous method call. We might want t
stevenjb 2012/11/12 19:46:40 That's makes sense. Done.
88 method_call->GetInterface(),
89 method_call->GetMember());
86 90
87 if (!response_message) { 91 if (!response_message) {
88 LogMethodCallFailure(method_call->GetInterface(), 92 LogMethodCallFailure(method_call->GetInterface(),
89 method_call->GetMember(), 93 method_call->GetMember(),
90 error.is_set() ? error.name() : "unknown error type", 94 error.is_set() ? error.name() : "unknown error type",
91 error.is_set() ? error.message() : ""); 95 error.is_set() ? error.message() : "");
92 return NULL; 96 return NULL;
93 } 97 }
94 // Record time spent for the method call. Don't include failures. 98 // Record time spent for the method call. Don't include failures.
95 UMA_HISTOGRAM_TIMES("DBus.SyncMethodCallTime", 99 UMA_HISTOGRAM_TIMES("DBus.SyncMethodCallTime",
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 DBusMessage* request_message = method_call->raw_message(); 141 DBusMessage* request_message = method_call->raw_message();
138 dbus_message_ref(request_message); 142 dbus_message_ref(request_message);
139 143
140 base::Closure task = base::Bind(&ObjectProxy::StartAsyncMethodCall, 144 base::Closure task = base::Bind(&ObjectProxy::StartAsyncMethodCall,
141 this, 145 this,
142 timeout_ms, 146 timeout_ms,
143 request_message, 147 request_message,
144 callback, 148 callback,
145 error_callback, 149 error_callback,
146 start_time); 150 start_time);
151 DbusStatistics::AddSentCall(service_name_,
152 method_call->GetInterface(),
153 method_call->GetMember());
154
147 // Wait for the response in the D-Bus thread. 155 // Wait for the response in the D-Bus thread.
148 bus_->PostTaskToDBusThread(FROM_HERE, task); 156 bus_->PostTaskToDBusThread(FROM_HERE, task);
149 } 157 }
150 158
151 void ObjectProxy::ConnectToSignal(const std::string& interface_name, 159 void ObjectProxy::ConnectToSignal(const std::string& interface_name,
152 const std::string& signal_name, 160 const std::string& signal_name,
153 SignalCallback signal_callback, 161 SignalCallback signal_callback,
154 OnConnectedCallback on_connected_callback) { 162 OnConnectedCallback on_connected_callback) {
155 bus_->AssertOnOriginThread(); 163 bus_->AssertOnOriginThread();
156 164
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 signal->GetMember() == "NameOwnerChanged") { 439 signal->GetMember() == "NameOwnerChanged") {
432 // Handle NameOwnerChanged separately 440 // Handle NameOwnerChanged separately
433 return HandleNameOwnerChanged(signal.get()); 441 return HandleNameOwnerChanged(signal.get());
434 } 442 }
435 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 443 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
436 } 444 }
437 445
438 const std::string interface = signal->GetInterface(); 446 const std::string interface = signal->GetInterface();
439 const std::string member = signal->GetMember(); 447 const std::string member = signal->GetMember();
440 448
449 DbusStatistics::AddReceivedCall(service_name_, interface, member);
450
441 // Check if we know about the signal. 451 // Check if we know about the signal.
442 const std::string absolute_signal_name = GetAbsoluteSignalName( 452 const std::string absolute_signal_name = GetAbsoluteSignalName(
443 interface, member); 453 interface, member);
444 MethodTable::const_iterator iter = method_table_.find(absolute_signal_name); 454 MethodTable::const_iterator iter = method_table_.find(absolute_signal_name);
445 if (iter == method_table_.end()) { 455 if (iter == method_table_.end()) {
446 // Don't know about the signal. 456 // Don't know about the signal.
447 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 457 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
448 } 458 }
449 VLOG(1) << "Signal received: " << signal->ToString(); 459 VLOG(1) << "Signal received: " << signal->ToString();
450 460
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 service_name_owner_ = new_owner; 646 service_name_owner_ = new_owner;
637 return DBUS_HANDLER_RESULT_HANDLED; 647 return DBUS_HANDLER_RESULT_HANDLED;
638 } 648 }
639 } 649 }
640 650
641 // Untrusted or uninteresting signal 651 // Untrusted or uninteresting signal
642 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 652 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
643 } 653 }
644 654
645 } // namespace dbus 655 } // namespace dbus
OLDNEW
« dbus/dbus_statistics_unittest.cc ('K') | « dbus/dbus_statistics_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698