Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: base/location.cc

Issue 18083015: Add queued_time_ms trace for events in message loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Naming etc Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/location.cc
diff --git a/base/location.cc b/base/location.cc
index b5da027ee821ece54eb15d4c2e8143b3a462961b..404b64e1964b895c8363071d5e603d6ce102f9ae 100644
--- a/base/location.cc
+++ b/base/location.cc
@@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/location.h"
+#include "base/debug/trace_event.h"
+#include "base/json/string_escape.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#if defined(COMPILER_MSVC)
@@ -11,9 +16,31 @@ extern "C" {
}
#endif
-#include "base/location.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
+namespace {
+
+class LocationConvertableToTraceFormat
+ : public base::debug::ConvertableToTraceFormat {
+ public:
+ LocationConvertableToTraceFormat(const char* function_name,
+ const char* file_name)
+ : function_name_(function_name),
+ file_name_(file_name) {
+ }
+
+ virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
+ out->append("\"");
+ base::JsonDoubleQuote(function_name_, false, out);
+ out->append("@");
+ base::JsonDoubleQuote(file_name_, false, out);
+ out->append("\"");
+ }
+
+ private:
+ const char* function_name_;
+ const char* file_name_;
+};
jar (doing other things) 2013/07/08 23:14:19 nit: NO_DEFAULT_COPY_OR_ASSIGN
+
+} // namespace
namespace tracked_objects {
@@ -39,6 +66,12 @@ std::string Location::ToString() const {
base::IntToString(line_number_);
}
+scoped_ptr<base::debug::ConvertableToTraceFormat>
+ Location::ToTraceFormat() const {
+ return scoped_ptr<base::debug::ConvertableToTraceFormat>(
+ new LocationConvertableToTraceFormat(function_name_, file_name_));
+}
+
void Location::Write(bool display_filename, bool display_function_name,
std::string* output) const {
base::StringAppendF(output, "%s[%d] ",
« no previous file with comments | « base/location.h ('k') | base/message_loop/message_loop.cc » ('j') | base/tracked_objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698