| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/metrics/histogram.h" | |
| 18 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
| 19 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 24 #include "base/synchronization/waitable_event.h" | 23 #include "base/synchronization/waitable_event.h" |
| 25 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 26 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
| 27 #include "base/threading/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( | 571 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( |
| 573 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 572 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
| 574 std::vector<base::WaitableEvent*> events; | 573 std::vector<base::WaitableEvent*> events; |
| 575 for (size_t i = 0; i < web_events.size(); ++i) | 574 for (size_t i = 0; i < web_events.size(); ++i) |
| 576 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); | 575 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); |
| 577 size_t idx = base::WaitableEvent::WaitMany(events.data(), events.size()); | 576 size_t idx = base::WaitableEvent::WaitMany(events.data(), events.size()); |
| 578 DCHECK_LT(idx, web_events.size()); | 577 DCHECK_LT(idx, web_events.size()); |
| 579 return web_events[idx]; | 578 return web_events[idx]; |
| 580 } | 579 } |
| 581 | 580 |
| 582 void BlinkPlatformImpl::histogramEnumeration( | |
| 583 const char* name, int sample, int boundary_value) { | |
| 584 // Copied from histogram macro, but without the static variable caching | |
| 585 // the histogram because name is dynamic. | |
| 586 base::HistogramBase* counter = | |
| 587 base::LinearHistogram::FactoryGet(name, 1, boundary_value, | |
| 588 boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag); | |
| 589 DCHECK_EQ(name, counter->histogram_name()); | |
| 590 counter->Add(sample); | |
| 591 } | |
| 592 | |
| 593 void BlinkPlatformImpl::registerMemoryDumpProvider( | 581 void BlinkPlatformImpl::registerMemoryDumpProvider( |
| 594 blink::WebMemoryDumpProvider* wmdp, const char* name) { | 582 blink::WebMemoryDumpProvider* wmdp, const char* name) { |
| 595 WebMemoryDumpProviderAdapter* wmdp_adapter = | 583 WebMemoryDumpProviderAdapter* wmdp_adapter = |
| 596 new WebMemoryDumpProviderAdapter(wmdp); | 584 new WebMemoryDumpProviderAdapter(wmdp); |
| 597 bool did_insert = | 585 bool did_insert = |
| 598 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second; | 586 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second; |
| 599 if (!did_insert) | 587 if (!did_insert) |
| 600 return; | 588 return; |
| 601 wmdp_adapter->set_is_registered(true); | 589 wmdp_adapter->set_is_registered(true); |
| 602 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 590 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 1175 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
| 1188 static_cast<ui::DomKey>(dom_key))); | 1176 static_cast<ui::DomKey>(dom_key))); |
| 1189 } | 1177 } |
| 1190 | 1178 |
| 1191 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { | 1179 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { |
| 1192 return static_cast<int>( | 1180 return static_cast<int>( |
| 1193 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); | 1181 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); |
| 1194 } | 1182 } |
| 1195 | 1183 |
| 1196 } // namespace content | 1184 } // namespace content |
| OLD | NEW |