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

Side by Side Diff: chrome/browser/ui/webui/metrics_handler.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/webui/metrics_handler.h" 5 #include "chrome/browser/ui/webui/metrics_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/metrics/metric_event_duration_details.h" 13 #include "chrome/browser/metrics/metric_event_duration_details.h"
14 #include "chrome/browser/ui/webui/chrome_web_ui.h" 14 #include "chrome/browser/ui/webui/chrome_web_ui.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/browser/user_metrics.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/user_metrics.h"
19 19
20 using base::ListValue; 20 using base::ListValue;
21 using content::UserMetricsAction;
21 22
22 MetricsHandler::MetricsHandler() {} 23 MetricsHandler::MetricsHandler() {}
23 MetricsHandler::~MetricsHandler() {} 24 MetricsHandler::~MetricsHandler() {}
24 25
25 void MetricsHandler::RegisterMessages() { 26 void MetricsHandler::RegisterMessages() {
26 web_ui_->RegisterMessageCallback( 27 web_ui_->RegisterMessageCallback(
27 "metricsHandler:recordAction", 28 "metricsHandler:recordAction",
28 base::Bind(&MetricsHandler::HandleRecordAction, base::Unretained(this))); 29 base::Bind(&MetricsHandler::HandleRecordAction, base::Unretained(this)));
29 web_ui_->RegisterMessageCallback( 30 web_ui_->RegisterMessageCallback(
30 "metricsHandler:recordInHistogram", 31 "metricsHandler:recordInHistogram",
31 base::Bind(&MetricsHandler::HandleRecordInHistogram, 32 base::Bind(&MetricsHandler::HandleRecordInHistogram,
32 base::Unretained(this))); 33 base::Unretained(this)));
33 web_ui_->RegisterMessageCallback( 34 web_ui_->RegisterMessageCallback(
34 "metricsHandler:logEventTime", 35 "metricsHandler:logEventTime",
35 base::Bind(&MetricsHandler::HandleLogEventTime, base::Unretained(this))); 36 base::Bind(&MetricsHandler::HandleLogEventTime, base::Unretained(this)));
36 } 37 }
37 38
38 void MetricsHandler::HandleRecordAction(const ListValue* args) { 39 void MetricsHandler::HandleRecordAction(const ListValue* args) {
39 std::string string_action = UTF16ToUTF8(ExtractStringValue(args)); 40 std::string string_action = UTF16ToUTF8(ExtractStringValue(args));
40 UserMetrics::RecordComputedAction(string_action); 41 content::RecordComputedAction(string_action);
41 } 42 }
42 43
43 void MetricsHandler::HandleRecordInHistogram(const ListValue* args) { 44 void MetricsHandler::HandleRecordInHistogram(const ListValue* args) {
44 std::string histogram_name; 45 std::string histogram_name;
45 double value; 46 double value;
46 double boundary_value; 47 double boundary_value;
47 if (!args->GetString(0, &histogram_name) || 48 if (!args->GetString(0, &histogram_name) ||
48 !args->GetDouble(1, &value) || 49 !args->GetDouble(1, &value) ||
49 !args->GetDouble(2, &boundary_value)) { 50 !args->GetDouble(2, &boundary_value)) {
50 NOTREACHED(); 51 NOTREACHED();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // The new tab page has finished loading; reset it. 97 // The new tab page has finished loading; reset it.
97 tab->set_new_tab_start_time(base::TimeTicks()); 98 tab->set_new_tab_start_time(base::TimeTicks());
98 } else { 99 } else {
99 NOTREACHED(); 100 NOTREACHED();
100 } 101 }
101 content::NotificationService::current()->Notify( 102 content::NotificationService::current()->Notify(
102 chrome::NOTIFICATION_METRIC_EVENT_DURATION, 103 chrome::NOTIFICATION_METRIC_EVENT_DURATION,
103 content::Source<TabContents>(tab), 104 content::Source<TabContents>(tab),
104 content::Details<MetricEventDurationDetails>(&details)); 105 content::Details<MetricEventDurationDetails>(&details));
105 } 106 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.cc ('k') | chrome/browser/ui/webui/ntp/most_visited_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698