Chromium Code Reviews| Index: chromeos/device_event_log.h |
| diff --git a/chromeos/device_event_log.h b/chromeos/device_event_log.h |
| index 34f02e3678b1d179ac864dd4e5d631e30e7d8fc0..094638941a5c36756709eb0a060f6a4963fe9fa5 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 { |
| @@ -39,6 +40,15 @@ namespace chromeos { |
| ::chromeos::device_event_log::internal::DeviceEventLogInstance( \ |
| __FILE__, __LINE__, type, level).stream() |
| +// Declare NET_LOG_IF_SLOW() at the top of a method to log slow methods |
| +// where "slow" is defined by kSlowMethodThresholdMs in the .cc file. |
| +#define NET_LOG_IF_SLOW() \ |
|
satorux1
2014/12/16 03:29:43
Maybe SCOPED_NET_LOG_IF_SLOW() because it depends
stevenjb
2014/12/16 19:12:58
Hmm, I kind of like it short, but I guess a little
|
| + DEVICE_LOG_IF_SLOW(::chromeos::device_event_log::LOG_TYPE_NETWORK) |
| + |
| +#define DEVICE_LOG_IF_SLOW(type) \ |
|
satorux1
2014/12/16 03:29:44
this looks like a generic tool. maybe define this
stevenjb
2014/12/16 19:12:58
I'll add a comment like I did above with DEVICE_LO
|
| + ::chromeos::device_event_log::internal::DeviceLogIfSlow _elapsed_( \ |
|
satorux1
2014/12/16 03:29:43
is _elapsed_ a variable name? names starting with
stevenjb
2014/12/16 19:12:58
Hmm. I intentionally wanted to use a variable that
satorux1
2014/12/18 05:18:51
Would something like work?
elapsed_ ## __LINE__
stevenjb
2014/12/18 18:16:17
That would have been clever, but I think the long
|
| + type, __FILE__, __func__) |
|
satorux1
2014/12/16 03:29:44
use __LINE__ as well?
Also it might be nicer to r
stevenjb
2014/12/16 19:12:58
__LINE__ doesn't add any info since we are timing
satorux1
2014/12/18 05:18:51
SGTM. I originally thought this could be used mult
stevenjb
2014/12/18 18:16:17
In theory it could be used within a scope, but yea
|
| + |
| namespace device_event_log { |
| // Used to specify the type of event. NOTE: Be sure to update LogTypeFromString |
| @@ -137,6 +147,18 @@ class CHROMEOS_EXPORT DeviceEventLogInstance { |
| DISALLOW_COPY_AND_ASSIGN(DeviceEventLogInstance); |
| }; |
| +class CHROMEOS_EXPORT DeviceLogIfSlow { |
|
satorux1
2014/12/16 03:29:44
Add some comment?
stevenjb
2014/12/16 19:12:58
Done.
|
| + public: |
| + DeviceLogIfSlow(LogType type, const char* file, const std::string& name); |
| + ~DeviceLogIfSlow(); |
| + |
| + private: |
| + const char* file_; |
| + LogType type_; |
| + std::string name_; |
| + base::ElapsedTimer timer_; |
| +}; |
| + |
| } // namespace internal |
| } // namespace device_event_log |