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