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"
13 @
class NSMutableDictionary
;
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
{
21 virtual bool HasAccess(AccessType type
) OVERRIDE
;
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
;
27 virtual bool WriteAccessPointRlz(AccessPoint access_point
,
28 const char* new_rlz
) OVERRIDE
;
29 virtual bool ReadAccessPointRlz(AccessPoint access_point
,
31 size_t rlz_size
) OVERRIDE
;
32 virtual bool ClearAccessPointRlz(AccessPoint access_point
) OVERRIDE
;
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
;
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
;
47 virtual void CollectGarbage() OVERRIDE
;
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
;
56 // Returns the backing dictionary that should be written to disk.
57 NSDictionary
* dictionary();
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();
68 // Returns the subdirectory of |WorkingDict()| used to store data for
70 NSMutableDictionary
* ProductDict(Product p
);
72 base::scoped_nsobject
<NSMutableDictionary
> dict_
;
73 base::scoped_nsobject
<NSString
> plist_path_
;
75 DISALLOW_COPY_AND_ASSIGN(RlzValueStoreMac
);
78 } // namespace rlz_lib
80 #endif // RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_