summaryrefslogtreecommitdiffstats
path: root/chromeos/device_event_log.h
diff options
context:
space:
mode:
authorstevenjb <stevenjb@chromium.org>2015-01-08 17:46:56 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-09 01:47:49 +0000
commitaaa1265b918ee6195ffc84caf970d509bec18b32 (patch)
treeba89de149afd69f971edecb07ed5878c2d5cf583 /chromeos/device_event_log.h
parentcfb751267474d602441c22f8136ba77f28549368 (diff)
downloadchromium_src-aaa1265b918ee6195ffc84caf970d509bec18b32.zip
chromium_src-aaa1265b918ee6195ffc84caf970d509bec18b32.tar.gz
chromium_src-aaa1265b918ee6195ffc84caf970d509bec18b32.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. Original CL (reverted): https://codereview.chromium.org/811623002 BUG=441650 Review URL: https://codereview.chromium.org/800893003 Cr-Commit-Position: refs/heads/master@{#310659}
Diffstat (limited to 'chromeos/device_event_log.h')
-rw-r--r--chromeos/device_event_log.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/chromeos/device_event_log.h b/chromeos/device_event_log.h
index 34f02e3..a71f8d6 100644
--- a/chromeos/device_event_log.h
+++ b/chromeos/device_event_log.h
@@ -9,6 +9,7 @@
#include <sstream>
#include "base/basictypes.h"
+#include "base/timer/elapsed_timer.h"
#include "chromeos/chromeos_export.h"
namespace chromeos {
@@ -33,12 +34,23 @@ namespace chromeos {
DEVICE_LOG(::chromeos::device_event_log::LOG_TYPE_LOGIN, \
::chromeos::device_event_log::LOG_LEVEL_##level)
-// Generally prefer the above macros unless |level| is not constant.
+// Generally prefer the above macros unless |type| or |level| is not constant.
#define DEVICE_LOG(type, level) \
::chromeos::device_event_log::internal::DeviceEventLogInstance( \
__FILE__, __LINE__, type, level).stream()
+// Declare {Type_LOG_IF_SLOW() at the top of a method to log slow methods
+// where "slow" is defined by kSlowMethodThresholdMs in the .cc file.
+#define SCOPED_NET_LOG_IF_SLOW() \
+ SCOPED_DEVICE_LOG_IF_SLOW(::chromeos::device_event_log::LOG_TYPE_NETWORK)
+
+// Generally prefer the above macros unless |type| is not constant.
+
+#define SCOPED_DEVICE_LOG_IF_SLOW(type) \
+ ::chromeos::device_event_log::internal::ScopedDeviceLogIfSlow \
+ scoped_device_log_if_slow(type, __FILE__, __func__)
+
namespace device_event_log {
// Used to specify the type of event. NOTE: Be sure to update LogTypeFromString
@@ -117,6 +129,9 @@ CHROMEOS_EXPORT extern const LogLevel kDefaultLogLevel;
namespace internal {
+// Implementation class for DEVICE_LOG macros. Provides a stream for creating
+// a log string and adds the event using device_event_log::AddEntry on
+// destruction.
class CHROMEOS_EXPORT DeviceEventLogInstance {
public:
DeviceEventLogInstance(const char* file,
@@ -137,6 +152,23 @@ class CHROMEOS_EXPORT DeviceEventLogInstance {
DISALLOW_COPY_AND_ASSIGN(DeviceEventLogInstance);
};
+// Implementation class for SCOPED_LOG_IF_SLOW macros. Tests the elapsed time on
+// destruction and adds a Debug or Error log entry if it exceeds the
+// corresponding expected maximum elapsed time.
+class CHROMEOS_EXPORT ScopedDeviceLogIfSlow {
+ public:
+ ScopedDeviceLogIfSlow(LogType type,
+ const char* file,
+ const std::string& name);
+ ~ScopedDeviceLogIfSlow();
+
+ private:
+ const char* file_;
+ LogType type_;
+ std::string name_;
+ base::ElapsedTimer timer_;
+};
+
} // namespace internal
} // namespace device_event_log