summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db/indexed_db_class_factory.h
blob: 03b03597f6755ebbd977a2a6f169f9ffc4337c1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_

#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"

namespace leveldb {
class Iterator;
}  // namespace leveldb

namespace content {

class LevelDBIteratorImpl;
class LevelDBDatabase;
class LevelDBTransaction;

// Use this factory to create some IndexedDB objects. Exists solely to
// facilitate tests which sometimes need to inject mock objects into the system.
class CONTENT_EXPORT IndexedDBClassFactory {
 public:
  typedef IndexedDBClassFactory* GetterCallback();

  static IndexedDBClassFactory* Get();

  static void SetIndexedDBClassFactoryGetter(GetterCallback* cb);

  virtual LevelDBIteratorImpl* CreateIteratorImpl(
      scoped_ptr<leveldb::Iterator> iterator);
  virtual LevelDBTransaction* CreateLevelDBTransaction(LevelDBDatabase* db);

 protected:
  IndexedDBClassFactory() {}
  virtual ~IndexedDBClassFactory() {}
  friend struct base::DefaultLazyInstanceTraits<IndexedDBClassFactory>;
};

}  // namespace content

#endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CLASS_FACTORY_H_