diff options
author | cmumford <cmumford@chromium.org> | 2015-10-13 10:02:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-13 17:03:01 +0000 |
commit | 5187806982cdaf12248d947a3f12c544a1ae79b3 (patch) | |
tree | 2c64e029cf24fd70710dca5ba03bbc579b9eff68 /components/leveldb_proto/proto_database_impl_unittest.cc | |
parent | 9ebbe4a764585a8ba96a8e383e6d9655ea6cba96 (diff) | |
download | chromium_src-5187806982cdaf12248d947a3f12c544a1ae79b3.zip chromium_src-5187806982cdaf12248d947a3f12c544a1ae79b3.tar.gz chromium_src-5187806982cdaf12248d947a3f12c544a1ae79b3.tar.bz2 |
Added UMA stats reporting to LevelDB proto.
Adding stats to report usage (and detect potential corruption).
BUG=508330
Review URL: https://codereview.chromium.org/1228143002
Cr-Commit-Position: refs/heads/master@{#353773}
Diffstat (limited to 'components/leveldb_proto/proto_database_impl_unittest.cc')
-rw-r--r-- | components/leveldb_proto/proto_database_impl_unittest.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/components/leveldb_proto/proto_database_impl_unittest.cc b/components/leveldb_proto/proto_database_impl_unittest.cc index 76b4ae5..ca145c4 100644 --- a/components/leveldb_proto/proto_database_impl_unittest.cc +++ b/components/leveldb_proto/proto_database_impl_unittest.cc @@ -30,13 +30,15 @@ namespace { typedef std::map<std::string, TestProto> EntryMap; +const char kTestLevelDBClientName[] = "Test"; + class MockDB : public LevelDB { public: MOCK_METHOD1(Init, bool(const base::FilePath&)); MOCK_METHOD2(Save, bool(const KeyValueVector&, const KeyVector&)); MOCK_METHOD1(Load, bool(std::vector<std::string>*)); - MockDB() { + MockDB() : LevelDB(kTestLevelDBClientName) { ON_CALL(*this, Init(_)).WillByDefault(Return(true)); ON_CALL(*this, Save(_, _)).WillByDefault(Return(true)); ON_CALL(*this, Load(_)).WillByDefault(Return(true)); @@ -340,8 +342,9 @@ TEST(ProtoDatabaseImplThreadingTest, TestDBDestruction) { MockDatabaseCaller caller; EXPECT_CALL(caller, InitCallback(_)); - db->Init(temp_dir.path(), base::Bind(&MockDatabaseCaller::InitCallback, - base::Unretained(&caller))); + db->Init( + kTestLevelDBClientName, temp_dir.path(), + base::Bind(&MockDatabaseCaller::InitCallback, base::Unretained(&caller))); db.reset(); @@ -369,12 +372,12 @@ void TestLevelDBSaveAndLoad(bool close_after_save) { std::make_pair(pair.second.id(), pair.second.SerializeAsString())); } - scoped_ptr<LevelDB> db(new LevelDB()); + scoped_ptr<LevelDB> db(new LevelDB(kTestLevelDBClientName)); EXPECT_TRUE(db->Init(temp_dir.path())); EXPECT_TRUE(db->Save(save_entries, remove_keys)); if (close_after_save) { - db.reset(new LevelDB()); + db.reset(new LevelDB(kTestLevelDBClientName)); EXPECT_TRUE(db->Init(temp_dir.path())); } @@ -405,7 +408,7 @@ TEST(ProtoDatabaseImplLevelDBTest, TestDBInitFail) { leveldb::Options options; options.create_if_missing = false; - scoped_ptr<LevelDB> db(new LevelDB()); + scoped_ptr<LevelDB> db(new LevelDB(kTestLevelDBClientName)); KeyValueVector save_entries; std::vector<std::string> load_entries; @@ -417,7 +420,7 @@ TEST(ProtoDatabaseImplLevelDBTest, TestDBInitFail) { } TEST(ProtoDatabaseImplLevelDBTest, TestMemoryDatabase) { - scoped_ptr<LevelDB> db(new LevelDB()); + scoped_ptr<LevelDB> db(new LevelDB(kTestLevelDBClientName)); std::vector<std::string> load_entries; |