Commit 1ebdce33 authored by gunsch@chromium.org's avatar gunsch@chromium.org

Moves components/metrics/chromeos to c/m/serialization/.

This allows other clients to use the external serialization utils.

R=bsimonnet@chromium.org,isherman@chromium.org,asvitkine@chromium.org
BUG=343624

Review URL: https://codereview.chromium.org/394093003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283880 0039d316-1c4b-4281-b951-d872f2087c98
parent 8da530a1
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "base/timer/elapsed_timer.h" #include "base/timer/elapsed_timer.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/chromeos_metrics_provider.h" #include "chrome/browser/metrics/chromeos_metrics_provider.h"
#include "components/metrics/chromeos/metric_sample.h"
#include "components/metrics/chromeos/serialization_utils.h"
#include "components/metrics/metrics_service.h" #include "components/metrics/metrics_service.h"
#include "components/metrics/serialization/metric_sample.h"
#include "components/metrics/serialization/serialization_utils.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "base/metrics/statistics_recorder.h" #include "base/metrics/statistics_recorder.h"
#include "chrome/browser/chromeos/external_metrics.h" #include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/test/base/uma_histogram_helper.h" #include "chrome/test/base/uma_histogram_helper.h"
#include "components/metrics/chromeos/metric_sample.h" #include "components/metrics/serialization/metric_sample.h"
#include "components/metrics/chromeos/serialization_utils.h" #include "components/metrics/serialization/serialization_utils.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
namespace chromeos { // Need this because of the FRIEND_TEST namespace chromeos { // Need this because of the FRIEND_TEST
......
...@@ -559,19 +559,19 @@ ...@@ -559,19 +559,19 @@
], ],
}], }],
['chromeos==1', { ['chromeos==1', {
'sources': [
'metrics/chromeos/serialization_utils_unittest.cc',
],
'sources!': [ 'sources!': [
'storage_monitor/storage_monitor_linux_unittest.cc', 'storage_monitor/storage_monitor_linux_unittest.cc',
], ],
'dependencies': [ 'dependencies': [
'../chromeos/chromeos.gyp:chromeos_test_support', '../chromeos/chromeos.gyp:chromeos_test_support',
'components.gyp:metrics_chromeos',
], ],
}], }],
['OS=="linux"', { ['OS=="linux"', {
'sources': [
'metrics/serialization/serialization_utils_unittest.cc',
],
'dependencies': [ 'dependencies': [
'components.gyp:metrics_serialization',
'../dbus/dbus.gyp:dbus', '../dbus/dbus.gyp:dbus',
'../device/media_transfer_protocol/media_transfer_protocol.gyp:device_media_transfer_protocol', '../device/media_transfer_protocol/media_transfer_protocol.gyp:device_media_transfer_protocol',
], ],
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
'conditions': [ 'conditions': [
['chromeos==1', { ['chromeos==1', {
'dependencies': [ 'dependencies': [
'metrics_chromeos', 'metrics_serialization',
], ],
}], }],
['OS=="win"', { ['OS=="win"', {
...@@ -125,16 +125,16 @@ ...@@ -125,16 +125,16 @@
}, },
], ],
'conditions': [ 'conditions': [
['chromeos==1', { ['OS=="linux"', {
'targets': [ 'targets': [
{ {
'target_name': 'metrics_chromeos', 'target_name': 'metrics_serialization',
'type': 'static_library', 'type': 'static_library',
'sources': [ 'sources': [
'metrics/chromeos/serialization_utils.cc', 'metrics/serialization/serialization_utils.cc',
'metrics/chromeos/serialization_utils.h', 'metrics/serialization/serialization_utils.h',
'metrics/chromeos/metric_sample.cc', 'metrics/serialization/metric_sample.cc',
'metrics/chromeos/metric_sample.h', 'metrics/serialization/metric_sample.h',
], ],
'dependencies': [ 'dependencies': [
'../base/base.gyp:base', '../base/base.gyp:base',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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 "components/metrics/chromeos/metric_sample.h" #include "components/metrics/serialization/metric_sample.h"
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// 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.
#ifndef COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ #ifndef COMPONENTS_METRICS_SERIALIZATION_METRIC_SAMPLE_H_
#define COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ #define COMPONENTS_METRICS_SERIALIZATION_METRIC_SAMPLE_H_
#include <string> #include <string>
...@@ -116,4 +116,4 @@ class MetricSample { ...@@ -116,4 +116,4 @@ class MetricSample {
} // namespace metrics } // namespace metrics
#endif // COMPONENTS_METRICS_CHROMEOS_METRIC_SAMPLE_H_ #endif // COMPONENTS_METRICS_SERIALIZATION_METRIC_SAMPLE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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 "components/metrics/chromeos/serialization_utils.h" #include "components/metrics/serialization/serialization_utils.h"
#include <sys/file.h> #include <sys/file.h>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "components/metrics/chromeos/metric_sample.h" #include "components/metrics/serialization/metric_sample.h"
#define READ_WRITE_ALL_FILE_FLAGS \ #define READ_WRITE_ALL_FILE_FLAGS \
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// 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.
#ifndef COMPONENTS_METRICS_CHROMEOS_SERIALIZATION_UTILS_H_ #ifndef COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
#define COMPONENTS_METRICS_CHROMEOS_SERIALIZATION_UTILS_H_ #define COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
#include <string> #include <string>
...@@ -45,4 +45,4 @@ static const int kMessageMaxLength = 1024; ...@@ -45,4 +45,4 @@ static const int kMessageMaxLength = 1024;
} // namespace SerializationUtils } // namespace SerializationUtils
} // namespace metrics } // namespace metrics
#endif // COMPONENTS_METRICS_CHROMEOS_SERIALIZATION_UTILS_H_ #endif // COMPONENTS_METRICS_SERIALIZATION_SERIALIZATION_UTILS_H_
...@@ -2,21 +2,21 @@ ...@@ -2,21 +2,21 @@
// 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 "components/metrics/chromeos/serialization_utils.h" #include "components/metrics/serialization/serialization_utils.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "components/metrics/chromeos/metric_sample.h" #include "components/metrics/serialization/metric_sample.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace metrics { namespace metrics {
namespace { namespace {
class SerializationUtilsChromeOSTest : public testing::Test { class SerializationUtilsTest : public testing::Test {
protected: protected:
SerializationUtilsChromeOSTest() { SerializationUtilsTest() {
bool success = temporary_dir.CreateUniqueTempDir(); bool success = temporary_dir.CreateUniqueTempDir();
if (success) { if (success) {
base::FilePath dir_path = temporary_dir.path(); base::FilePath dir_path = temporary_dir.path();
...@@ -43,29 +43,29 @@ class SerializationUtilsChromeOSTest : public testing::Test { ...@@ -43,29 +43,29 @@ class SerializationUtilsChromeOSTest : public testing::Test {
base::FilePath filepath; base::FilePath filepath;
}; };
TEST_F(SerializationUtilsChromeOSTest, CrashSerializeTest) { TEST_F(SerializationUtilsTest, CrashSerializeTest) {
TestSerialization(MetricSample::CrashSample("test").get()); TestSerialization(MetricSample::CrashSample("test").get());
} }
TEST_F(SerializationUtilsChromeOSTest, HistogramSerializeTest) { TEST_F(SerializationUtilsTest, HistogramSerializeTest) {
TestSerialization( TestSerialization(
MetricSample::HistogramSample("myhist", 13, 1, 100, 10).get()); MetricSample::HistogramSample("myhist", 13, 1, 100, 10).get());
} }
TEST_F(SerializationUtilsChromeOSTest, LinearSerializeTest) { TEST_F(SerializationUtilsTest, LinearSerializeTest) {
TestSerialization( TestSerialization(
MetricSample::LinearHistogramSample("linearhist", 12, 30).get()); MetricSample::LinearHistogramSample("linearhist", 12, 30).get());
} }
TEST_F(SerializationUtilsChromeOSTest, SparseSerializeTest) { TEST_F(SerializationUtilsTest, SparseSerializeTest) {
TestSerialization(MetricSample::SparseHistogramSample("mysparse", 30).get()); TestSerialization(MetricSample::SparseHistogramSample("mysparse", 30).get());
} }
TEST_F(SerializationUtilsChromeOSTest, UserActionSerializeTest) { TEST_F(SerializationUtilsTest, UserActionSerializeTest) {
TestSerialization(MetricSample::UserActionSample("myaction").get()); TestSerialization(MetricSample::UserActionSample("myaction").get());
} }
TEST_F(SerializationUtilsChromeOSTest, IllegalNameAreFilteredTest) { TEST_F(SerializationUtilsTest, IllegalNameAreFilteredTest) {
scoped_ptr<MetricSample> sample1 = scoped_ptr<MetricSample> sample1 =
MetricSample::SparseHistogramSample("no space", 10); MetricSample::SparseHistogramSample("no space", 10);
scoped_ptr<MetricSample> sample2 = MetricSample::LinearHistogramSample( scoped_ptr<MetricSample> sample2 = MetricSample::LinearHistogramSample(
...@@ -80,13 +80,13 @@ TEST_F(SerializationUtilsChromeOSTest, IllegalNameAreFilteredTest) { ...@@ -80,13 +80,13 @@ TEST_F(SerializationUtilsChromeOSTest, IllegalNameAreFilteredTest) {
EXPECT_EQ(0, size); EXPECT_EQ(0, size);
} }
TEST_F(SerializationUtilsChromeOSTest, BadInputIsCaughtTest) { TEST_F(SerializationUtilsTest, BadInputIsCaughtTest) {
std::string input( std::string input(
base::StringPrintf("sparsehistogram%cname foo%c", '\0', '\0')); base::StringPrintf("sparsehistogram%cname foo%c", '\0', '\0'));
EXPECT_EQ(NULL, MetricSample::ParseSparseHistogram(input).get()); EXPECT_EQ(NULL, MetricSample::ParseSparseHistogram(input).get());
} }
TEST_F(SerializationUtilsChromeOSTest, MessageSeparatedByZero) { TEST_F(SerializationUtilsTest, MessageSeparatedByZero) {
scoped_ptr<MetricSample> crash = MetricSample::CrashSample("mycrash"); scoped_ptr<MetricSample> crash = MetricSample::CrashSample("mycrash");
SerializationUtils::WriteMetricToFile(*crash.get(), filename); SerializationUtils::WriteMetricToFile(*crash.get(), filename);
...@@ -100,7 +100,7 @@ TEST_F(SerializationUtilsChromeOSTest, MessageSeparatedByZero) { ...@@ -100,7 +100,7 @@ TEST_F(SerializationUtilsChromeOSTest, MessageSeparatedByZero) {
EXPECT_EQ(size, 18); EXPECT_EQ(size, 18);
} }
TEST_F(SerializationUtilsChromeOSTest, MessagesTooLongAreDiscardedTest) { TEST_F(SerializationUtilsTest, MessagesTooLongAreDiscardedTest) {
// Creates a message that is bigger than the maximum allowed size. // Creates a message that is bigger than the maximum allowed size.
// As we are adding extra character (crash, \0s, etc), if the name is // As we are adding extra character (crash, \0s, etc), if the name is
// kMessageMaxLength long, it will be too long. // kMessageMaxLength long, it will be too long.
...@@ -113,7 +113,7 @@ TEST_F(SerializationUtilsChromeOSTest, MessagesTooLongAreDiscardedTest) { ...@@ -113,7 +113,7 @@ TEST_F(SerializationUtilsChromeOSTest, MessagesTooLongAreDiscardedTest) {
EXPECT_EQ(0, size); EXPECT_EQ(0, size);
} }
TEST_F(SerializationUtilsChromeOSTest, ReadLongMessageTest) { TEST_F(SerializationUtilsTest, ReadLongMessageTest) {
base::File test_file(filepath, base::File test_file(filepath,
base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND); base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND);
std::string message(SerializationUtils::kMessageMaxLength + 1, 'c'); std::string message(SerializationUtils::kMessageMaxLength + 1, 'c');
...@@ -134,7 +134,7 @@ TEST_F(SerializationUtilsChromeOSTest, ReadLongMessageTest) { ...@@ -134,7 +134,7 @@ TEST_F(SerializationUtilsChromeOSTest, ReadLongMessageTest) {
EXPECT_TRUE(crash->IsEqual(*samples[0])); EXPECT_TRUE(crash->IsEqual(*samples[0]));
} }
TEST_F(SerializationUtilsChromeOSTest, WriteReadTest) { TEST_F(SerializationUtilsTest, WriteReadTest) {
scoped_ptr<MetricSample> hist = scoped_ptr<MetricSample> hist =
MetricSample::HistogramSample("myhist", 1, 2, 3, 4); MetricSample::HistogramSample("myhist", 1, 2, 3, 4);
scoped_ptr<MetricSample> crash = MetricSample::CrashSample("mycrash"); scoped_ptr<MetricSample> crash = MetricSample::CrashSample("mycrash");
......
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