summaryrefslogtreecommitdiffstats
path: root/chromeos/device_event_log.cc
diff options
context:
space:
mode:
authorstevenjb <stevenjb@chromium.org>2014-12-18 14:03:38 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-18 22:05:08 +0000
commit9cfc3f8f868ec7c38f1e5025554c0caf837750a5 (patch)
tree2fbadeb769f156c848251c0a9b11107e69d10f9e /chromeos/device_event_log.cc
parent0374e30b2b498a91dad757e854c43590fc20ac52 (diff)
downloadchromium_src-9cfc3f8f868ec7c38f1e5025554c0caf837750a5.zip
chromium_src-9cfc3f8f868ec7c38f1e5025554c0caf837750a5.tar.gz
chromium_src-9cfc3f8f868ec7c38f1e5025554c0caf837750a5.tar.bz2
Add logging for slow device events, limit network UI update rate
This CL does the following: * Cleans up some redundant code in the network UI. * Disassociates Network UI updates from dbus calls and limits the frequency of UI updates by using a timer to trigger updates. * Adds NET_LOG_IF_SLOW to device_event_log.h to log slow network events. Note: I also did virtual/override cleanup while in there and ran clang format on the changed files. BUG=441650 Review URL: https://codereview.chromium.org/811623002 Cr-Commit-Position: refs/heads/master@{#309083}
Diffstat (limited to 'chromeos/device_event_log.cc')
-rw-r--r--chromeos/device_event_log.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/chromeos/device_event_log.cc b/chromeos/device_event_log.cc
index 8251e7d..aaded58 100644
--- a/chromeos/device_event_log.cc
+++ b/chromeos/device_event_log.cc
@@ -17,6 +17,9 @@ namespace {
const size_t kDefaultMaxEntries = 4000;
+const int kSlowMethodThresholdMs = 10;
+const int kVerySlowMethodThresholdMs = 50;
+
DeviceEventLogImpl* g_device_event_log = NULL;
} // namespace
@@ -83,6 +86,23 @@ DeviceEventLogInstance::~DeviceEventLogInstance() {
device_event_log::AddEntry(file_, line_, type_, level_, stream_.str());
}
+ScopedDeviceLogIfSlow::ScopedDeviceLogIfSlow(LogType type,
+ const char* file,
+ const std::string& name)
+ : file_(file), type_(type), name_(name) {
+}
+
+ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() {
+ if (timer_.Elapsed().InMilliseconds() >= kSlowMethodThresholdMs) {
+ LogLevel level(LOG_LEVEL_DEBUG);
+ if (timer_.Elapsed().InMilliseconds() >= kVerySlowMethodThresholdMs)
+ level = LOG_LEVEL_ERROR;
+ DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_
+ << ": " << timer_.Elapsed().InMilliseconds()
+ << "ms";
+ }
+}
+
} // namespace internal
} // namespace device_event_log