OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_ | 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_ | 6 #define CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 12 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
13 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 13 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| 14 #include "content/browser/indexed_db/indexed_db_database.h" |
14 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 15 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class LevelDBTransaction; | 19 class LevelDBTransaction; |
19 class LevelDBDatabase; | 20 class LevelDBDatabase; |
20 | 21 |
21 enum FailClass { | 22 enum FailClass { |
22 FAIL_CLASS_NOTHING, | 23 FAIL_CLASS_NOTHING, |
23 FAIL_CLASS_LEVELDB_ITERATOR, | 24 FAIL_CLASS_LEVELDB_ITERATOR, |
24 FAIL_CLASS_LEVELDB_TRANSACTION, | 25 FAIL_CLASS_LEVELDB_TRANSACTION, |
25 }; | 26 }; |
26 | 27 |
27 enum FailMethod { | 28 enum FailMethod { |
28 FAIL_METHOD_NOTHING, | 29 FAIL_METHOD_NOTHING, |
29 FAIL_METHOD_COMMIT, | 30 FAIL_METHOD_COMMIT, |
30 FAIL_METHOD_COMMIT_DISK_FULL, | 31 FAIL_METHOD_COMMIT_DISK_FULL, |
31 FAIL_METHOD_GET, | 32 FAIL_METHOD_GET, |
32 FAIL_METHOD_SEEK, | 33 FAIL_METHOD_SEEK, |
33 }; | 34 }; |
34 | 35 |
35 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory { | 36 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory { |
36 public: | 37 public: |
37 MockBrowserTestIndexedDBClassFactory(); | 38 MockBrowserTestIndexedDBClassFactory(); |
38 ~MockBrowserTestIndexedDBClassFactory() override; | 39 ~MockBrowserTestIndexedDBClassFactory() override; |
| 40 |
| 41 IndexedDBDatabase* CreateIndexedDBDatabase( |
| 42 const base::string16& name, |
| 43 IndexedDBBackingStore* backing_store, |
| 44 IndexedDBFactory* factory, |
| 45 const IndexedDBDatabase::Identifier& unique_identifier) override; |
39 IndexedDBTransaction* CreateIndexedDBTransaction( | 46 IndexedDBTransaction* CreateIndexedDBTransaction( |
40 int64 id, | 47 int64 id, |
41 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | 48 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, |
42 const std::set<int64>& scope, | 49 const std::set<int64>& scope, |
43 blink::WebIDBTransactionMode mode, | 50 blink::WebIDBTransactionMode mode, |
44 IndexedDBDatabase* db, | 51 IndexedDBDatabase* db, |
45 IndexedDBBackingStore::Transaction* backing_store_transaction) override; | 52 IndexedDBBackingStore::Transaction* backing_store_transaction) override; |
46 LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override; | 53 LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override; |
47 LevelDBIteratorImpl* CreateIteratorImpl( | 54 LevelDBIteratorImpl* CreateIteratorImpl( |
48 scoped_ptr<leveldb::Iterator> iterator) override; | 55 scoped_ptr<leveldb::Iterator> iterator) override; |
49 | 56 |
50 void FailOperation(FailClass failure_class, | 57 void FailOperation(FailClass failure_class, |
51 FailMethod failure_method, | 58 FailMethod failure_method, |
52 int fail_on_instance_num, | 59 int fail_on_instance_num, |
53 int fail_on_call_num); | 60 int fail_on_call_num); |
54 void Reset(); | 61 void Reset(); |
55 | 62 |
56 private: | 63 private: |
57 FailClass failure_class_; | 64 FailClass failure_class_; |
58 FailMethod failure_method_; | 65 FailMethod failure_method_; |
59 std::map<FailClass, int> instance_count_; | 66 std::map<FailClass, int> instance_count_; |
60 std::map<FailClass, int> fail_on_instance_num_; | 67 std::map<FailClass, int> fail_on_instance_num_; |
61 std::map<FailClass, int> fail_on_call_num_; | 68 std::map<FailClass, int> fail_on_call_num_; |
62 bool only_trace_calls_; | 69 bool only_trace_calls_; |
63 }; | 70 }; |
64 | 71 |
65 } // namespace content | 72 } // namespace content |
66 | 73 |
67 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_
H_ | 74 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_
H_ |
OLD | NEW |