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

Unified Diff: components/metrics/metrics_service_unittest.cc

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: extract common histogram FactoryGet code; extract histogram persistence into seperate files Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/metrics_service_unittest.cc
diff --git a/components/metrics/metrics_service_unittest.cc b/components/metrics/metrics_service_unittest.cc
index b306c9b7523c3e36d4b84cb8586cd9d841331ccf..8a402149af614e40a6f85770ef5747c7c09bce7e 100644
--- a/components/metrics/metrics_service_unittest.cc
+++ b/components/metrics/metrics_service_unittest.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram_base.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/statistics_recorder.h"
#include "base/prefs/testing_pref_service.h"
@@ -390,4 +391,62 @@ TEST_F(MetricsServiceTest,
EXPECT_TRUE(test_provider->on_recording_disabled_called());
}
+TEST_F(MetricsServiceTest, MultiplePersistentAllocators) {
+ base::HistogramBase::SetDefaultPersistentMemoryAllocator(
+ new base::LocalPersistentMemoryAllocator(64 << 10, 0, std::string()));
+ scoped_ptr<base::PersistentMemoryAllocator> pma1;
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA1A", 30);
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA1B", 30);
+ pma1.reset(base::HistogramBase::ReleaseDefaultPersistentMemoryAllocator());
+
+ base::HistogramBase::SetDefaultPersistentMemoryAllocator(
+ new base::LocalPersistentMemoryAllocator(64 << 10, 0, std::string()));
+ scoped_ptr<base::PersistentMemoryAllocator> pma2;
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA2A", 30);
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA2B", 30);
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA2C", 30);
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA2D", 30);
+ pma2.reset(base::HistogramBase::ReleaseDefaultPersistentMemoryAllocator());
+
+ base::HistogramBase::SetDefaultPersistentMemoryAllocator(
+ new base::LocalPersistentMemoryAllocator(64 << 10, 0, std::string()));
+
+ TestMetricsServiceClient client;
+ TestMetricsService service(
+ GetMetricsStateManager(), &client, GetLocalState());
+
+ {
+ MetricsService::PersistentHistogramIterator i = service.persistent_begin();
+ EXPECT_EQ(service.persistent_end(), i);
+ }
+
+ LOCAL_HISTOGRAM_COUNTS("MetricsServiceTest.MPA3A", 30);
+ {
+ MetricsService::PersistentHistogramIterator i = service.persistent_begin();
+ EXPECT_EQ(service.persistent_end(), i);
+ }
+
+ service.AddPersistentMemorySegment(pma1.get());
+ {
+ MetricsService::PersistentHistogramIterator i = service.persistent_begin();
+ EXPECT_NE(service.persistent_end(), i);
+ EXPECT_TRUE(*i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_TRUE(*i);
+ EXPECT_EQ(service.persistent_end(), ++i);
+ }
+
+ service.AddPersistentMemorySegment(pma2.get());
+ {
+ MetricsService::PersistentHistogramIterator i = service.persistent_begin();
+ EXPECT_NE(service.persistent_end(), i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_NE(service.persistent_end(), ++i);
+ EXPECT_EQ(service.persistent_end(), ++i);
+ }
+}
+
} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698