Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / rlz / mac / lib / rlz_value_store_mac.h
blob1cf9699d63a0c86aba72dacf7ce1aa2aecd841b9
1 // Copyright (c) 2012 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.
5 #ifndef RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_
6 #define RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_
8 #include "base/compiler_specific.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "rlz/lib/rlz_value_store.h"
12 @class NSDictionary;
13 @class NSMutableDictionary;
15 namespace rlz_lib {
17 // An implementation of RlzValueStore for mac. It stores information in a
18 // plist file in the user's Application Support folder.
19 class RlzValueStoreMac : public RlzValueStore {
20 public:
21 bool HasAccess(AccessType type) override;
23 bool WritePingTime(Product product, int64 time) override;
24 bool ReadPingTime(Product product, int64* time) override;
25 bool ClearPingTime(Product product) override;
27 bool WriteAccessPointRlz(AccessPoint access_point,
28 const char* new_rlz) override;
29 bool ReadAccessPointRlz(AccessPoint access_point,
30 char* rlz,
31 size_t rlz_size) override;
32 bool ClearAccessPointRlz(AccessPoint access_point) override;
34 bool AddProductEvent(Product product, const char* event_rlz) override;
35 bool ReadProductEvents(Product product,
36 std::vector<std::string>* events) override;
37 bool ClearProductEvent(Product product, const char* event_rlz) override;
38 bool ClearAllProductEvents(Product product) override;
40 bool AddStatefulEvent(Product product, const char* event_rlz) override;
41 bool IsStatefulEvent(Product product, const char* event_rlz) override;
42 bool ClearAllStatefulEvents(Product product) override;
44 void CollectGarbage() override;
46 private:
47 // |dict| is the dictionary that backs all data. plist_path is the name of the
48 // plist file, used solely for implementing HasAccess().
49 RlzValueStoreMac(NSMutableDictionary* dict, NSString* plist_path);
50 ~RlzValueStoreMac() override;
51 friend class ScopedRlzValueStoreLock;
53 // Returns the backing dictionary that should be written to disk.
54 NSDictionary* dictionary();
56 // Returns the dictionary to which all data should be written. Usually, this
57 // is just |dictionary()|, but if supplementary branding is used, it's a
58 // subdirectory at key "brand_<supplementary branding code>".
59 // Note that windows stores data at
60 // rlz/name (e.g. "pingtime")/supplementalbranding/productcode
61 // Mac on the other hand does
62 // supplementalbranding/productcode/pingtime.
63 NSMutableDictionary* WorkingDict();
65 // Returns the subdirectory of |WorkingDict()| used to store data for
66 // product p.
67 NSMutableDictionary* ProductDict(Product p);
69 base::scoped_nsobject<NSMutableDictionary> dict_;
70 base::scoped_nsobject<NSString> plist_path_;
72 DISALLOW_COPY_AND_ASSIGN(RlzValueStoreMac);
75 } // namespace rlz_lib
77 #endif // RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_