| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 | 13 |
| 14 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 14 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 15 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 15 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| 16 #include "content/browser/indexed_db/indexed_db_database.h" | 16 #include "content/browser/indexed_db/indexed_db_database.h" |
| 17 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 17 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class IndexedDBConnection; |
| 21 class LevelDBTransaction; | 22 class LevelDBTransaction; |
| 22 class LevelDBDatabase; | 23 class LevelDBDatabase; |
| 23 | 24 |
| 24 enum FailClass { | 25 enum FailClass { |
| 25 FAIL_CLASS_NOTHING, | 26 FAIL_CLASS_NOTHING, |
| 26 FAIL_CLASS_LEVELDB_ITERATOR, | 27 FAIL_CLASS_LEVELDB_ITERATOR, |
| 27 FAIL_CLASS_LEVELDB_TRANSACTION, | 28 FAIL_CLASS_LEVELDB_TRANSACTION, |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 enum FailMethod { | 31 enum FailMethod { |
| 31 FAIL_METHOD_NOTHING, | 32 FAIL_METHOD_NOTHING, |
| 32 FAIL_METHOD_COMMIT, | 33 FAIL_METHOD_COMMIT, |
| 33 FAIL_METHOD_COMMIT_DISK_FULL, | 34 FAIL_METHOD_COMMIT_DISK_FULL, |
| 34 FAIL_METHOD_GET, | 35 FAIL_METHOD_GET, |
| 35 FAIL_METHOD_SEEK, | 36 FAIL_METHOD_SEEK, |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory { | 39 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory { |
| 39 public: | 40 public: |
| 40 MockBrowserTestIndexedDBClassFactory(); | 41 MockBrowserTestIndexedDBClassFactory(); |
| 41 ~MockBrowserTestIndexedDBClassFactory() override; | 42 ~MockBrowserTestIndexedDBClassFactory() override; |
| 42 | 43 |
| 43 IndexedDBDatabase* CreateIndexedDBDatabase( | 44 IndexedDBDatabase* CreateIndexedDBDatabase( |
| 44 const base::string16& name, | 45 const base::string16& name, |
| 45 IndexedDBBackingStore* backing_store, | 46 IndexedDBBackingStore* backing_store, |
| 46 IndexedDBFactory* factory, | 47 IndexedDBFactory* factory, |
| 47 const IndexedDBDatabase::Identifier& unique_identifier) override; | 48 const IndexedDBDatabase::Identifier& unique_identifier) override; |
| 48 IndexedDBTransaction* CreateIndexedDBTransaction( | 49 IndexedDBTransaction* CreateIndexedDBTransaction( |
| 49 int64_t id, | 50 int64_t id, |
| 50 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | 51 base::WeakPtr<IndexedDBConnection> connection, |
| 51 const std::set<int64_t>& scope, | 52 const std::set<int64_t>& scope, |
| 52 blink::WebIDBTransactionMode mode, | 53 blink::WebIDBTransactionMode mode, |
| 53 IndexedDBDatabase* db, | |
| 54 IndexedDBBackingStore::Transaction* backing_store_transaction) override; | 54 IndexedDBBackingStore::Transaction* backing_store_transaction) override; |
| 55 LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override; | 55 LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override; |
| 56 LevelDBIteratorImpl* CreateIteratorImpl( | 56 LevelDBIteratorImpl* CreateIteratorImpl( |
| 57 std::unique_ptr<leveldb::Iterator> iterator) override; | 57 std::unique_ptr<leveldb::Iterator> iterator) override; |
| 58 | 58 |
| 59 void FailOperation(FailClass failure_class, | 59 void FailOperation(FailClass failure_class, |
| 60 FailMethod failure_method, | 60 FailMethod failure_method, |
| 61 int fail_on_instance_num, | 61 int fail_on_instance_num, |
| 62 int fail_on_call_num); | 62 int fail_on_call_num); |
| 63 void Reset(); | 63 void Reset(); |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 FailClass failure_class_; | 66 FailClass failure_class_; |
| 67 FailMethod failure_method_; | 67 FailMethod failure_method_; |
| 68 std::map<FailClass, int> instance_count_; | 68 std::map<FailClass, int> instance_count_; |
| 69 std::map<FailClass, int> fail_on_instance_num_; | 69 std::map<FailClass, int> fail_on_instance_num_; |
| 70 std::map<FailClass, int> fail_on_call_num_; | 70 std::map<FailClass, int> fail_on_call_num_; |
| 71 bool only_trace_calls_; | 71 bool only_trace_calls_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace content | 74 } // namespace content |
| 75 | 75 |
| 76 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_
H_ | 76 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_
H_ |
| OLD | NEW |