Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1370)

Side by Side Diff: chrome/browser/performance_monitor/performance_monitor_util.cc

Issue 10702117: Chrome Performance Monitor: Metric API Functions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed it up. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/performance_monitor/performance_monitor_util.h" 5 #include "chrome/browser/performance_monitor/performance_monitor_util.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "chrome/browser/performance_monitor/database.h"
11 #include "chrome/browser/performance_monitor/events.h" 12 #include "chrome/browser/performance_monitor/events.h"
13 #include "content/public/browser/browser_thread.h"
12 14
13 namespace performance_monitor { 15 namespace performance_monitor {
14 namespace util { 16 namespace util {
15 17
16 std::vector<MetricInfo> AggregateMetric( 18 std::vector<MetricInfo> AggregateMetric(
17 const std::vector<MetricInfo>& metric_infos, 19 const std::vector<MetricInfo>& metric_infos,
18 const base::Time& start, 20 const base::Time& start,
19 const base::TimeDelta& resolution) { 21 const base::TimeDelta& resolution) {
20 std::vector<MetricInfo> results; 22 std::vector<MetricInfo> results;
21 // Ignore all the points before the aggregation start. 23 // Ignore all the points before the aggregation start.
(...skipping 21 matching lines...) Expand all
43 45
44 // If the window splits an area of the step function, split the aggregation 46 // If the window splits an area of the step function, split the aggregation
45 // at the end of the window. 47 // at the end of the window.
46 integrated += metric_value * (window_end - last_sample_time).InSecondsF(); 48 integrated += metric_value * (window_end - last_sample_time).InSecondsF();
47 double average = integrated / resolution.InSecondsF(); 49 double average = integrated / resolution.InSecondsF();
48 results.push_back(MetricInfo(window_end, average)); 50 results.push_back(MetricInfo(window_end, average));
49 } 51 }
50 return results; 52 return results;
51 } 53 }
52 54
55 bool PostTaskToDatabaseAndReply(const base::Closure& request,
56 const base::Closure& reply) {
57 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
58 base::SequencedWorkerPool::SequenceToken token =
59 pool->GetNamedSequenceToken(Database::kDatabaseSequenceToken);
60 return pool->GetSequencedTaskRunner(token)->PostTaskAndReply(
61 FROM_HERE, request, reply);
62 }
63
53 scoped_ptr<Event> CreateExtensionInstallEvent( 64 scoped_ptr<Event> CreateExtensionInstallEvent(
54 const base::Time& time, 65 const base::Time& time,
55 const std::string& id, 66 const std::string& id,
56 const std::string& name, 67 const std::string& name,
57 const std::string& url, 68 const std::string& url,
58 const int& location, 69 const int& location,
59 const std::string& version, 70 const std::string& version,
60 const std::string& description) { 71 const std::string& description) {
61 events::ExtensionInstall event; 72 events::ExtensionInstall event;
62 event.event_type = EVENT_EXTENSION_INSTALL; 73 event.event_type = EVENT_EXTENSION_INSTALL;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 event.time = static_cast<double>(time.ToInternalValue()); 213 event.time = static_cast<double>(time.ToInternalValue());
203 event.previous_version = previous_version; 214 event.previous_version = previous_version;
204 event.current_version = current_version; 215 event.current_version = current_version;
205 scoped_ptr<base::DictionaryValue> value = event.ToValue(); 216 scoped_ptr<base::DictionaryValue> value = event.ToValue();
206 return scoped_ptr<Event>(new Event( 217 return scoped_ptr<Event>(new Event(
207 EVENT_CHROME_UPDATE, time, value.Pass())); 218 EVENT_CHROME_UPDATE, time, value.Pass()));
208 } 219 }
209 220
210 } // namespace util 221 } // namespace util
211 } // namespace performance_monitor 222 } // namespace performance_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698