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 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 5 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
6 #include "content/browser/indexed_db/indexed_db_transaction.h" | 6 #include "content/browser/indexed_db/indexed_db_transaction.h" |
7 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" | 7 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" |
8 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 8 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 static IndexedDBClassFactory::GetterCallback* s_factory_getter; | 12 static IndexedDBClassFactory::GetterCallback* s_factory_getter; |
13 static ::base::LazyInstance<IndexedDBClassFactory>::Leaky s_factory = | 13 static ::base::LazyInstance<IndexedDBClassFactory>::Leaky s_factory = |
14 LAZY_INSTANCE_INITIALIZER; | 14 LAZY_INSTANCE_INITIALIZER; |
15 | 15 |
16 void IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetterCallback* cb) { | 16 void IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetterCallback* cb) { |
17 s_factory_getter = cb; | 17 s_factory_getter = cb; |
18 } | 18 } |
19 | 19 |
20 IndexedDBClassFactory* IndexedDBClassFactory::Get() { | 20 IndexedDBClassFactory* IndexedDBClassFactory::Get() { |
21 if (s_factory_getter) | 21 if (s_factory_getter) |
22 return (*s_factory_getter)(); | 22 return (*s_factory_getter)(); |
23 else | 23 else |
24 return s_factory.Pointer(); | 24 return s_factory.Pointer(); |
25 } | 25 } |
26 | 26 |
| 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); |
| 33 } |
| 34 |
27 IndexedDBTransaction* IndexedDBClassFactory::CreateIndexedDBTransaction( | 35 IndexedDBTransaction* IndexedDBClassFactory::CreateIndexedDBTransaction( |
28 int64 id, | 36 int64 id, |
29 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, | 37 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, |
30 const std::set<int64>& scope, | 38 const std::set<int64>& scope, |
31 blink::WebIDBTransactionMode mode, | 39 blink::WebIDBTransactionMode mode, |
32 IndexedDBDatabase* db, | 40 IndexedDBDatabase* db, |
33 IndexedDBBackingStore::Transaction* backing_store_transaction) { | 41 IndexedDBBackingStore::Transaction* backing_store_transaction) { |
34 return new IndexedDBTransaction(id, callbacks, scope, mode, db, | 42 return new IndexedDBTransaction(id, callbacks, scope, mode, db, |
35 backing_store_transaction); | 43 backing_store_transaction); |
36 } | 44 } |
37 | 45 |
38 LevelDBTransaction* IndexedDBClassFactory::CreateLevelDBTransaction( | 46 LevelDBTransaction* IndexedDBClassFactory::CreateLevelDBTransaction( |
39 LevelDBDatabase* db) { | 47 LevelDBDatabase* db) { |
40 return new LevelDBTransaction(db); | 48 return new LevelDBTransaction(db); |
41 } | 49 } |
42 | 50 |
43 content::LevelDBIteratorImpl* IndexedDBClassFactory::CreateIteratorImpl( | 51 content::LevelDBIteratorImpl* IndexedDBClassFactory::CreateIteratorImpl( |
44 scoped_ptr<leveldb::Iterator> iterator) { | 52 scoped_ptr<leveldb::Iterator> iterator) { |
45 return new LevelDBIteratorImpl(iterator.Pass()); | 53 return new LevelDBIteratorImpl(iterator.Pass()); |
46 } | 54 } |
47 | 55 |
48 } // namespace content | 56 } // namespace content |
OLD | NEW |