summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs/tracked/hash_store_contents.h
blob: e07104b7050eb0492b6c111bdef68f6683138204 (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
// 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 CHROME_BROWSER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_
#define CHROME_BROWSER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_

#include <string>

#include "base/memory/scoped_ptr.h"

namespace base {
class DictionaryValue;
} // namespace base

// Provides access to the contents of a preference hash store.
class HashStoreContents {
 public:
  // Used to modify a DictionaryValue stored in the preference hash store. The
  // MutableDictionary should be destroyed when modifications are complete in
  // order to allow them to be committed to the underlying storage.
  class MutableDictionary {
   public:
    virtual ~MutableDictionary() {}
    // Returns the DictionaryValue, which will be created if it does not already
    // exist.
    virtual base::DictionaryValue* operator->() = 0;
  };

  virtual ~HashStoreContents() {}

  // Returns the hash-store ID. May be empty.
  virtual std::string hash_store_id() const = 0;

  // Discards all data related to this hash store.
  virtual void Reset() = 0;

  // Indicates whether any data is currently stored for this hash store.
  virtual bool IsInitialized() const = 0;

  // Retrieves a version number previously associated with this hash store via
  // SetVersion. Returns false if no version number has been stored.
  virtual bool GetVersion(int* version) const = 0;

  // Associates a version number wih this hash store.
  virtual void SetVersion(int version) = 0;

  // Retrieves the contents of this hash store. May return NULL if the hash
  // store has not been initialized.
  virtual const base::DictionaryValue* GetContents() const = 0;

  // Provides mutable access to the contents of this hash store.
  virtual scoped_ptr<MutableDictionary> GetMutableContents() = 0;

  // Retrieves the super MAC value previously stored by SetSuperMac. May be
  // empty if no super MAC has been stored.
  virtual std::string GetSuperMac() const = 0;

  // Stores a super MAC value for this hash store.
  virtual void SetSuperMac(const std::string& super_mac) = 0;
};

#endif  // CHROME_BROWSER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_