summaryrefslogtreecommitdiffstats
path: root/extensions/browser/value_store/value_store_factory.h
blob: ec43547e880298322a6c6261ed2f9841a95cef0b (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2016 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 EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_H_

#include <set>

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/storage/settings_namespace.h"
#include "extensions/common/extension.h"

class ValueStore;

namespace extensions {

// Create new value stores for rules, state, or settings. For settings will
// also create stores for the specified namespace and model type.
//
// Note: This factory creates the lower level stores that directly read/write to
//       disk. Sync/Managed stores are created directly, but delegate their
//       calls to a |ValueStore| created by this interface.
class ValueStoreFactory : public base::RefCountedThreadSafe<ValueStoreFactory> {
 public:
  enum class ModelType { APP, EXTENSION };

  // Create a |ValueStore| to contain rules data.
  virtual scoped_ptr<ValueStore> CreateRulesStore() = 0;

  // Create a |ValueStore| to contain state data.
  virtual scoped_ptr<ValueStore> CreateStateStore() = 0;

  // Create a |ValueStore| to contain settings data for a specific extension
  // namespace and model type.
  virtual scoped_ptr<ValueStore> CreateSettingsStore(
      settings_namespace::Namespace settings_namespace,
      ModelType model_type,
      const ExtensionId& extension_id) = 0;

  // Delete all settings for specified given extension in the specified
  // namespace/model_type.
  virtual void DeleteSettings(settings_namespace::Namespace settings_namespace,
                              ModelType model_type,
                              const ExtensionId& extension_id) = 0;

  // Are there any settings stored in the specified namespace/model_type for
  // the given extension?
  virtual bool HasSettings(settings_namespace::Namespace settings_namespace,
                           ModelType model_type,
                           const ExtensionId& extension_id) = 0;

  // Return all extension ID's with settings stored in the given
  // namespace/model_type.
  virtual std::set<ExtensionId> GetKnownExtensionIDs(
      settings_namespace::Namespace settings_namespace,
      ModelType model_type) const = 0;

 protected:
  friend class base::RefCountedThreadSafe<ValueStoreFactory>;
  virtual ~ValueStoreFactory() {}
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_H_