Home | History | Annotate | Download | only in indexed_db
      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.
      4 
      5 #include "content/browser/indexed_db/indexed_db_class_factory.h"
      6 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h"
      7 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
      8 
      9 namespace content {
     10 
     11 static IndexedDBClassFactory::GetterCallback* s_factory_getter;
     12 static ::base::LazyInstance<IndexedDBClassFactory>::Leaky s_factory =
     13     LAZY_INSTANCE_INITIALIZER;
     14 
     15 void IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetterCallback* cb) {
     16   s_factory_getter = cb;
     17 }
     18 
     19 IndexedDBClassFactory* IndexedDBClassFactory::Get() {
     20   if (s_factory_getter)
     21     return (*s_factory_getter)();
     22   else
     23     return s_factory.Pointer();
     24 }
     25 
     26 LevelDBTransaction* IndexedDBClassFactory::CreateLevelDBTransaction(
     27     LevelDBDatabase* db) {
     28   return new LevelDBTransaction(db);
     29 }
     30 
     31 content::LevelDBIteratorImpl* IndexedDBClassFactory::CreateIteratorImpl(
     32     scoped_ptr<leveldb::Iterator> iterator) {
     33   return new LevelDBIteratorImpl(iterator.Pass());
     34 }
     35 
     36 }  // namespace content
     37