diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-04 21:09:41 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-04 21:09:41 +0000 |
commit | 16c4c44cfa3569daca521e4886855ff0f6cc7569 (patch) | |
tree | 892c7bf222166153d6ab47c3168c6b1736fdd56e /chrome/browser/performance_monitor | |
parent | 3ed181d0d0feb9797ac6f9c2854f1ff1a9bf91a8 (diff) | |
download | chromium_src-16c4c44cfa3569daca521e4886855ff0f6cc7569.zip chromium_src-16c4c44cfa3569daca521e4886855ff0f6cc7569.tar.gz chromium_src-16c4c44cfa3569daca521e4886855ff0f6cc7569.tar.bz2 |
CPM Localization
WebUI change to meet the new spec and add in localization.
BUG=130212
TBR=thakis@chromium.org (for gypi changes)
Review URL: https://chromiumcodereview.appspot.com/10836321
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/performance_monitor')
-rw-r--r-- | chrome/browser/performance_monitor/database_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/event.cc | 26 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/event.h | 7 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/metric.h | 3 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/metric_details.cc | 137 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/metric_details.h | 25 | ||||
-rw-r--r-- | chrome/browser/performance_monitor/performance_monitor.cc | 9 |
7 files changed, 16 insertions, 193 deletions
diff --git a/chrome/browser/performance_monitor/database_unittest.cc b/chrome/browser/performance_monitor/database_unittest.cc index 3a18553..4fef765 100644 --- a/chrome/browser/performance_monitor/database_unittest.cc +++ b/chrome/browser/performance_monitor/database_unittest.cc @@ -12,7 +12,7 @@ #include "base/scoped_temp_dir.h" #include "base/time.h" #include "chrome/browser/performance_monitor/database.h" -#include "chrome/browser/performance_monitor/metric_details.h" +#include "chrome/browser/performance_monitor/metric.h" #include "chrome/browser/performance_monitor/performance_monitor_util.h" #include "chrome/common/extensions/extension.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/performance_monitor/event.cc b/chrome/browser/performance_monitor/event.cc index 43738f6..46b48b9 100644 --- a/chrome/browser/performance_monitor/event.cc +++ b/chrome/browser/performance_monitor/event.cc @@ -7,32 +7,6 @@ #include "base/logging.h" namespace performance_monitor { -namespace { - -// Keep this array synced with EventTypes in the header file. -// TODO(mtytel): i18n. -const char* kEventTypeNames[] = { - "Undefined", - "Extension Installs", - "Extension Uninstalls", - "Extension Updates", - "Extension Enables", - "Extension Disables", - "Chrome Updates", - "Renderer Freezes", - "Renderer Crashes", - "Out of Memory Crashes", - "Unclean Shutdowns" -}; -COMPILE_ASSERT(ARRAYSIZE_UNSAFE(kEventTypeNames) == EVENT_NUMBER_OF_EVENTS, - event_names_incorrect_size); - -} // namespace - -const char* EventTypeToString(EventType event_type) { - DCHECK_GT(EVENT_NUMBER_OF_EVENTS, event_type); - return kEventTypeNames[event_type]; -} Event::Event(const EventType& type, const base::Time& time, diff --git a/chrome/browser/performance_monitor/event.h b/chrome/browser/performance_monitor/event.h index 60f4c94..a4fc2c5 100644 --- a/chrome/browser/performance_monitor/event.h +++ b/chrome/browser/performance_monitor/event.h @@ -12,9 +12,10 @@ namespace performance_monitor { // IMPORTANT: This is used as an indication of the event type within the -// performance monitor database; do not change the order! If you add new events -// to this list, place them above EVENT_NUMBER_OF_EVENTS and add a string to -// kEventTypeNames in the cc file. +// performance monitor database; do not change the order! If you add new +// event types to this list, place them above NUMBER_OF_EVENTS and add the +// appropriate messages/functions in generated_resources.grd and in +// chrome/browser/ui/webui/performance_monitor/l10n_util. enum EventType { EVENT_UNDEFINED, EVENT_EXTENSION_INSTALL, diff --git a/chrome/browser/performance_monitor/metric.h b/chrome/browser/performance_monitor/metric.h index 56d3e48..7d717b9 100644 --- a/chrome/browser/performance_monitor/metric.h +++ b/chrome/browser/performance_monitor/metric.h @@ -13,7 +13,8 @@ namespace performance_monitor { // IMPORTANT: This is used as an indication of the metric type within the // performance monitor database; do not change the order! If you add new // metric types to this list, place them above METRIC_NUMBER_OF_METRICS and add -// the appropriate constants to metric_details. +// the appropriate messages/functions in generated_resources.grd and in +// chrome/browser/ui/webui/performance_monitor/l10n_util. enum MetricType { METRIC_CPU_USAGE, METRIC_PRIVATE_MEMORY_USAGE, diff --git a/chrome/browser/performance_monitor/metric_details.cc b/chrome/browser/performance_monitor/metric_details.cc deleted file mode 100644 index 1bcf966..0000000 --- a/chrome/browser/performance_monitor/metric_details.cc +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/performance_monitor/metric_details.h" - -#include "base/logging.h" -#include "chrome/browser/performance_monitor/constants.h" - -namespace performance_monitor { -namespace { - -// Metric details follow. -// All metric details have the following constants: -// - Name -// - Description -// - Units -// - TickSize (the smallest possible maximum which will be viewed in the ui.) - -// CPU Usage -const char kMetricCPUUsageName[] = "CPU Usage"; -const char kMetricCPUUsageDescription[] = "The CPU usage measured in percent."; -const char kMetricCPUUsageUnits[] = "percent"; -const double kMetricCPUUsageTickSize = 100.0; - -// Private Memory Usage -const char kMetricPrivateMemoryUsageName[] = "Private Memory Usage"; -const char kMetricPrivateMemoryUsageDescription[] = - "The total private memory usage of all chrome processes measured in bytes."; -const char kMetricPrivateMemoryUsageUnits[] = "bytes"; -const double kMetricPrivateMemoryUsageTickSize = 10000000.0; - -// Shared Memory Usage -const char kMetricSharedMemoryUsageName[] = "Shared Memory Usage"; -const char kMetricSharedMemoryUsageDescription[] = - "The total shared memory usage of all chrome processes measured in bytes."; -const char kMetricSharedMemoryUsageUnits[] = "bytes"; -const double kMetricSharedMemoryUsageTickSize = 10000000.0; - -// Startup Time -const char kMetricStartupTimeName[] = "Startup Time"; -const char kMetricStartupTimeDescription[] = - "The startup time measured in microseconds"; -const char kMetricStartupTimeUnits[] = "microseconds"; -const double kMetricStartupTimeTickSize = 5000000; - -// Test Startup Time -const char kMetricTestStartupTimeName[] = "Test Startup Time"; -const char kMetricTestStartupTimeDescription[] = - "The startup time of test startups measured in microseconds"; -const char kMetricTestStartupTimeUnits[] = "microseconds"; -const double kMetricTestStartupTimeTickSize = 5000000; - -// Session Restore Time -const char kMetricSessionRestoreTimeName[] = "Session Restore Time"; -const char kMetricSessionRestoreTimeDescription[] = - "The session restore time measured in microseconds"; -const char kMetricSessionRestoreTimeUnits[] = "microseconds"; -const double kMetricSessionRestoreTimeTickSize = 5000000; - -// Page Load Time -const char kMetricPageLoadTimeName[] = "Page Load Time"; -const char kMetricPageLoadTimeDescription[] = - "The amount of time taken to load a page measured in microseconds."; -const char kMetricPageLoadTimeUnits[] = "microseconds"; -const double kMetricPageLoadTimeTickSize = 30000000.0; - -// Network Bytes Read -const char kMetricNetworkBytesReadName[] = "Network Bytes Read"; -const char kMetricNetworkBytesReadDescription[] = - "The number of bytes read across the network."; -const char kMetricNetworkBytesReadUnits[] = "bytes"; -const double kMetricNetworkBytesReadTickSize = 2000000.0; - -// Keep this array synced with MetricTypes in the header file. -// TODO(mtytel): i18n. -const MetricDetails kMetricDetailsList[] = { - { - kMetricCPUUsageName, - kMetricCPUUsageDescription, - kMetricCPUUsageUnits, - kMetricCPUUsageTickSize, - }, - { - kMetricPrivateMemoryUsageName, - kMetricPrivateMemoryUsageDescription, - kMetricPrivateMemoryUsageUnits, - kMetricPrivateMemoryUsageTickSize - }, - { - kMetricSharedMemoryUsageName, - kMetricSharedMemoryUsageDescription, - kMetricSharedMemoryUsageUnits, - kMetricSharedMemoryUsageTickSize - }, - { - kMetricStartupTimeName, - kMetricStartupTimeDescription, - kMetricStartupTimeUnits, - kMetricStartupTimeTickSize - }, - { - kMetricTestStartupTimeName, - kMetricTestStartupTimeDescription, - kMetricTestStartupTimeUnits, - kMetricTestStartupTimeTickSize - }, - { - kMetricSessionRestoreTimeName, - kMetricSessionRestoreTimeDescription, - kMetricSessionRestoreTimeUnits, - kMetricSessionRestoreTimeTickSize - }, - { - kMetricPageLoadTimeName, - kMetricPageLoadTimeDescription, - kMetricPageLoadTimeUnits, - kMetricPageLoadTimeTickSize - }, - { - kMetricNetworkBytesReadName, - kMetricNetworkBytesReadDescription, - kMetricNetworkBytesReadUnits, - kMetricNetworkBytesReadTickSize - } -}; -COMPILE_ASSERT(ARRAYSIZE_UNSAFE(kMetricDetailsList) == METRIC_NUMBER_OF_METRICS, - metric_names_incorrect_size); - -} // namespace - -const MetricDetails* GetMetricDetails(MetricType metric_type) { - DCHECK_GT(METRIC_NUMBER_OF_METRICS, metric_type); - return &kMetricDetailsList[metric_type]; -} - -} // namespace performance_monitor diff --git a/chrome/browser/performance_monitor/metric_details.h b/chrome/browser/performance_monitor/metric_details.h deleted file mode 100644 index 4f3b163..0000000 --- a/chrome/browser/performance_monitor/metric_details.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_METRIC_DETAILS_H_ -#define CHROME_BROWSER_PERFORMANCE_MONITOR_METRIC_DETAILS_H_ - -#include <string> - -#include "chrome/browser/performance_monitor/metric.h" - -namespace performance_monitor { - -struct MetricDetails { - const char* const name; - const char* const description; - const char* const units; - const double tick_size; -}; - -const MetricDetails* GetMetricDetails(MetricType event_type); - -} // namespace performance_monitor - -#endif // CHROME_BROWSER_PERFORMANCE_MONITOR_METRIC_DETAILS_H_ diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc index ff5eebb..8646e1f 100644 --- a/chrome/browser/performance_monitor/performance_monitor.cc +++ b/chrome/browser/performance_monitor/performance_monitor.cc @@ -45,6 +45,8 @@ const uint32 kAccessFlags = base::kProcessAccessDuplicateHandle | base::kProcessAccessTerminate | base::kProcessAccessWaitForTermination; +bool g_started_initialization = false; + std::string TimeToString(base::Time time) { int64 time_int64 = time.ToInternalValue(); return base::Int64ToString(time_int64); @@ -91,6 +93,13 @@ PerformanceMonitor* PerformanceMonitor::GetInstance() { } void PerformanceMonitor::Start() { + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + // Avoid responding to multiple calls to Start(). + if (g_started_initialization) + return; + + g_started_initialization = true; util::PostTaskToDatabaseThreadAndReply( FROM_HERE, base::Bind(&PerformanceMonitor::InitOnBackgroundThread, |