1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/performance_monitor/performance_monitor_ui_constants.h"
7 #include "base/logging.h"
8 #include "base/time/time.h"
9 #include "chrome/browser/performance_monitor/constants.h"
11 namespace performance_monitor {
15 // Keep this list synced with the enum declared in the .h file.
16 const UnitDetails kUnitDetailsList[] = {
17 { UNIT_BYTES, MEASUREMENT_TYPE_MEMORY, 1 },
18 { UNIT_KILOBYTES, MEASUREMENT_TYPE_MEMORY, kBytesPerKilobyte },
19 { UNIT_MEGABYTES, MEASUREMENT_TYPE_MEMORY, kBytesPerMegabyte },
20 { UNIT_GIGABYTES, MEASUREMENT_TYPE_MEMORY, kBytesPerGigabyte },
21 { UNIT_TERABYTES, MEASUREMENT_TYPE_MEMORY, kBytesPerTerabyte },
22 { UNIT_MICROSECONDS, MEASUREMENT_TYPE_TIME, 1 },
23 { UNIT_MILLISECONDS, MEASUREMENT_TYPE_TIME,
24 base::Time::kMicrosecondsPerMillisecond },
25 { UNIT_SECONDS, MEASUREMENT_TYPE_TIME, base::Time::kMicrosecondsPerSecond },
26 { UNIT_MINUTES, MEASUREMENT_TYPE_TIME, base::Time::kMicrosecondsPerMinute },
27 { UNIT_HOURS, MEASUREMENT_TYPE_TIME, base::Time::kMicrosecondsPerHour },
28 { UNIT_DAYS, MEASUREMENT_TYPE_TIME, base::Time::kMicrosecondsPerDay },
29 { UNIT_WEEKS, MEASUREMENT_TYPE_TIME, base::Time::kMicrosecondsPerWeek },
30 { UNIT_MONTHS, MEASUREMENT_TYPE_TIME, kMicrosecondsPerMonth },
31 { UNIT_YEARS, MEASUREMENT_TYPE_TIME, kMicrosecondsPerYear },
32 { UNIT_PERCENT, MEASUREMENT_TYPE_PERCENT, 1 },
35 COMPILE_ASSERT(ARRAYSIZE_UNSAFE(kUnitDetailsList) == UNIT_UNDEFINED,
36 unit_details_doesnt_match_unit_types);
40 const UnitDetails* GetUnitDetails(Unit unit) {
41 if (unit == UNIT_UNDEFINED) {
42 LOG(ERROR) << "Request for undefined unit";
46 return &kUnitDetailsList[unit];
49 } // namespace performance_monitor