Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_class_factory.cc
blobcb77cca5a6e5cf727e66ba1e36feab2e3e8ec07c
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"
10 namespace content {
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() {
21 if (s_factory_getter)
22 return (*s_factory_getter)();
23 else
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(
36 int64 id,
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