| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // How long the cached value should remain valid. | 133 // How long the cached value should remain valid. |
| 134 base::TimeDelta cache_valid_time_; | 134 base::TimeDelta cache_valid_time_; |
| 135 | 135 |
| 136 // The last time the cached value was updated. | 136 // The last time the cached value was updated. |
| 137 base::Time last_updated_time_; | 137 base::Time last_updated_time_; |
| 138 | 138 |
| 139 base::Lock lock_; | 139 base::Lock lock_; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 class ConvertableToTraceFormatWrapper | 142 class ConvertableToTraceFormatWrapper |
| 143 : public base::debug::ConvertableToTraceFormat { | 143 : public base::trace_event::ConvertableToTraceFormat { |
| 144 public: | 144 public: |
| 145 explicit ConvertableToTraceFormatWrapper( | 145 explicit ConvertableToTraceFormatWrapper( |
| 146 const blink::WebConvertableToTraceFormat& convertable) | 146 const blink::WebConvertableToTraceFormat& convertable) |
| 147 : convertable_(convertable) {} | 147 : convertable_(convertable) {} |
| 148 void AppendAsTraceFormat(std::string* out) const override { | 148 void AppendAsTraceFormat(std::string* out) const override { |
| 149 *out += convertable_.asTraceFormat().utf8(); | 149 *out += convertable_.asTraceFormat().utf8(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 ~ConvertableToTraceFormatWrapper() override {} | 153 ~ConvertableToTraceFormatWrapper() override {} |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 case 2: | 589 case 2: |
| 590 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(2)); | 590 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(2)); |
| 591 default: | 591 default: |
| 592 NOTREACHED() << "Unknown thread bucket type."; | 592 NOTREACHED() << "Unknown thread bucket type."; |
| 593 } | 593 } |
| 594 return NULL; | 594 return NULL; |
| 595 } | 595 } |
| 596 | 596 |
| 597 static_assert( | 597 static_assert( |
| 598 sizeof(blink::Platform::TraceEventHandle) == | 598 sizeof(blink::Platform::TraceEventHandle) == |
| 599 sizeof(base::debug::TraceEventHandle), | 599 sizeof(base::trace_event::TraceEventHandle), |
| 600 "TraceEventHandle types must be same size"); | 600 "TraceEventHandle types must be same size"); |
| 601 | 601 |
| 602 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( | 602 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
| 603 char phase, | 603 char phase, |
| 604 const unsigned char* category_group_enabled, | 604 const unsigned char* category_group_enabled, |
| 605 const char* name, | 605 const char* name, |
| 606 unsigned long long id, | 606 unsigned long long id, |
| 607 double timestamp, | 607 double timestamp, |
| 608 int num_args, | 608 int num_args, |
| 609 const char** arg_names, | 609 const char** arg_names, |
| 610 const unsigned char* arg_types, | 610 const unsigned char* arg_types, |
| 611 const unsigned long long* arg_values, | 611 const unsigned long long* arg_values, |
| 612 unsigned char flags) { | 612 unsigned char flags) { |
| 613 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( | 613 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( |
| 614 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); | 614 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); |
| 615 base::debug::TraceEventHandle handle = | 615 base::trace_event::TraceEventHandle handle = |
| 616 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 616 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
| 617 phase, category_group_enabled, name, id, | 617 phase, category_group_enabled, name, id, |
| 618 base::PlatformThread::CurrentId(), | 618 base::PlatformThread::CurrentId(), |
| 619 timestamp_tt, | 619 timestamp_tt, |
| 620 num_args, arg_names, arg_types, arg_values, NULL, flags); | 620 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 621 blink::Platform::TraceEventHandle result; | 621 blink::Platform::TraceEventHandle result; |
| 622 memcpy(&result, &handle, sizeof(result)); | 622 memcpy(&result, &handle, sizeof(result)); |
| 623 return result; | 623 return result; |
| 624 } | 624 } |
| 625 | 625 |
| 626 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( | 626 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent( |
| 627 char phase, | 627 char phase, |
| 628 const unsigned char* category_group_enabled, | 628 const unsigned char* category_group_enabled, |
| 629 const char* name, | 629 const char* name, |
| 630 unsigned long long id, | 630 unsigned long long id, |
| 631 double timestamp, | 631 double timestamp, |
| 632 int num_args, | 632 int num_args, |
| 633 const char** arg_names, | 633 const char** arg_names, |
| 634 const unsigned char* arg_types, | 634 const unsigned char* arg_types, |
| 635 const unsigned long long* arg_values, | 635 const unsigned long long* arg_values, |
| 636 const blink::WebConvertableToTraceFormat* convertable_values, | 636 const blink::WebConvertableToTraceFormat* convertable_values, |
| 637 unsigned char flags) { | 637 unsigned char flags) { |
| 638 scoped_refptr<base::debug::ConvertableToTraceFormat> convertable_wrappers[2]; | 638 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 639 convertable_wrappers[2]; |
| 639 if (convertable_values) { | 640 if (convertable_values) { |
| 640 size_t size = std::min(static_cast<size_t>(num_args), | 641 size_t size = std::min(static_cast<size_t>(num_args), |
| 641 arraysize(convertable_wrappers)); | 642 arraysize(convertable_wrappers)); |
| 642 for (size_t i = 0; i < size; ++i) { | 643 for (size_t i = 0; i < size; ++i) { |
| 643 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { | 644 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) { |
| 644 convertable_wrappers[i] = | 645 convertable_wrappers[i] = |
| 645 new ConvertableToTraceFormatWrapper(convertable_values[i]); | 646 new ConvertableToTraceFormatWrapper(convertable_values[i]); |
| 646 } | 647 } |
| 647 } | 648 } |
| 648 } | 649 } |
| 649 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( | 650 base::TimeTicks timestamp_tt = base::TimeTicks::FromInternalValue( |
| 650 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); | 651 static_cast<int64>(timestamp * base::Time::kMicrosecondsPerSecond)); |
| 651 base::debug::TraceEventHandle handle = | 652 base::trace_event::TraceEventHandle handle = |
| 652 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(phase, | 653 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(phase, |
| 653 category_group_enabled, | 654 category_group_enabled, |
| 654 name, | 655 name, |
| 655 id, | 656 id, |
| 656 base::PlatformThread::CurrentId(), | 657 base::PlatformThread::CurrentId(), |
| 657 timestamp_tt, | 658 timestamp_tt, |
| 658 num_args, | 659 num_args, |
| 659 arg_names, | 660 arg_names, |
| 660 arg_types, | 661 arg_types, |
| 661 arg_values, | 662 arg_values, |
| 662 convertable_wrappers, | 663 convertable_wrappers, |
| 663 flags); | 664 flags); |
| 664 blink::Platform::TraceEventHandle result; | 665 blink::Platform::TraceEventHandle result; |
| 665 memcpy(&result, &handle, sizeof(result)); | 666 memcpy(&result, &handle, sizeof(result)); |
| 666 return result; | 667 return result; |
| 667 } | 668 } |
| 668 | 669 |
| 669 void BlinkPlatformImpl::updateTraceEventDuration( | 670 void BlinkPlatformImpl::updateTraceEventDuration( |
| 670 const unsigned char* category_group_enabled, | 671 const unsigned char* category_group_enabled, |
| 671 const char* name, | 672 const char* name, |
| 672 TraceEventHandle handle) { | 673 TraceEventHandle handle) { |
| 673 base::debug::TraceEventHandle traceEventHandle; | 674 base::trace_event::TraceEventHandle traceEventHandle; |
| 674 memcpy(&traceEventHandle, &handle, sizeof(handle)); | 675 memcpy(&traceEventHandle, &handle, sizeof(handle)); |
| 675 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 676 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
| 676 category_group_enabled, name, traceEventHandle); | 677 category_group_enabled, name, traceEventHandle); |
| 677 } | 678 } |
| 678 | 679 |
| 679 namespace { | 680 namespace { |
| 680 | 681 |
| 681 WebData loadAudioSpatializationResource(const char* name) { | 682 WebData loadAudioSpatializationResource(const char* name) { |
| 682 #ifdef IDR_AUDIO_SPATIALIZATION_COMPOSITE | 683 #ifdef IDR_AUDIO_SPATIALIZATION_COMPOSITE |
| 683 if (!strcmp(name, "Composite")) { | 684 if (!strcmp(name, "Composite")) { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1260 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
| 1260 static_cast<ui::DomCode>(dom_code))); | 1261 static_cast<ui::DomCode>(dom_code))); |
| 1261 } | 1262 } |
| 1262 | 1263 |
| 1263 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1264 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
| 1264 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1265 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
| 1265 code.utf8().data())); | 1266 code.utf8().data())); |
| 1266 } | 1267 } |
| 1267 | 1268 |
| 1268 } // namespace content | 1269 } // namespace content |
| OLD | NEW |