Chromium Code Reviews| Index: runtime/lib/timeline.cc |
| diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc |
| index 8410f1bb5074f9f018cc829ba1283ba608c9d48d..f81ce4d3aa711bce09f9904362ab8edcd8fdaeca 100644 |
| --- a/runtime/lib/timeline.cc |
| +++ b/runtime/lib/timeline.cc |
| @@ -58,7 +58,13 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
| OSThread* os_thread = thread->os_thread(); |
| ASSERT(os_thread != NULL); |
| int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id()); |
| - |
| + // Convert phase to a C string and perform a sanity check. |
| + const char* phase_string = phase.ToCString(); |
| + ASSERT(phase_string != NULL); |
| + ASSERT((phase_string[0] == 'n') || |
| + (phase_string[0] == 'b') || |
| + (phase_string[0] == 'e')); |
| + ASSERT(phase_string[1] == '\0'); |
| char* json = OS::SCreate(zone, |
| "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 "," |
| "\"ts\":%" Pd64 ",\"ph\":\"%s\",\"id\":%" Pd64 ", \"args\":%s}", |
| @@ -67,7 +73,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
| tid, |
| pid, |
| start.AsInt64Value(), |
| - phase.ToCString(), |
| + phase_string, |
| id.AsInt64Value(), |
| args.ToCString()); |
|
siva
2015/12/30 20:21:26
Can this json initialization stuff be moved down b
Cutch
2015/12/30 20:48:14
Good suggestion. Done here and elsewhere.
|
| @@ -76,9 +82,21 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) { |
| // Stream was turned off. |
| return Object::null(); |
| } |
| + switch (phase_string[0]) { |
| + case 'n': |
| + event->AsyncInstant("", id.AsInt64Value(), start.AsInt64Value()); |
| + break; |
| + case 'b': |
| + event->AsyncBegin("", id.AsInt64Value(), start.AsInt64Value()); |
| + break; |
| + case 'e': |
| + event->AsyncEnd("", id.AsInt64Value(), start.AsInt64Value()); |
| + break; |
| + default: |
| + UNREACHABLE(); |
| + } |
| // json was allocated in the zone and a copy will be stored in event. |
| - event->SerializedJSON(json, start.AsInt64Value(), id.AsInt64Value()); |
| - event->Complete(); |
| + event->CompleteWithPreSerializedJSON(json); |
| return Object::null(); |
| } |
| @@ -123,10 +141,9 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) { |
| // Stream was turned off. |
| return Object::null(); |
| } |
| + event->Duration("", start.AsInt64Value(), end.AsInt64Value()); |
| // json was allocated in the zone and a copy will be stored in event. |
| - event->SerializedJSON(json, start.AsInt64Value(), end.AsInt64Value()); |
| - event->SetSerializedJSONIsDuration(true); |
| - event->Complete(); |
| + event->CompleteWithPreSerializedJSON(json); |
| return Object::null(); |
| } |
| @@ -168,9 +185,9 @@ DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 4) { |
| // Stream was turned off. |
| return Object::null(); |
| } |
| + event->Instant("", start.AsInt64Value()); |
| // json was allocated in the zone and a copy will be stored in event. |
| - event->SerializedJSON(json, start.AsInt64Value(), 0); |
| - event->Complete(); |
| + event->CompleteWithPreSerializedJSON(json); |
| return Object::null(); |
| } |