diff options
author | jasonroberts <jasonroberts@google.com> | 2016-03-09 11:42:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-09 19:43:41 +0000 |
commit | b5a2f8293ebfe4879b5ba5cbe6d51ceebd09699f (patch) | |
tree | 5db8b1372436b2e18b5ced70ac81806304dd4458 /chromecast | |
parent | 3abe3303bcbb2b24d7c21228f88114337347b674 (diff) | |
download | chromium_src-b5a2f8293ebfe4879b5ba5cbe6d51ceebd09699f.zip chromium_src-b5a2f8293ebfe4879b5ba5cbe6d51ceebd09699f.tar.gz chromium_src-b5a2f8293ebfe4879b5ba5cbe6d51ceebd09699f.tar.bz2 |
[Chromecast] Add method to log Cast Event with value.
BUG=internal b/27553453
Review URL: https://codereview.chromium.org/1773333002
Cr-Commit-Position: refs/heads/master@{#380180}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/base/metrics/cast_metrics_helper.cc | 26 | ||||
-rw-r--r-- | chromecast/base/metrics/cast_metrics_helper.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/chromecast/base/metrics/cast_metrics_helper.cc b/chromecast/base/metrics/cast_metrics_helper.cc index 8f12042b..75cfa6d 100644 --- a/chromecast/base/metrics/cast_metrics_helper.cc +++ b/chromecast/base/metrics/cast_metrics_helper.cc @@ -4,14 +4,21 @@ #include "chromecast/base/metrics/cast_metrics_helper.h" +#include <string> +#include <vector> + #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/json/json_string_value_serializer.h" #include "base/location.h" +#include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/metrics/user_metrics.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "base/time/time.h" +#include "base/values.h" #include "chromecast/base/metrics/cast_histograms.h" #include "chromecast/base/metrics/grouped_histogram.h" @@ -33,6 +40,14 @@ CastMetricsHelper* g_instance = NULL; const char kMetricsNameAppInfoDelimiter = '#'; +scoped_ptr<std::string> SerializeToJson(const base::Value& value) { + scoped_ptr<std::string> json_str(new std::string()); + JSONStringValueSerializer serializer(json_str.get()); + if (!serializer.Serialize(value)) + json_str.reset(nullptr); + return json_str; +} + } // namespace // static @@ -276,5 +291,16 @@ void CastMetricsHelper::LogMediumTimeHistogramEvent( 50); } +void CastMetricsHelper::RecordSimpleActionWithValue(const std::string& event, + int value) { + scoped_ptr<base::DictionaryValue> cast_event(new base::DictionaryValue()); + cast_event->SetString("name", event); + base::TimeTicks now = base::TimeTicks::Now(); + cast_event->SetDouble("time", now.ToInternalValue()); + cast_event->SetInteger("value", value); + const std::string message = *SerializeToJson(*cast_event.get()).get(); + RecordSimpleAction(message); +} + } // namespace metrics } // namespace chromecast diff --git a/chromecast/base/metrics/cast_metrics_helper.h b/chromecast/base/metrics/cast_metrics_helper.h index 251261d..e8af9cf 100644 --- a/chromecast/base/metrics/cast_metrics_helper.h +++ b/chromecast/base/metrics/cast_metrics_helper.h @@ -77,6 +77,9 @@ class CastMetricsHelper { // This is used as an in-place replacement of content::RecordComputedAction(). virtual void RecordSimpleAction(const std::string& action); + // Logs an event with an integer value + virtual void RecordSimpleActionWithValue(const std::string& event, int value); + // Logs UMA record of the time the app made its first paint. virtual void LogTimeToFirstPaint(); |