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

Unified Diff: content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h

Issue 334303002: Using a mock LevelDBTransaction for corruption tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LevelDBTraceTansaction::s_class_name is now static Created 6 years, 6 months 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: content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
diff --git a/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..b30f150cb4a2944267af23f7bd4de46d87467cb8
--- /dev/null
+++ b/content/browser/indexed_db/mock_browsertest_indexed_db_class_factory.h
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_
+#define CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_
+
+#include <map>
+
+#include "content/browser/indexed_db/indexed_db_class_factory.h"
+
+namespace content {
+
+class LevelDBTransaction;
+class LevelDBDatabase;
+
+enum FailClass {
+ FAIL_CLASS_NOTHING,
+ FAIL_CLASS_LEVELDB_TRANSACTION,
+};
+
+enum FailMethod {
+ FAIL_METHOD_NOTHING,
+ FAIL_METHOD_COMMIT,
+ FAIL_METHOD_GET,
+};
+
+class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory {
+ public:
+ MockBrowserTestIndexedDBClassFactory();
+ virtual ~MockBrowserTestIndexedDBClassFactory();
+ virtual LevelDBTransaction* CreateLevelDBTransaction(
+ LevelDBDatabase* db) OVERRIDE;
+
+ void FailOperation(FailClass failure_class,
+ FailMethod failure_method,
+ int fail_on_instance_num,
+ int fail_on_call_num);
+ void Reset();
+
+ private:
+ FailClass failure_class_;
+ FailMethod failure_method_;
+ std::map<FailClass, int> instance_count_;
+ std::map<FailClass, int> fail_on_instance_num_;
+ std::map<FailClass, int> fail_on_call_num_;
+ bool only_trace_calls_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698