Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / gl / angle_platform_impl.cc
bloba405f8e0859e1d577b9b18108b8aae5ea1523ac5
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/angle_platform_impl.h"
7 #include "base/metrics/histogram.h"
8 #include "base/metrics/sparse_histogram.h"
9 #include "base/trace_event/trace_event.h"
11 namespace gfx {
13 ANGLEPlatformImpl::ANGLEPlatformImpl() {
16 ANGLEPlatformImpl::~ANGLEPlatformImpl() {
19 double ANGLEPlatformImpl::currentTime() {
20 return base::Time::Now().ToDoubleT();
23 double ANGLEPlatformImpl::monotonicallyIncreasingTime() {
24 return (base::TraceTicks::Now() - base::TraceTicks()).InSecondsF();
27 const unsigned char* ANGLEPlatformImpl::getTraceCategoryEnabledFlag(
28 const char* category_group) {
29 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
32 angle::Platform::TraceEventHandle ANGLEPlatformImpl::addTraceEvent(
33 char phase,
34 const unsigned char* category_group_enabled,
35 const char* name,
36 unsigned long long id,
37 double timestamp,
38 int num_args,
39 const char** arg_names,
40 const unsigned char* arg_types,
41 const unsigned long long* arg_values,
42 unsigned char flags) {
43 base::TraceTicks timestamp_tt =
44 base::TraceTicks() + base::TimeDelta::FromSecondsD(timestamp);
45 base::trace_event::TraceEventHandle handle =
46 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP(
47 phase, category_group_enabled, name, id, trace_event_internal::kNoId,
48 base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names,
49 arg_types, arg_values, nullptr, flags);
50 angle::Platform::TraceEventHandle result;
51 memcpy(&result, &handle, sizeof(result));
52 return result;
55 void ANGLEPlatformImpl::updateTraceEventDuration(
56 const unsigned char* category_group_enabled,
57 const char* name,
58 TraceEventHandle handle) {
59 base::trace_event::TraceEventHandle trace_event_handle;
60 memcpy(&trace_event_handle, &handle, sizeof(handle));
61 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name,
62 trace_event_handle);
65 void ANGLEPlatformImpl::histogramCustomCounts(const char* name,
66 int sample,
67 int min,
68 int max,
69 int bucket_count) {
70 // Copied from histogram macro, but without the static variable caching
71 // the histogram because name is dynamic.
72 base::HistogramBase* counter = base::Histogram::FactoryGet(
73 name, min, max, bucket_count,
74 base::HistogramBase::kUmaTargetedHistogramFlag);
75 DCHECK_EQ(name, counter->histogram_name());
76 counter->Add(sample);
79 void ANGLEPlatformImpl::histogramEnumeration(const char* name,
80 int sample,
81 int boundary_value) {
82 // Copied from histogram macro, but without the static variable caching
83 // the histogram because name is dynamic.
84 base::HistogramBase* counter = base::LinearHistogram::FactoryGet(
85 name, 1, boundary_value, boundary_value + 1,
86 base::HistogramBase::kUmaTargetedHistogramFlag);
87 DCHECK_EQ(name, counter->histogram_name());
88 counter->Add(sample);
91 void ANGLEPlatformImpl::histogramSparse(const char* name, int sample) {
92 // For sparse histograms, we can use the macro, as it does not incorporate a
93 // static.
94 UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample);
97 void ANGLEPlatformImpl::histogramBoolean(const char* name, bool sample) {
98 histogramEnumeration(name, sample ? 1 : 0, 2);
101 } // namespace gfx