| Index: chromeos/device_event_log.cc
|
| diff --git a/chromeos/device_event_log.cc b/chromeos/device_event_log.cc
|
| index 8251e7d579e80e4a8fbe83656e07942f91a44419..aaded58a3ebc8dd2c145ee462e29975ecf16f341 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
|
|
|