Commit 767c9d99 authored by isherman@chromium.org's avatar isherman@chromium.org

[UMA] Include field trial tuples in the UMA upload.

BUG=109817
TEST=unit_tests --gtest_filter=MetricsLogTest.*


Review URL: http://codereview.chromium.org/9559017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124655 0039d316-1c4b-4281-b951-d872f2087c98
parent 1eced7f0
...@@ -48,19 +48,19 @@ extern "C" IMAGE_DOS_HEADER __ImageBase; ...@@ -48,19 +48,19 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
using content::GpuDataManager; using content::GpuDataManager;
using metrics::OmniboxEventProto; using metrics::OmniboxEventProto;
using metrics::SystemProfileProto; using metrics::SystemProfileProto;
typedef base::FieldTrial::NameGroupId NameGroupId;
namespace { namespace {
// Returns the date at which the current metrics client ID was created as // Returns the date at which the current metrics client ID was created as
// a string containing milliseconds since the epoch, or "0" if none was found. // a string containing milliseconds since the epoch, or "0" if none was found.
std::string GetInstallDate() { std::string GetInstallDate(PrefService* pref) {
PrefService* pref = g_browser_process->local_state(); if (!pref) {
if (pref) {
return pref->GetString(prefs::kMetricsClientIDTimestamp);
} else {
NOTREACHED(); NOTREACHED();
return "0"; return "0";
} }
return pref->GetString(prefs::kMetricsClientIDTimestamp);
} }
OmniboxEventProto::InputType AsOmniboxEventInputType( OmniboxEventProto::InputType AsOmniboxEventInputType(
...@@ -171,6 +171,17 @@ void SetPluginInfo(const webkit::WebPluginInfo& plugin_info, ...@@ -171,6 +171,17 @@ void SetPluginInfo(const webkit::WebPluginInfo& plugin_info,
plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info)); plugin->set_is_disabled(!plugin_prefs->IsPluginEnabled(plugin_info));
} }
void WriteFieldTrials(const std::vector<NameGroupId>& field_trial_ids,
SystemProfileProto* system_profile) {
for (std::vector<NameGroupId>::const_iterator it = field_trial_ids.begin();
it != field_trial_ids.end(); ++it) {
SystemProfileProto::FieldTrial* field_trial =
system_profile->add_field_trial();
field_trial->set_name_id(it->name);
field_trial->set_group_id(it->group);
}
}
} // namespace } // namespace
static base::LazyInstance<std::string>::Leaky static base::LazyInstance<std::string>::Leaky
...@@ -230,9 +241,9 @@ const std::string& MetricsLog::version_extension() { ...@@ -230,9 +241,9 @@ const std::string& MetricsLog::version_extension() {
void MetricsLog::RecordIncrementalStabilityElements( void MetricsLog::RecordIncrementalStabilityElements(
const std::vector<webkit::WebPluginInfo>& plugin_list) { const std::vector<webkit::WebPluginInfo>& plugin_list) {
DCHECK(!locked_); DCHECK(!locked());
PrefService* pref = g_browser_process->local_state(); PrefService* pref = GetPrefService();
DCHECK(pref); DCHECK(pref);
OPEN_ELEMENT_FOR_SCOPE("profile"); OPEN_ELEMENT_FOR_SCOPE("profile");
...@@ -249,10 +260,28 @@ void MetricsLog::RecordIncrementalStabilityElements( ...@@ -249,10 +260,28 @@ void MetricsLog::RecordIncrementalStabilityElements(
} }
} }
PrefService* MetricsLog::GetPrefService() {
return g_browser_process->local_state();
}
gfx::Size MetricsLog::GetScreenSize() const {
return gfx::Screen::GetPrimaryMonitorSize();
}
int MetricsLog::GetScreenCount() const {
return gfx::Screen::GetNumMonitors();
}
void MetricsLog::GetFieldTrialIds(
std::vector<NameGroupId>* field_trial_ids) const {
base::FieldTrialList::GetFieldTrialNameGroupIds(field_trial_ids);
}
void MetricsLog::WriteStabilityElement( void MetricsLog::WriteStabilityElement(
const std::vector<webkit::WebPluginInfo>& plugin_list, const std::vector<webkit::WebPluginInfo>& plugin_list,
PrefService* pref) { PrefService* pref) {
DCHECK(!locked_); DCHECK(!locked());
// Get stability attributes out of Local State, zeroing out stored values. // Get stability attributes out of Local State, zeroing out stored values.
// NOTE: This could lead to some data loss if this report isn't successfully // NOTE: This could lead to some data loss if this report isn't successfully
...@@ -292,7 +321,7 @@ void MetricsLog::WriteStabilityElement( ...@@ -292,7 +321,7 @@ void MetricsLog::WriteStabilityElement(
// Write the protobuf version. // Write the protobuf version.
SystemProfileProto::Stability* stability = SystemProfileProto::Stability* stability =
uma_proto_.mutable_system_profile()->mutable_stability(); uma_proto()->mutable_system_profile()->mutable_stability();
stability->set_incomplete_shutdown_count(incomplete_shutdown_count); stability->set_incomplete_shutdown_count(incomplete_shutdown_count);
stability->set_breakpad_registration_success_count( stability->set_breakpad_registration_success_count(
breakpad_registration_success_count); breakpad_registration_success_count);
...@@ -315,7 +344,7 @@ void MetricsLog::WritePluginStabilityElements( ...@@ -315,7 +344,7 @@ void MetricsLog::WritePluginStabilityElements(
OPEN_ELEMENT_FOR_SCOPE("plugins"); OPEN_ELEMENT_FOR_SCOPE("plugins");
SystemProfileProto::Stability* stability = SystemProfileProto::Stability* stability =
uma_proto_.mutable_system_profile()->mutable_stability(); uma_proto()->mutable_system_profile()->mutable_stability();
PluginPrefs* plugin_prefs = GetPluginPrefs(); PluginPrefs* plugin_prefs = GetPluginPrefs();
for (ListValue::const_iterator iter = plugin_stats_list->begin(); for (ListValue::const_iterator iter = plugin_stats_list->begin();
iter != plugin_stats_list->end(); ++iter) { iter != plugin_stats_list->end(); ++iter) {
...@@ -400,7 +429,7 @@ void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) { ...@@ -400,7 +429,7 @@ void MetricsLog::WriteRequiredStabilityAttributes(PrefService* pref) {
// Write the protobuf version. // Write the protobuf version.
SystemProfileProto::Stability* stability = SystemProfileProto::Stability* stability =
uma_proto_.mutable_system_profile()->mutable_stability(); uma_proto()->mutable_system_profile()->mutable_stability();
stability->set_launch_count(launch_count); stability->set_launch_count(launch_count);
stability->set_crash_count(crash_count); stability->set_crash_count(crash_count);
} }
...@@ -411,7 +440,7 @@ void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) { ...@@ -411,7 +440,7 @@ void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) {
// are aggergated (summed) server side. // are aggergated (summed) server side.
SystemProfileProto::Stability* stability = SystemProfileProto::Stability* stability =
uma_proto_.mutable_system_profile()->mutable_stability(); uma_proto()->mutable_system_profile()->mutable_stability();
int count = pref->GetInteger(prefs::kStabilityPageLoadCount); int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
if (count) { if (count) {
WriteIntAttribute("pageloadcount", count); WriteIntAttribute("pageloadcount", count);
...@@ -476,12 +505,12 @@ void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) { ...@@ -476,12 +505,12 @@ void MetricsLog::WriteRealtimeStabilityAttributes(PrefService* pref) {
void MetricsLog::WritePluginList( void MetricsLog::WritePluginList(
const std::vector<webkit::WebPluginInfo>& plugin_list) { const std::vector<webkit::WebPluginInfo>& plugin_list) {
DCHECK(!locked_); DCHECK(!locked());
PluginPrefs* plugin_prefs = GetPluginPrefs(); PluginPrefs* plugin_prefs = GetPluginPrefs();
OPEN_ELEMENT_FOR_SCOPE("plugins"); OPEN_ELEMENT_FOR_SCOPE("plugins");
SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
for (std::vector<webkit::WebPluginInfo>::const_iterator iter = for (std::vector<webkit::WebPluginInfo>::const_iterator iter =
plugin_list.begin(); plugin_list.begin();
iter != plugin_list.end(); ++iter) { iter != plugin_list.end(); ++iter) {
...@@ -516,7 +545,7 @@ void MetricsLog::WritePluginList( ...@@ -516,7 +545,7 @@ void MetricsLog::WritePluginList(
} }
void MetricsLog::WriteInstallElement() { void MetricsLog::WriteInstallElement() {
std::string install_date = GetInstallDate(); std::string install_date = GetInstallDate(GetPrefService());
// Write the XML version. // Write the XML version.
OPEN_ELEMENT_FOR_SCOPE("install"); OPEN_ELEMENT_FOR_SCOPE("install");
...@@ -527,15 +556,15 @@ void MetricsLog::WriteInstallElement() { ...@@ -527,15 +556,15 @@ void MetricsLog::WriteInstallElement() {
int numeric_install_date; int numeric_install_date;
bool success = base::StringToInt(install_date, &numeric_install_date); bool success = base::StringToInt(install_date, &numeric_install_date);
DCHECK(success); DCHECK(success);
uma_proto_.mutable_system_profile()->set_install_date(numeric_install_date); uma_proto()->mutable_system_profile()->set_install_date(numeric_install_date);
} }
void MetricsLog::RecordEnvironment( void MetricsLog::RecordEnvironment(
const std::vector<webkit::WebPluginInfo>& plugin_list, const std::vector<webkit::WebPluginInfo>& plugin_list,
const DictionaryValue* profile_metrics) { const DictionaryValue* profile_metrics) {
DCHECK(!locked_); DCHECK(!locked());
PrefService* pref = g_browser_process->local_state(); PrefService* pref = GetPrefService();
OPEN_ELEMENT_FOR_SCOPE("profile"); OPEN_ELEMENT_FOR_SCOPE("profile");
WriteCommonEventAttributes(); WriteCommonEventAttributes();
...@@ -546,7 +575,7 @@ void MetricsLog::RecordEnvironment( ...@@ -546,7 +575,7 @@ void MetricsLog::RecordEnvironment(
WriteStabilityElement(plugin_list, pref); WriteStabilityElement(plugin_list, pref);
SystemProfileProto* system_profile = uma_proto_.mutable_system_profile(); SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
system_profile->set_application_locale( system_profile->set_application_locale(
content::GetContentClient()->browser()->GetApplicationLocale()); content::GetContentClient()->browser()->GetApplicationLocale());
...@@ -619,10 +648,10 @@ void MetricsLog::RecordEnvironment( ...@@ -619,10 +648,10 @@ void MetricsLog::RecordEnvironment(
} }
{ {
const gfx::Size display_size = gfx::Screen::GetPrimaryMonitorSize(); const gfx::Size display_size = GetScreenSize();
int display_width = display_size.width(); int display_width = display_size.width();
int display_height = display_size.height(); int display_height = display_size.height();
int screen_count = gfx::Screen::GetNumMonitors(); int screen_count = GetScreenCount();
// Write the XML version. // Write the XML version.
OPEN_ELEMENT_FOR_SCOPE("display"); OPEN_ELEMENT_FOR_SCOPE("display");
...@@ -670,6 +699,10 @@ void MetricsLog::RecordEnvironment( ...@@ -670,6 +699,10 @@ void MetricsLog::RecordEnvironment(
if (profile_metrics) if (profile_metrics)
WriteAllProfilesMetrics(*profile_metrics); WriteAllProfilesMetrics(*profile_metrics);
std::vector<NameGroupId> field_trial_ids;
GetFieldTrialIds(&field_trial_ids);
WriteFieldTrials(field_trial_ids, system_profile);
} }
void MetricsLog::WriteAllProfilesMetrics( void MetricsLog::WriteAllProfilesMetrics(
...@@ -736,7 +769,7 @@ void MetricsLog::WriteProfileMetrics(const std::string& profileidhash, ...@@ -736,7 +769,7 @@ void MetricsLog::WriteProfileMetrics(const std::string& profileidhash,
} }
void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
DCHECK(!locked_); DCHECK(!locked());
// Write the XML version. // Write the XML version.
OPEN_ELEMENT_FOR_SCOPE("uielement"); OPEN_ELEMENT_FOR_SCOPE("uielement");
...@@ -785,7 +818,7 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) { ...@@ -785,7 +818,7 @@ void MetricsLog::RecordOmniboxOpenedURL(const AutocompleteLog& log) {
} }
// Write the protobuf version. // Write the protobuf version.
OmniboxEventProto* omnibox_event = uma_proto_.add_omnibox_event(); OmniboxEventProto* omnibox_event = uma_proto()->add_omnibox_event();
omnibox_event->set_time(MetricsLogBase::GetCurrentTime()); omnibox_event->set_time(MetricsLogBase::GetCurrentTime());
if (log.tab_id != -1) { if (log.tab_id != -1) {
// If we know what tab the autocomplete URL was opened in, log it. // If we know what tab the autocomplete URL was opened in, log it.
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
#include <vector> #include <vector>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/metrics/metrics_log_base.h" #include "chrome/common/metrics/metrics_log_base.h"
#include "ui/gfx/size.h"
struct AutocompleteLog; struct AutocompleteLog;
class PrefService; class PrefService;
...@@ -71,6 +73,23 @@ class MetricsLog : public MetricsLogBase { ...@@ -71,6 +73,23 @@ class MetricsLog : public MetricsLogBase {
void RecordIncrementalStabilityElements( void RecordIncrementalStabilityElements(
const std::vector<webkit::WebPluginInfo>& plugin_list); const std::vector<webkit::WebPluginInfo>& plugin_list);
protected:
// Exposed for the sake of mocking in test code.
// Returns the PrefService from which to log metrics data.
virtual PrefService* GetPrefService();
// Returns the screen size for the primary monitor.
virtual gfx::Size GetScreenSize() const;
// Returns the number of monitors the user is using.
virtual int GetScreenCount() const;
// Fills |field_trial_ids| with the list of initialized field trials name and
// group ids.
virtual void GetFieldTrialIds(
std::vector<base::FieldTrial::NameGroupId>* field_trial_ids) const;
private: private:
FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <string> #include <string>
#include "base/basictypes.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/time.h" #include "base/time.h"
#include "chrome/browser/metrics/metrics_log.h" #include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/metrics/proto/system_profile.pb.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/testing_pref_service.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/size.h"
#include "webkit/plugins/webplugininfo.h" #include "webkit/plugins/webplugininfo.h"
using base::TimeDelta; using base::TimeDelta;
namespace { namespace {
// Since buildtime is highly variable, this function will scan an output log and const char kClientId[] = "bogus client ID";
// replace it with a consistent number. const int kSessionId = 127;
void NormalizeBuildtime(std::string* xml_encoded) { const int kScreenWidth = 1024;
std::string prefix = "buildtime=\""; const int kScreenHeight = 768;
const char postfix = '\"'; const int kScreenCount = 3;
size_t offset = xml_encoded->find(prefix); const base::FieldTrial::NameGroupId kFieldTrialIds[] = {
ASSERT_NE(std::string::npos, offset); {37, 43},
offset += prefix.size(); {13, 47},
size_t postfix_position = xml_encoded->find(postfix, offset); {23, 17}
ASSERT_NE(std::string::npos, postfix_position); };
for (size_t i = offset; i < postfix_position; ++i) {
char digit = xml_encoded->at(i); class TestMetricsLog : public MetricsLog {
ASSERT_GE(digit, '0'); public:
ASSERT_LE(digit, '9'); TestMetricsLog(const std::string& client_id, int session_id)
: MetricsLog(client_id, session_id) {
browser::RegisterLocalState(&prefs_);
#if defined(OS_CHROMEOS)
prefs_.SetInteger(prefs::kStabilityChildProcessCrashCount, 10);
prefs_.SetInteger(prefs::kStabilityOtherUserCrashCount, 11);
prefs_.SetInteger(prefs::kStabilityKernelCrashCount, 12);
prefs_.SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13);
#endif // OS_CHROMEOS
} }
virtual ~TestMetricsLog() {}
// Insert a single fake buildtime. virtual PrefService* GetPrefService() OVERRIDE {
xml_encoded->replace(offset, postfix_position - offset, "123246"); return &prefs_;
} }
class NoTimeMetricsLog : public MetricsLog { const metrics::SystemProfileProto& system_profile() const {
public: return uma_proto()->system_profile();
NoTimeMetricsLog(std::string client_id, int session_id): }
MetricsLog(client_id, session_id) {}
virtual ~NoTimeMetricsLog() {}
// Override this so that output is testable. private:
virtual std::string GetCurrentTimeString() { virtual std::string GetCurrentTimeString() OVERRIDE {
return std::string(); return std::string();
} }
virtual void GetFieldTrialIds(
std::vector<base::FieldTrial::NameGroupId>* field_trial_ids) const
OVERRIDE {
ASSERT_TRUE(field_trial_ids->empty());
for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
field_trial_ids->push_back(kFieldTrialIds[i]);
}
}
virtual gfx::Size GetScreenSize() const OVERRIDE {
return gfx::Size(kScreenWidth, kScreenHeight);
}
virtual int GetScreenCount() const OVERRIDE {
return kScreenCount;
}
TestingPrefService prefs_;
DISALLOW_COPY_AND_ASSIGN(TestMetricsLog);
}; };
} // namespace } // namespace
...@@ -57,35 +90,45 @@ class NoTimeMetricsLog : public MetricsLog { ...@@ -57,35 +90,45 @@ class NoTimeMetricsLog : public MetricsLog {
class MetricsLogTest : public testing::Test { class MetricsLogTest : public testing::Test {
}; };
#if defined(OS_CHROMEOS) TEST_F(MetricsLogTest, RecordEnvironment) {
TEST(MetricsLogTest, ChromeOSStabilityData) { // Everything except build_timestamp and app_version
NoTimeMetricsLog log("bogus client ID", 0); TestMetricsLog log(kClientId, kSessionId);
TestingPrefService prefs;
browser::RegisterLocalState(&prefs);
prefs.SetInteger(prefs::kStabilityChildProcessCrashCount, 10);
prefs.SetInteger(prefs::kStabilityOtherUserCrashCount, 11);
prefs.SetInteger(prefs::kStabilityKernelCrashCount, 12);
prefs.SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13);
std::vector<webkit::WebPluginInfo> plugins; std::vector<webkit::WebPluginInfo> plugins;
log.RecordEnvironment(plugins, NULL);
const metrics::SystemProfileProto& system_profile = log.system_profile();
ASSERT_EQ(arraysize(kFieldTrialIds),
static_cast<size_t>(system_profile.field_trial_size()));
for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
const metrics::SystemProfileProto::FieldTrial& field_trial =
system_profile.field_trial(i);
EXPECT_EQ(kFieldTrialIds[i].name, field_trial.name_id());
EXPECT_EQ(kFieldTrialIds[i].group, field_trial.group_id());
}
// TODO(isherman): Verify other data written into the protobuf as a result of
// this call.
}
#if defined(OS_CHROMEOS)
TEST_F(MetricsLogTest, ChromeOSStabilityData) {
TestMetricsLog log(kClientId, kSessionId);
std::string expected_output = base::StringPrintf(
"<log clientid=\"bogus client ID\" buildtime=\"123456789\" "
"appversion=\"%s\">\n"
"<stability stuff>\n", MetricsLog::GetVersionString().c_str());
// Expect 3 warnings about not yet being able to send the // Expect 3 warnings about not yet being able to send the
// Chrome OS stability stats. // Chrome OS stability stats.
log.WriteStabilityElement(plugins, &prefs); std::vector<webkit::WebPluginInfo> plugins;
PrefService* prefs = log.GetPrefService();
log.WriteStabilityElement(plugins, prefs);
log.CloseLog(); log.CloseLog();
int size = log.GetEncodedLogSizeXml(); int size = log.GetEncodedLogSizeXml();
ASSERT_GT(size, 0); ASSERT_GT(size, 0);
EXPECT_EQ(0, prefs.GetInteger(prefs::kStabilityChildProcessCrashCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityChildProcessCrashCount));
EXPECT_EQ(0, prefs.GetInteger(prefs::kStabilityOtherUserCrashCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityOtherUserCrashCount));
EXPECT_EQ(0, prefs.GetInteger(prefs::kStabilityKernelCrashCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityKernelCrashCount));
EXPECT_EQ(0, prefs.GetInteger(prefs::kStabilitySystemUncleanShutdownCount)); EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilitySystemUncleanShutdownCount));
std::string encoded; std::string encoded;
// Leave room for the NUL terminator. // Leave room for the NUL terminator.
......
...@@ -123,12 +123,12 @@ class MetricsLogBase::XmlWrapper { ...@@ -123,12 +123,12 @@ class MetricsLogBase::XmlWrapper {
MetricsLogBase::MetricsLogBase(const std::string& client_id, int session_id, MetricsLogBase::MetricsLogBase(const std::string& client_id, int session_id,
const std::string& version_string) const std::string& version_string)
: start_time_(Time::Now()), : num_events_(0),
start_time_(Time::Now()),
client_id_(client_id), client_id_(client_id),
session_id_(base::IntToString(session_id)), session_id_(base::IntToString(session_id)),
locked_(false), locked_(false),
xml_wrapper_(new XmlWrapper), xml_wrapper_(new XmlWrapper) {
num_events_(0) {
int64_t build_time = GetBuildTime(); int64_t build_time = GetBuildTime();
// Write the XML version. // Write the XML version.
......
...@@ -104,6 +104,7 @@ class MetricsLogBase { ...@@ -104,6 +104,7 @@ class MetricsLogBase {
// Returns a string containing the current time. // Returns a string containing the current time.
// Virtual so that it can be overridden for testing. // Virtual so that it can be overridden for testing.
// TODO(isherman): Remove this method once the XML pipeline is old news.
virtual std::string GetCurrentTimeString(); virtual std::string GetCurrentTimeString();
// Helper class that invokes StartElement from constructor, and EndElement // Helper class that invokes StartElement from constructor, and EndElement
// from destructor. // from destructor.
...@@ -147,6 +148,17 @@ class MetricsLogBase { ...@@ -147,6 +148,17 @@ class MetricsLogBase {
// Write the attributes that are common to every metrics event type. // Write the attributes that are common to every metrics event type.
void WriteCommonEventAttributes(); void WriteCommonEventAttributes();
bool locked() const { return locked_; }
metrics::ChromeUserMetricsExtension* uma_proto() { return &uma_proto_; }
const metrics::ChromeUserMetricsExtension* uma_proto() const {
return &uma_proto_;
}
// TODO(isherman): Remove this once the XML pipeline is outta here.
int num_events_; // the number of events recorded in this log
private:
base::Time start_time_; base::Time start_time_;
base::Time end_time_; base::Time end_time_;
...@@ -162,12 +174,9 @@ class MetricsLogBase { ...@@ -162,12 +174,9 @@ class MetricsLogBase {
// Isolated to limit the dependency on the XML library for our consumers. // Isolated to limit the dependency on the XML library for our consumers.
XmlWrapper* xml_wrapper_; XmlWrapper* xml_wrapper_;
int num_events_; // the number of events recorded in this log
// Stores the protocol buffer representation for this log. // Stores the protocol buffer representation for this log.
metrics::ChromeUserMetricsExtension uma_proto_; metrics::ChromeUserMetricsExtension uma_proto_;
private:
DISALLOW_COPY_AND_ASSIGN(MetricsLogBase); DISALLOW_COPY_AND_ASSIGN(MetricsLogBase);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment