diff options
author | stevenjb <stevenjb@chromium.org> | 2014-12-18 14:03:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-18 22:05:08 +0000 |
commit | 9cfc3f8f868ec7c38f1e5025554c0caf837750a5 (patch) | |
tree | 2fbadeb769f156c848251c0a9b11107e69d10f9e /chromeos/device_event_log.h | |
parent | 0374e30b2b498a91dad757e854c43590fc20ac52 (diff) | |
download | chromium_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.h')
-rw-r--r-- | chromeos/device_event_log.h | 34 |
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 |