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

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 1381023002: NOCOMMIT: Blink tracing now uses base Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 // How long the cached value should remain valid. 151 // How long the cached value should remain valid.
152 base::TimeDelta cache_valid_time_; 152 base::TimeDelta cache_valid_time_;
153 153
154 // The last time the cached value was updated. 154 // The last time the cached value was updated.
155 base::Time last_updated_time_; 155 base::Time last_updated_time_;
156 156
157 base::Lock lock_; 157 base::Lock lock_;
158 }; 158 };
159 159
160 class ConvertableToTraceFormatWrapper
161 : public base::trace_event::ConvertableToTraceFormat {
162 public:
163 // We move a reference pointer from |convertable| to |convertable_|,
164 // rather than copying, for thread safety. https://crbug.com/478149
165 explicit ConvertableToTraceFormatWrapper(
166 blink::WebConvertableToTraceFormat& convertable) {
167 convertable_.moveFrom(convertable);
168 }
169 void AppendAsTraceFormat(std::string* out) const override {
170 *out += convertable_.asTraceFormat().utf8();
171 }
172
173 private:
174 ~ConvertableToTraceFormatWrapper() override {}
175
176 blink::WebConvertableToTraceFormat convertable_;
177 };
178
179 } // namespace 160 } // namespace
180 161
181 static int ToMessageID(WebLocalizedString::Name name) { 162 static int ToMessageID(WebLocalizedString::Name name) {
182 switch (name) { 163 switch (name) {
183 case WebLocalizedString::AXAMPMFieldText: 164 case WebLocalizedString::AXAMPMFieldText:
184 return IDS_AX_AM_PM_FIELD_TEXT; 165 return IDS_AX_AM_PM_FIELD_TEXT;
185 case WebLocalizedString::AXButtonActionVerb: 166 case WebLocalizedString::AXButtonActionVerb:
186 return IDS_AX_BUTTON_ACTION_VERB; 167 return IDS_AX_BUTTON_ACTION_VERB;
187 case WebLocalizedString::AXCalendarShowMonthSelector: 168 case WebLocalizedString::AXCalendarShowMonthSelector:
188 return IDS_AX_CALENDAR_SHOW_MONTH_SELECTOR; 169 return IDS_AX_CALENDAR_SHOW_MONTH_SELECTOR;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 &TRACE_EVENT_API_THREAD_BUCKET(1)); 589 &TRACE_EVENT_API_THREAD_BUCKET(1));
609 case 2: 590 case 2:
610 return reinterpret_cast<blink::Platform::TraceEventAPIAtomicWord*>( 591 return reinterpret_cast<blink::Platform::TraceEventAPIAtomicWord*>(
611 &TRACE_EVENT_API_THREAD_BUCKET(2)); 592 &TRACE_EVENT_API_THREAD_BUCKET(2));
612 default: 593 default:
613 NOTREACHED() << "Unknown thread bucket type."; 594 NOTREACHED() << "Unknown thread bucket type.";
614 } 595 }
615 return NULL; 596 return NULL;
616 } 597 }
617 598
618 static_assert(
619 sizeof(blink::Platform::TraceEventHandle) ==
620 sizeof(base::trace_event::TraceEventHandle),
621 "TraceEventHandle types must be same size");
622
623 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent(
624 char phase,
625 const unsigned char* category_group_enabled,
626 const char* name,
627 unsigned long long id,
628 unsigned long long bind_id,
629 double timestamp,
630 int num_args,
631 const char** arg_names,
632 const unsigned char* arg_types,
633 const unsigned long long* arg_values,
634 blink::WebConvertableToTraceFormat* convertable_values,
635 unsigned int flags) {
636 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
637 convertable_wrappers[2];
638 if (convertable_values) {
639 size_t size = std::min(static_cast<size_t>(num_args),
640 arraysize(convertable_wrappers));
641 for (size_t i = 0; i < size; ++i) {
642 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
643 convertable_wrappers[i] =
644 new ConvertableToTraceFormatWrapper(convertable_values[i]);
645 }
646 }
647 }
648 base::TraceTicks timestamp_tt =
649 base::TraceTicks() + base::TimeDelta::FromSecondsD(timestamp);
650 base::trace_event::TraceEventHandle handle =
651 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
652 phase, category_group_enabled, name, id, trace_event_internal::kNoId,
653 bind_id, base::PlatformThread::CurrentId(), timestamp_tt, num_args,
654 arg_names, arg_types, arg_values, convertable_wrappers, flags);
655 blink::Platform::TraceEventHandle result;
656 memcpy(&result, &handle, sizeof(result));
657 return result;
658 }
659
660 blink::Platform::TraceEventHandle BlinkPlatformImpl::addTraceEvent(
661 char phase,
662 const unsigned char* category_group_enabled,
663 const char* name,
664 unsigned long long id,
665 double timestamp,
666 int num_args,
667 const char** arg_names,
668 const unsigned char* arg_types,
669 const unsigned long long* arg_values,
670 blink::WebConvertableToTraceFormat* convertable_values,
671 unsigned char flags) {
672 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
673 convertable_wrappers[2];
674 if (convertable_values) {
675 size_t size = std::min(static_cast<size_t>(num_args),
676 arraysize(convertable_wrappers));
677 for (size_t i = 0; i < size; ++i) {
678 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
679 convertable_wrappers[i] =
680 new ConvertableToTraceFormatWrapper(convertable_values[i]);
681 }
682 }
683 }
684 base::TraceTicks timestamp_tt =
685 base::TraceTicks() + base::TimeDelta::FromSecondsD(timestamp);
686 base::trace_event::TraceEventHandle handle =
687 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
688 phase, category_group_enabled, name, id, trace_event_internal::kNoId,
689 base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names,
690 arg_types, arg_values, convertable_wrappers, flags);
691 blink::Platform::TraceEventHandle result;
692 memcpy(&result, &handle, sizeof(result));
693 return result;
694 }
695
696 void BlinkPlatformImpl::updateTraceEventDuration(
697 const unsigned char* category_group_enabled,
698 const char* name,
699 TraceEventHandle handle) {
700 base::trace_event::TraceEventHandle traceEventHandle;
701 memcpy(&traceEventHandle, &handle, sizeof(handle));
702 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
703 category_group_enabled, name, traceEventHandle);
704 }
705
706 void BlinkPlatformImpl::registerMemoryDumpProvider( 599 void BlinkPlatformImpl::registerMemoryDumpProvider(
707 blink::WebMemoryDumpProvider* wmdp) { 600 blink::WebMemoryDumpProvider* wmdp) {
708 WebMemoryDumpProviderAdapter* wmdp_adapter = 601 WebMemoryDumpProviderAdapter* wmdp_adapter =
709 new WebMemoryDumpProviderAdapter(wmdp); 602 new WebMemoryDumpProviderAdapter(wmdp);
710 bool did_insert = 603 bool did_insert =
711 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second; 604 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second;
712 if (!did_insert) 605 if (!did_insert)
713 return; 606 return;
714 wmdp_adapter->set_is_registered(true); 607 wmdp_adapter->set_is_registered(true);
715 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 608 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1285 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1393 static_cast<ui::DomKey>(dom_key))); 1286 static_cast<ui::DomKey>(dom_key)));
1394 } 1287 }
1395 1288
1396 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1289 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1397 return static_cast<int>( 1290 return static_cast<int>(
1398 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8().data())); 1291 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8().data()));
1399 } 1292 }
1400 1293
1401 } // namespace content 1294 } // namespace content
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.h ('k') | third_party/WebKit/Source/bindings/core/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698