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

Unified Diff: base/trace_event/trace_event.cc

Issue 2381083003: The TRACE_LINK_IDS macro (Closed)
Patch Set: TracedValue -> CTTF Created 4 years, 2 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/trace_event/trace_event.cc
diff --git a/base/trace_event/trace_event.cc b/base/trace_event/trace_event.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0ea34e37637b8b2db311742262f6e468163d0b28
--- /dev/null
+++ b/base/trace_event/trace_event.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/trace_event/trace_event.h"
+
+#include "base/format_macros.h"
+#include "base/memory/ptr_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/trace_event/trace_event_argument.h"
+
+namespace trace_event_internal {
+
+std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
+TraceID::dict_value() const {
+ auto value = base::MakeUnique<base::trace_event::TracedValue>();
+
+ if (scope_ != kGlobalScope)
+ value->SetString("scope", scope_);
+ switch (id_flags_) {
+ case TRACE_EVENT_FLAG_HAS_ID:
+ value->SetString(
+ "id",
+ base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
+ break;
+ case TRACE_EVENT_FLAG_HAS_GLOBAL_ID:
+ value->BeginDictionary("id2");
+ value->SetString(
+ "global",
+ base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
+ value->EndDictionary();
+ break;
+ case TRACE_EVENT_FLAG_HAS_LOCAL_ID:
+ value->BeginDictionary("id2");
+ value->SetString(
+ "local",
+ base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
+ value->EndDictionary();
+ break;
+ default:
+ NOTREACHED() << "Unrecognized ID flag";
+ }
+
+ return std::move(value);
+}
+
+} // namespace trace_event_internal

Powered by Google App Engine
This is Rietveld 408576698