| 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" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/metrics/sparse_histogram.h" | |
| 19 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 20 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
| 25 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
| 26 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
| 27 #include "base/thread_task_runner_handle.h" | 26 #include "base/thread_task_runner_handle.h" |
| 28 #include "base/threading/platform_thread.h" | 27 #include "base/threading/platform_thread.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 const char* name, int sample, int boundary_value) { | 600 const char* name, int sample, int boundary_value) { |
| 602 // Copied from histogram macro, but without the static variable caching | 601 // Copied from histogram macro, but without the static variable caching |
| 603 // the histogram because name is dynamic. | 602 // the histogram because name is dynamic. |
| 604 base::HistogramBase* counter = | 603 base::HistogramBase* counter = |
| 605 base::LinearHistogram::FactoryGet(name, 1, boundary_value, | 604 base::LinearHistogram::FactoryGet(name, 1, boundary_value, |
| 606 boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag); | 605 boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag); |
| 607 DCHECK_EQ(name, counter->histogram_name()); | 606 DCHECK_EQ(name, counter->histogram_name()); |
| 608 counter->Add(sample); | 607 counter->Add(sample); |
| 609 } | 608 } |
| 610 | 609 |
| 611 void BlinkPlatformImpl::histogramSparse(const char* name, int sample) { | |
| 612 // For sparse histograms, we can use the macro, as it does not incorporate a | |
| 613 // static. | |
| 614 UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); | |
| 615 } | |
| 616 | |
| 617 void BlinkPlatformImpl::registerMemoryDumpProvider( | 610 void BlinkPlatformImpl::registerMemoryDumpProvider( |
| 618 blink::WebMemoryDumpProvider* wmdp, const char* name) { | 611 blink::WebMemoryDumpProvider* wmdp, const char* name) { |
| 619 WebMemoryDumpProviderAdapter* wmdp_adapter = | 612 WebMemoryDumpProviderAdapter* wmdp_adapter = |
| 620 new WebMemoryDumpProviderAdapter(wmdp); | 613 new WebMemoryDumpProviderAdapter(wmdp); |
| 621 bool did_insert = | 614 bool did_insert = |
| 622 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second; | 615 memory_dump_providers_.add(wmdp, make_scoped_ptr(wmdp_adapter)).second; |
| 623 if (!did_insert) | 616 if (!did_insert) |
| 624 return; | 617 return; |
| 625 wmdp_adapter->set_is_registered(true); | 618 wmdp_adapter->set_is_registered(true); |
| 626 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 619 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 1204 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
| 1212 static_cast<ui::DomKey>(dom_key))); | 1205 static_cast<ui::DomKey>(dom_key))); |
| 1213 } | 1206 } |
| 1214 | 1207 |
| 1215 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { | 1208 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { |
| 1216 return static_cast<int>( | 1209 return static_cast<int>( |
| 1217 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); | 1210 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); |
| 1218 } | 1211 } |
| 1219 | 1212 |
| 1220 } // namespace content | 1213 } // namespace content |
| OLD | NEW |