File: hash_store_contents.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (90 lines) | stat: -rw-r--r-- 3,770 bytes parent folder | download
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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 COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_
#define COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_

#include <map>
#include <memory>
#include <string>

#include "base/strings/string_piece.h"

namespace base {
class DictionaryValue;
class Value;
}  // namespace base

// Provides access to the contents of a preference hash store. The store
// contains the following data:
// Contents: a client-defined dictionary that should map preference names to
// MACs.
// Version: a client-defined version number for the format of Contents.
// Super MAC: a MAC that authenticates the entirety of Contents.
class HashStoreContents {
 public:
  virtual ~HashStoreContents() {}

  // Returns true if this implementation of HashStoreContents can be copied via
  // MakeCopy().
  virtual bool IsCopyable() const = 0;

  // Returns a copy of this HashStoreContents. Must only be called on
  // lightweight implementations (which return true from IsCopyable()) and only
  // in scenarios where a copy cannot be avoided.
  virtual std::unique_ptr<HashStoreContents> MakeCopy() const = 0;

  // Returns the suffix to be appended to UMA histograms for this store type.
  // The returned value must either be an empty string or one of the values in
  // histograms.xml's TrackedPreferencesExternalValidators.
  virtual base::StringPiece GetUMASuffix() const = 0;

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

  // Outputs the MAC validating the preference at path. Returns true if a MAC
  // was successfully read and false otherwise.
  virtual bool GetMac(const std::string& path, std::string* out_value) = 0;

  // Outputs the MACS validating the split preference at path. Returns true if
  // MACS were successfully read and false otherwise.
  virtual bool GetSplitMacs(const std::string& path,
                            std::map<std::string, std::string>* out_value) = 0;

  // Set the MAC validating the preference at path.
  virtual void SetMac(const std::string& path, const std::string& value) = 0;

  // Set the MAC validating the split preference at path and split_path.
  // For example, |path| is 'extension' and |split_path| is some extenson id.
  virtual void SetSplitMac(const std::string& path,
                           const std::string& split_path,
                           const std::string& value) = 0;

  // Sets the MAC for the preference at |path|.
  // If |path| is a split preference |in_value| must be a DictionaryValue whose
  // keys are keys in the split preference and whose values are MACs of the
  // corresponding values in the split preference.
  // If |path| is an atomic preference |in_value| must be a StringValue
  // containing a MAC of the preference value.
  virtual void ImportEntry(const std::string& path,
                           const base::Value* in_value) = 0;

  // Removes the MAC (for atomic preferences) or MACs (for split preferences)
  // at |path|. Returns true if there was an entry at |path| which was
  // successfully removed.
  virtual bool RemoveEntry(const std::string& path) = 0;

  // Only needed if this store supports super MACs.
  virtual const base::DictionaryValue* GetContents() const = 0;

  // Retrieves the super MAC value previously stored by SetSuperMac. May be
  // empty if no super MAC has been stored or if this store does not support
  // super MACs.
  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  // COMPONENTS_USER_PREFS_TRACKED_HASH_STORE_CONTENTS_H_