Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / content / browser / indexed_db / mock_browsertest_indexed_db_class_factory.h
blob1b77071f0e559365464001b95cbd19abbd07b4a1
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.
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_
8 #include <map>
9 #include <set>
11 #include "base/memory/scoped_ptr.h"
12 #include "content/browser/indexed_db/indexed_db_backing_store.h"
13 #include "content/browser/indexed_db/indexed_db_class_factory.h"
14 #include "content/browser/indexed_db/indexed_db_database.h"
15 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
17 namespace content {
19 class LevelDBTransaction;
20 class LevelDBDatabase;
22 enum FailClass {
23 FAIL_CLASS_NOTHING,
24 FAIL_CLASS_LEVELDB_ITERATOR,
25 FAIL_CLASS_LEVELDB_TRANSACTION,
28 enum FailMethod {
29 FAIL_METHOD_NOTHING,
30 FAIL_METHOD_COMMIT,
31 FAIL_METHOD_COMMIT_DISK_FULL,
32 FAIL_METHOD_GET,
33 FAIL_METHOD_SEEK,
36 class MockBrowserTestIndexedDBClassFactory : public IndexedDBClassFactory {
37 public:
38 MockBrowserTestIndexedDBClassFactory();
39 ~MockBrowserTestIndexedDBClassFactory() override;
41 IndexedDBDatabase* CreateIndexedDBDatabase(
42 const base::string16& name,
43 IndexedDBBackingStore* backing_store,
44 IndexedDBFactory* factory,
45 const IndexedDBDatabase::Identifier& unique_identifier) override;
46 IndexedDBTransaction* CreateIndexedDBTransaction(
47 int64 id,
48 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks,
49 const std::set<int64>& scope,
50 blink::WebIDBTransactionMode mode,
51 IndexedDBDatabase* db,
52 IndexedDBBackingStore::Transaction* backing_store_transaction) override;
53 LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db) override;
54 LevelDBIteratorImpl* CreateIteratorImpl(
55 scoped_ptr<leveldb::Iterator> iterator) override;
57 void FailOperation(FailClass failure_class,
58 FailMethod failure_method,
59 int fail_on_instance_num,
60 int fail_on_call_num);
61 void Reset();
63 private:
64 FailClass failure_class_;
65 FailMethod failure_method_;
66 std::map<FailClass, int> instance_count_;
67 std::map<FailClass, int> fail_on_instance_num_;
68 std::map<FailClass, int> fail_on_call_num_;
69 bool only_trace_calls_;
72 } // namespace content
74 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_BROWSERTEST_INDEXED_DB_CLASS_FACTORY_H_