| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H_ | 5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H_ |
| 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H_ | 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/performance_monitor/event.h" | 10 #include "chrome/browser/performance_monitor/event.h" |
| 11 #include "chrome/browser/performance_monitor/metric_info.h" | 11 #include "chrome/browser/performance_monitor/metric_info.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
| 13 | 13 |
| 14 namespace performance_monitor { | 14 namespace performance_monitor { |
| 15 namespace util { | 15 namespace util { |
| 16 | 16 |
| 17 // Metric data can be either dense or sporadic, so AggregateMetric() normalizes | 17 // Metric data can be either dense or sporadic, so AggregateMetric() normalizes |
| 18 // the metric data in time. |metric_infos| must be sorted in increasing time. | 18 // the metric data in time. |metric_infos| must be sorted in increasing time. |
| 19 // Put concisely, AggregateMetric() does sample rate conversion from irregular | 19 // Put concisely, AggregateMetric() does sample rate conversion from irregular |
| 20 // metric data points to a sample period of |resolution| beginning at |start|. | 20 // metric data points to a sample period of |resolution| beginning at |start|. |
| 21 // Each sampling window starts and ends at an integer multiple away from | 21 // Each sampling window starts and ends at an integer multiple away from |
| 22 // |start| and data points are omitted if there are no points to resample. | 22 // |start| and data points are omitted if there are no points to resample. |
| 23 std::vector<MetricInfo> AggregateMetric( | 23 std::vector<MetricInfo> AggregateMetric( |
| 24 const std::vector<MetricInfo>& metric_infos, | 24 const std::vector<MetricInfo>& metric_infos, |
| 25 const base::Time& start, | 25 const base::Time& start, |
| 26 const base::TimeDelta& resolution); | 26 const base::TimeDelta& resolution); |
| 27 | 27 |
| 28 // Post a task to the database using the kDatabaseSequenceToken and reply; this | 28 // Posts |request| to the performance monitor database's sequenced thread. On |
| 29 // is useful in the absence of a PostBlockingPoolSequencedTaskAndReply method. | 29 // completion |reply| is posted to the thread that called |
| 30 bool PostTaskToDatabaseAndReply(const base::Closure& request, | 30 // PostTaskToDatabaseThreadAndReply. |
| 31 const base::Closure& reply); | 31 bool PostTaskToDatabaseThreadAndReply(const base::Closure& request, |
| 32 const base::Closure& reply); |
| 32 | 33 |
| 33 // These are a collection of methods designed to create an event to store the | 34 // These are a collection of methods designed to create an event to store the |
| 34 // pertinent information, given all the fields. Please use these methods to | 35 // pertinent information, given all the fields. Please use these methods to |
| 35 // create any PerformanceMonitor events, as this will ensure strong-typing | 36 // create any PerformanceMonitor events, as this will ensure strong-typing |
| 36 // guards that performance_monitor::Event() will not. | 37 // guards that performance_monitor::Event() will not. |
| 37 scoped_ptr<Event> CreateExtensionInstallEvent( | 38 scoped_ptr<Event> CreateExtensionInstallEvent( |
| 38 const base::Time& time, | 39 const base::Time& time, |
| 39 const std::string& id, | 40 const std::string& id, |
| 40 const std::string& name, | 41 const std::string& name, |
| 41 const std::string& url, | 42 const std::string& url, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 94 |
| 94 scoped_ptr<Event> CreateChromeUpdateEvent( | 95 scoped_ptr<Event> CreateChromeUpdateEvent( |
| 95 const base::Time& time, | 96 const base::Time& time, |
| 96 const std::string& previous_version, | 97 const std::string& previous_version, |
| 97 const std::string& current_version); | 98 const std::string& current_version); |
| 98 | 99 |
| 99 } // namespace util | 100 } // namespace util |
| 100 } // namespace performance_monitor | 101 } // namespace performance_monitor |
| 101 | 102 |
| 102 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H__ | 103 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_UTIL_H__ |
| OLD | NEW |