Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / indexed_db / indexed_db_class_factory.h
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 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_
7
8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h"
11
12 namespace leveldb {
13 class Iterator;
14 }  // namespace leveldb
15
16 namespace content {
17
18 class LevelDBIteratorImpl;
19 class LevelDBDatabase;
20 class LevelDBTransaction;
21
22 // Use this factory to create some IndexedDB objects. Exists solely to
23 // facilitate tests which sometimes need to inject mock objects into the system.
24 class CONTENT_EXPORT IndexedDBClassFactory {
25  public:
26   typedef IndexedDBClassFactory* GetterCallback();
27
28   static IndexedDBClassFactory* Get();
29
30   static void SetIndexedDBClassFactoryGetter(GetterCallback* cb);
31
32   virtual LevelDBIteratorImpl* CreateIteratorImpl(
33       scoped_ptr<leveldb::Iterator> iterator);
34   virtual LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db);
35
36  protected:
37   IndexedDBClassFactory() {}
38   virtual ~IndexedDBClassFactory() {}
39   friend struct base::DefaultLazyInstanceTraits<IndexedDBClassFactory>;
40 };
41
42 }  // namespace content
43
44 #endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_