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 #include "content/browser/indexed_db/indexed_db_class_factory.h"
6 #include "content/browser/indexed_db/indexed_db_transaction.h"
7 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h"
8 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
12 static IndexedDBClassFactory::GetterCallback
* s_factory_getter
;
13 static ::base::LazyInstance
<IndexedDBClassFactory
>::Leaky s_factory
=
14 LAZY_INSTANCE_INITIALIZER
;
16 void IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetterCallback
* cb
) {
17 s_factory_getter
= cb
;
20 IndexedDBClassFactory
* IndexedDBClassFactory::Get() {
22 return (*s_factory_getter
)();
24 return s_factory
.Pointer();
27 IndexedDBDatabase
* IndexedDBClassFactory::CreateIndexedDBDatabase(
28 const base::string16
& name
,
29 IndexedDBBackingStore
* backing_store
,
30 IndexedDBFactory
* factory
,
31 const IndexedDBDatabase::Identifier
& unique_identifier
) {
32 return new IndexedDBDatabase(name
, backing_store
, factory
, unique_identifier
);
35 IndexedDBTransaction
* IndexedDBClassFactory::CreateIndexedDBTransaction(
37 scoped_refptr
<IndexedDBDatabaseCallbacks
> callbacks
,
38 const std::set
<int64
>& scope
,
39 blink::WebIDBTransactionMode mode
,
40 IndexedDBDatabase
* db
,
41 IndexedDBBackingStore::Transaction
* backing_store_transaction
) {
42 return new IndexedDBTransaction(id
, callbacks
, scope
, mode
, db
,
43 backing_store_transaction
);
46 LevelDBTransaction
* IndexedDBClassFactory::CreateLevelDBTransaction(
47 LevelDBDatabase
* db
) {
48 return new LevelDBTransaction(db
);
51 content::LevelDBIteratorImpl
* IndexedDBClassFactory::CreateIteratorImpl(
52 scoped_ptr
<leveldb::Iterator
> iterator
) {
53 return new LevelDBIteratorImpl(iterator
.Pass());
56 } // namespace content