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_INDEXED_DB_CLASS_FACTORY_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_
10 #include "base/lazy_instance.h"
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_database.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
19 } // namespace leveldb
23 class IndexedDBBackingStore
;
24 class IndexedDBDatabaseCallbacks
;
25 class IndexedDBFactory
;
26 class IndexedDBTransaction
;
27 class LevelDBDatabase
;
28 class LevelDBIteratorImpl
;
29 class LevelDBTransaction
;
31 // Use this factory to create some IndexedDB objects. Exists solely to
32 // facilitate tests which sometimes need to inject mock objects into the system.
33 class CONTENT_EXPORT IndexedDBClassFactory
{
35 typedef IndexedDBClassFactory
* GetterCallback();
37 static IndexedDBClassFactory
* Get();
39 static void SetIndexedDBClassFactoryGetter(GetterCallback
* cb
);
41 virtual IndexedDBDatabase
* CreateIndexedDBDatabase(
42 const base::string16
& name
,
43 IndexedDBBackingStore
* backing_store
,
44 IndexedDBFactory
* factory
,
45 const IndexedDBDatabase::Identifier
& unique_identifier
);
47 virtual IndexedDBTransaction
* CreateIndexedDBTransaction(
49 scoped_refptr
<IndexedDBDatabaseCallbacks
> callbacks
,
50 const std::set
<int64
>& scope
,
51 blink::WebIDBTransactionMode mode
,
52 IndexedDBDatabase
* db
,
53 IndexedDBBackingStore::Transaction
* backing_store_transaction
);
55 virtual LevelDBIteratorImpl
* CreateIteratorImpl(
56 scoped_ptr
<leveldb::Iterator
> iterator
);
57 virtual LevelDBTransaction
* CreateLevelDBTransaction(LevelDBDatabase
* db
);
60 IndexedDBClassFactory() {}
61 virtual ~IndexedDBClassFactory() {}
62 friend struct base::DefaultLazyInstanceTraits
<IndexedDBClassFactory
>;
65 } // namespace content
67 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_