OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 static_assert( | 596 static_assert( |
597 sizeof(blink::Platform::TraceEventHandle) == | 597 sizeof(blink::Platform::TraceEventHandle) == |
598 sizeof(base::debug::TraceEventHandle), | 598 sizeof(base::debug::TraceEventHandle), |
599 "TraceEventHandle types must be same size"); | 599 "TraceEventHandle types must be same size"); |
600 | 600 |
601 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( | 601 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
602 char phase, | 602 char phase, |
603 const unsigned char* category_group_enabled, | 603 const unsigned char* category_group_enabled, |
604 const char* name, | 604 const char* name, |
605 unsigned long long id, | 605 unsigned long long id, |
| 606 double timestamp, |
606 int num_args, | 607 int num_args, |
607 const char** arg_names, | 608 const char** arg_names, |
608 const unsigned char* arg_types, | 609 const unsigned char* arg_types, |
609 const unsigned long long* arg_values, | 610 const unsigned long long* arg_values, |
610 unsigned char flags) { | 611 unsigned char flags) { |
611 base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT( | 612 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( |
612 phase, category_group_enabled, name, id, | 613 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); |
613 num_args, arg_names, arg_types, arg_values, NULL, flags); | 614 base::debug::TraceEventHandle handle = |
| 615 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 616 phase, category_group_enabled, name, id, |
| 617 base::PlatformThread::CurrentId(), |
| 618 timestamp_tt, |
| 619 num_args, arg_names, arg_types, arg_values, NULL, flags); |
614 blink::Platform::TraceEventHandle result; | 620 blink::Platform::TraceEventHandle result; |
615 memcpy(&result, &handle, sizeof(result)); | 621 memcpy(&result, &handle, sizeof(result)); |
616 return result; | 622 return result; |
617 } | 623 } |
618 | 624 |
619 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( | 625 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
620 char phase, | 626 char phase, |
621 const unsigned char* category_group_enabled, | 627 const unsigned char* category_group_enabled, |
622 const char* name, | 628 const char* name, |
623 unsigned long long id, | 629 unsigned long long id, |
| 630 double timestamp, |
624 int num_args, | 631 int num_args, |
625 const char** arg_names, | 632 const char** arg_names, |
626 const unsigned char* arg_types, | 633 const unsigned char* arg_types, |
627 const unsigned long long* arg_values, | 634 const unsigned long long* arg_values, |
628 const blink::WebConvertableToTraceFormat* convertable_values, | 635 const blink::WebConvertableToTraceFormat* convertable_values, |
629 unsigned char flags) { | 636 unsigned char flags) { |
630 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_wrappers[2]; | 637 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_wrappers[2]; |
631 if (convertable_values) { | 638 if (convertable_values) { |
632 size_t size = std::min(static_cast<size_t>(num_args), | 639 size_t size = std::min(static_cast<size_t>(num_args), |
633 arraysize(convertable_wrappers)); | 640 arraysize(convertable_wrappers)); |
634 for (size_t i = 0; i < size; ++i) { | 641 for (size_t i = 0; i < size; ++i) { |
635 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { | 642 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { |
636 convertable_wrappers[i] = | 643 convertable_wrappers[i] = |
637 new ConvertableToTraceFormatWrapper(convertable_values[i]); | 644 new ConvertableToTraceFormatWrapper(convertable_values[i]); |
638 } | 645 } |
639 } | 646 } |
640 } | 647 } |
| 648 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( |
| 649 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); |
641 base::debug::TraceEventHandle handle = | 650 base::debug::TraceEventHandle handle = |
642 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, | 651 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(phase, |
643 category_group_enabled, | 652 category_group_enabled, |
644 name, | 653 name, |
645 id, | 654 id, |
| 655 base::PlatformThread::CurrentId(), |
| 656 timestamp_tt, |
646 num_args, | 657 num_args, |
647 arg_names, | 658 arg_names, |
648 arg_types, | 659 arg_types, |
649 arg_values, | 660 arg_values, |
650 convertable_wrappers, | 661 convertable_wrappers, |
651 flags); | 662 flags); |
652 blink::Platform::TraceEventHandle result; | 663 blink::Platform::TraceEventHandle result; |
653 memcpy(&result, &handle, sizeof(result)); | 664 memcpy(&result, &handle, sizeof(result)); |
654 return result; | 665 return result; |
655 } | 666 } |
656 | 667 |
| 668 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
| 669 char phase, |
| 670 const unsigned char* category_group_enabled, |
| 671 const char* name, |
| 672 unsigned long long id, |
| 673 int num_args, |
| 674 const char** arg_names, |
| 675 const unsigned char* arg_types, |
| 676 const unsigned long long* arg_values, |
| 677 unsigned char flags) { |
| 678 return addTraceEvent(phase, category_group_enabled, name, id, currentTime(), |
| 679 num_args, arg_names, arg_types, arg_values, flags); |
| 680 } |
| 681 |
| 682 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
| 683 char phase, |
| 684 const unsigned char* category_group_enabled, |
| 685 const char* name, |
| 686 unsigned long long id, |
| 687 int num_args, |
| 688 const char** arg_names, |
| 689 const unsigned char* arg_types, |
| 690 const unsigned long long* arg_values, |
| 691 const blink::WebConvertableToTraceFormat* convertable_values, |
| 692 unsigned char flags) { |
| 693 return addTraceEvent(phase, category_group_enabled, name, id, currentTime(), |
| 694 num_args, arg_names, arg_types, arg_values, |
| 695 convertable_values, flags); |
| 696 } |
| 697 |
657 void BlinkPlatformImpl::updateTraceEventDuration( | 698 void BlinkPlatformImpl::updateTraceEventDuration( |
658 const unsigned char* category_group_enabled, | 699 const unsigned char* category_group_enabled, |
659 const char* name, | 700 const char* name, |
660 TraceEventHandle handle) { | 701 TraceEventHandle handle) { |
661 base::debug::TraceEventHandle traceEventHandle; | 702 base::debug::TraceEventHandle traceEventHandle; |
662 memcpy(&traceEventHandle, &handle, sizeof(handle)); | 703 memcpy(&traceEventHandle, &handle, sizeof(handle)); |
663 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 704 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
664 category_group_enabled, name, traceEventHandle); | 705 category_group_enabled, name, traceEventHandle); |
665 } | 706 } |
666 | 707 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 } | 1276 } |
1236 | 1277 |
1237 // static | 1278 // static |
1238 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 1279 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
1239 WebThreadImplForMessageLoop* impl = | 1280 WebThreadImplForMessageLoop* impl = |
1240 static_cast<WebThreadImplForMessageLoop*>(thread); | 1281 static_cast<WebThreadImplForMessageLoop*>(thread); |
1241 delete impl; | 1282 delete impl; |
1242 } | 1283 } |
1243 | 1284 |
1244 } // namespace content | 1285 } // namespace content |
OLD | NEW |