| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/chromeos/drive/logging.h" | 8 #include "chrome/browser/chromeos/drive/logging.h" |
| 9 | 9 |
| 10 namespace file_manager { | 10 namespace file_manager { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 const int kSlowOperationThresholdMs = 500; // In ms. | 13 const int kSlowOperationThresholdMs = 500; // In ms. |
| 14 | 14 |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 LoggedAsyncExtensionFunction::LoggedAsyncExtensionFunction() | 17 LoggedAsyncExtensionFunction::LoggedAsyncExtensionFunction() |
| 18 : log_on_completion_(false) { | 18 : log_on_completion_(false) { |
| 19 start_time_ = base::Time::Now(); | 19 start_time_ = base::Time::Now(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 LoggedAsyncExtensionFunction::~LoggedAsyncExtensionFunction() { | 22 LoggedAsyncExtensionFunction::~LoggedAsyncExtensionFunction() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void LoggedAsyncExtensionFunction::SendResponse(bool success) { | 25 void LoggedAsyncExtensionFunction::SendResponse(bool success) { |
| 26 int64 elapsed = (base::Time::Now() - start_time_).InMilliseconds(); | 26 int64 elapsed = (base::Time::Now() - start_time_).InMilliseconds(); |
| 27 if (log_on_completion_) { | 27 if (log_on_completion_) { |
| 28 drive::util::Log("%s[%d] %s. (elapsed time: %sms)", | 28 drive::util::Log(logging::LOG_INFO, |
| 29 "%s[%d] %s. (elapsed time: %sms)", |
| 29 name().c_str(), | 30 name().c_str(), |
| 30 request_id(), | 31 request_id(), |
| 31 success ? "succeeded" : "failed", | 32 success ? "succeeded" : "failed", |
| 32 base::Int64ToString(elapsed).c_str()); | 33 base::Int64ToString(elapsed).c_str()); |
| 33 } else if (elapsed >= kSlowOperationThresholdMs) { | 34 } else if (elapsed >= kSlowOperationThresholdMs) { |
| 34 drive::util::Log( | 35 drive::util::Log( |
| 36 logging::LOG_WARNING, |
| 35 "PEFORMANCE WARNING: %s[%d] was slow. (elapsed time: %sms)", | 37 "PEFORMANCE WARNING: %s[%d] was slow. (elapsed time: %sms)", |
| 36 name().c_str(), | 38 name().c_str(), |
| 37 request_id(), | 39 request_id(), |
| 38 base::Int64ToString(elapsed).c_str()); | 40 base::Int64ToString(elapsed).c_str()); |
| 39 } | 41 } |
| 40 | 42 |
| 41 AsyncExtensionFunction::SendResponse(success); | 43 AsyncExtensionFunction::SendResponse(success); |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace file_manager | 46 } // namespace file_manager |
| OLD | NEW |