OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ | |
6 #define RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ | |
7 | |
8 #include "rlz/lib/rlz_value_store.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_nsobject.h" | |
11 | |
12 @class NSDictionary; | |
13 @class NSMutableDictionary; | |
14 | |
15 namespace rlz_lib { | |
16 | |
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 virtual bool HasAccess(AccessType type) OVERRIDE; | |
22 | |
23 virtual bool WritePingTime(Product product, int64 time) OVERRIDE; | |
24 virtual bool ReadPingTime(Product product, int64* time) OVERRIDE; | |
25 virtual bool ClearPingTime(Product product) OVERRIDE; | |
26 | |
27 virtual bool WriteAccessPointRlz(AccessPoint access_point, | |
28 const char* new_rlz) OVERRIDE; | |
29 virtual bool ReadAccessPointRlz(AccessPoint access_point, | |
30 char* rlz, | |
31 size_t rlz_size) OVERRIDE; | |
32 virtual bool ClearAccessPointRlz(AccessPoint access_point) OVERRIDE; | |
33 | |
34 virtual bool AddProductEvent(Product product, const char* event_rlz) OVERRIDE; | |
35 virtual bool ReadProductEvents(Product product, | |
36 std::vector<std::string>* events) OVERRIDE; | |
37 virtual bool ClearProductEvent(Product product, | |
38 const char* event_rlz) OVERRIDE; | |
39 virtual bool ClearAllProductEvents(Product product) OVERRIDE; | |
40 | |
41 virtual bool AddStatefulEvent(Product product, | |
42 const char* event_rlz) OVERRIDE; | |
43 virtual bool IsStatefulEvent(Product product, | |
44 const char* event_rlz) OVERRIDE; | |
45 virtual bool ClearAllStatefulEvents(Product product) OVERRIDE; | |
46 | |
47 virtual void CollectGarbage() OVERRIDE; | |
48 | |
49 private: | |
50 // |dict| is the dictionary that backs all data. plist_path is the name of the | |
51 // plist file, used solely for implementing HasAccess(). | |
52 RlzValueStoreMac(NSMutableDictionary* dict, NSString* plist_path); | |
53 virtual ~RlzValueStoreMac(); | |
54 friend class ScopedRlzValueStoreLock; | |
55 | |
56 // Returns the backing dictionary that should be written to disk. | |
57 NSDictionary* dictionary(); | |
58 | |
59 // Returns the dictionary to which all data should be written. Usually, this | |
60 // is just |dictionary()|, but if supplementary branding is used, it's a | |
61 // subdirectory at key "brand_<supplementary branding code>". | |
62 // Note that windows stores data at | |
63 // rlz/name (e.g. "pingtime")/supplementalbranding/productcode | |
64 // Mac on the other hand does | |
65 // supplementalbranding/productcode/pingtime. | |
66 NSMutableDictionary* WorkingDict(); | |
67 | |
68 // Returns the subdirectory of |WorkingDict()| used to store data for | |
69 // product p. | |
70 NSMutableDictionary* ProductDict(Product p); | |
71 | |
72 scoped_nsobject<NSMutableDictionary> dict_; | |
73 scoped_nsobject<NSString> plist_path_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(RlzValueStoreMac); | |
76 }; | |
77 | |
78 } // namespace rlz_lib | |
79 | |
80 #endif // RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ | |
OLD | NEW |