b30f150cb4a2944267af23f7bd4de46d87467cb8
[platform/framework/web/crosswalk.git] / src / content / browser / indexed_db / mock_browsertest_indexed_db_class_factory.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_
6 #define CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_
7
8 #include <map>
9
10 #include "content/browser/indexed_db/indexed_db_class_factory.h"
11
12 namespace content {
13
14 class LevelDBTransaction;
15 class LevelDBDatabase;
16
17 enum FailClass {
18   FAIL_CLASS_NOTHING,
19   FAIL_CLASS_LEVELDB_TRANSACTION,
20 };
21
22 enum FailMethod {
23   FAIL_METHOD_NOTHING,
24   FAIL_METHOD_COMMIT,
25   FAIL_METHOD_GET,
26 };
27
28 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory {
29  public:
30   MockBrowserTestIndexedDBClassFactory();
31   virtual ~MockBrowserTestIndexedDBClassFactory();
32   virtual LevelDBTransaction* CreateLevelDBTransaction(
33       LevelDBDatabase* db) OVERRIDE;
34
35   void FailOperation(FailClass failure_class,
36                      FailMethod failure_method,
37                      int fail_on_instance_num,
38                      int fail_on_call_num);
39   void Reset();
40
41  private:
42   FailClass failure_class_;
43   FailMethod failure_method_;
44   std::map<FailClass, int> instance_count_;
45   std::map<FailClass, int> fail_on_instance_num_;
46   std::map<FailClass, int> fail_on_call_num_;
47   bool only_trace_calls_;
48 };
49
50 }  // namespace content
51
52 #endif  // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_