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] ", |