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

Side by Side Diff: base/trace_event/trace_event_impl.cc

Issue 2381083003: The TRACE_LINK_IDS macro (Closed)
Patch Set: . 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/trace_event.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
11 #include "base/memory/ptr_util.h"
11 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "base/trace_event/trace_event_argument.h"
18 #include "base/trace_event/trace_log.h" 20 #include "base/trace_event/trace_log.h"
19 21
20 namespace base { 22 namespace base {
21 namespace trace_event { 23 namespace trace_event {
22 24
23 namespace { 25 namespace {
24 26
25 size_t GetAllocLength(const char* str) { return str ? strlen(str) + 1 : 0; } 27 size_t GetAllocLength(const char* str) { return str ? strlen(str) + 1 : 0; }
26 28
27 // Copies |*member| into |*buffer|, sets |*member| to point to this new 29 // Copies |*member| into |*buffer|, sets |*member| to point to this new
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 default: 386 default:
385 NOTREACHED() << "More than one of the ID flags are set"; 387 NOTREACHED() << "More than one of the ID flags are set";
386 break; 388 break;
387 } 389 }
388 } 390 }
389 391
390 if (flags_ & TRACE_EVENT_FLAG_BIND_TO_ENCLOSING) 392 if (flags_ & TRACE_EVENT_FLAG_BIND_TO_ENCLOSING)
391 StringAppendF(out, ",\"bp\":\"e\""); 393 StringAppendF(out, ",\"bp\":\"e\"");
392 394
393 if ((flags_ & TRACE_EVENT_FLAG_FLOW_OUT) || 395 if ((flags_ & TRACE_EVENT_FLAG_FLOW_OUT) ||
394 (flags_ & TRACE_EVENT_FLAG_FLOW_IN) || 396 (flags_ & TRACE_EVENT_FLAG_FLOW_IN)) {
395 phase_ == TRACE_EVENT_PHASE_BIND_IDS) {
396 StringAppendF(out, ",\"bind_id\":\"0x%" PRIx64 "\"", 397 StringAppendF(out, ",\"bind_id\":\"0x%" PRIx64 "\"",
397 static_cast<uint64_t>(bind_id_)); 398 static_cast<uint64_t>(bind_id_));
398 } 399 }
399 if (flags_ & TRACE_EVENT_FLAG_FLOW_IN) 400 if (flags_ & TRACE_EVENT_FLAG_FLOW_IN)
400 StringAppendF(out, ",\"flow_in\":true"); 401 StringAppendF(out, ",\"flow_in\":true");
401 if (flags_ & TRACE_EVENT_FLAG_FLOW_OUT) 402 if (flags_ & TRACE_EVENT_FLAG_FLOW_OUT)
402 StringAppendF(out, ",\"flow_out\":true"); 403 StringAppendF(out, ",\"flow_out\":true");
403 404
404 // Instant events also output their scope. 405 // Instant events also output their scope.
405 if (phase_ == TRACE_EVENT_PHASE_INSTANT) { 406 if (phase_ == TRACE_EVENT_PHASE_INSTANT) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text); 442 AppendValueAsJSON(arg_types_[i], arg_values_[i], &value_as_text);
442 443
443 *out << value_as_text; 444 *out << value_as_text;
444 } 445 }
445 *out << "}"; 446 *out << "}";
446 } 447 }
447 } 448 }
448 449
449 } // namespace trace_event 450 } // namespace trace_event
450 } // namespace base 451 } // namespace base
452
453 namespace trace_event_internal {
454
455 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
456 TraceID::AsConvertableToTraceFormat() const {
457 auto value = base::MakeUnique<base::trace_event::TracedValue>();
458
459 if (scope_ != kGlobalScope)
460 value->SetString("scope", scope_);
461 switch (id_flags_) {
462 case TRACE_EVENT_FLAG_HAS_ID:
463 value->SetString(
464 "id",
465 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
466 break;
467 case TRACE_EVENT_FLAG_HAS_GLOBAL_ID:
468 value->BeginDictionary("id2");
469 value->SetString(
470 "global",
471 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
472 value->EndDictionary();
473 break;
474 case TRACE_EVENT_FLAG_HAS_LOCAL_ID:
475 value->BeginDictionary("id2");
476 value->SetString(
477 "local",
478 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_)));
479 value->EndDictionary();
480 break;
481 default:
482 NOTREACHED() << "Unrecognized ID flag";
483 }
484
485 return std::move(value);
486 }
487
488 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_event.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698