Chromium Code Reviews| Index: rlz/chromeos/lib/rlz_value_store_chromeos.h |
| diff --git a/rlz/mac/lib/rlz_value_store_mac.h b/rlz/chromeos/lib/rlz_value_store_chromeos.h |
| similarity index 48% |
| copy from rlz/mac/lib/rlz_value_store_mac.h |
| copy to rlz/chromeos/lib/rlz_value_store_chromeos.h |
| index b7ffb4e820ebf07657dec1fbf9cb10e10d16a891..b1df2763c6beaaa7a4b6504814f4ba57562bb91b 100644 |
| --- a/rlz/mac/lib/rlz_value_store_mac.h |
| +++ b/rlz/chromeos/lib/rlz_value_store_chromeos.h |
| @@ -2,22 +2,36 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ |
| -#define RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ |
| +#ifndef RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |
| +#define RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |
| +#include "base/prefs/persistent_pref_store.h" |
| +#include "base/threading/non_thread_safe.h" |
| #include "rlz/lib/rlz_value_store.h" |
| -#include "base/compiler_specific.h" |
| -#include "base/memory/scoped_nsobject.h" |
| -@class NSDictionary; |
| -@class NSMutableDictionary; |
| +namespace base { |
| +class ListValue; |
| +class MessageLoopProxy; |
| +class Value; |
| +} |
| + |
| +template <typename T> struct DefaultSingletonTraits; |
| namespace rlz_lib { |
| -// An implementation of RlzValueStore for mac. It stores information in a |
| -// plist file in the user's Application Support folder. |
| -class RlzValueStoreMac : public RlzValueStore { |
| +// An implementation of RlzValueStore for ChromeOS. Unlike Mac and Win |
| +// counterparts, it's non thread-safe and should only be accessed on a single |
| +// Thread instance that has a MessageLoop. |
|
Roger Tawa OOO till Jul 10th
2012/11/06 20:55:11
Why is that a valid assumption? I don't believe i
Ivan Korotkov
2012/11/07 10:49:12
Yes, currently RlzValueStore is accessed on a bloc
|
| +class RlzValueStoreChromeOS : public RlzValueStore, |
| + public base::NonThreadSafe { |
| public: |
| + static RlzValueStoreChromeOS* GetInstance(); |
| + |
| + // Sets the MessageLoopProxy that underlying PersistentPrefStore will post I/O |
| + // tasks to. Must be called before the first GetInstance() call. |
| + static void SetIOTaskRunner(base::MessageLoopProxy* io_task_runner); |
| + |
| + // RlzValueStore overrides: |
| virtual bool HasAccess(AccessType type) OVERRIDE; |
| virtual bool WritePingTime(Product product, int64 time) OVERRIDE; |
| @@ -47,34 +61,27 @@ class RlzValueStoreMac : public RlzValueStore { |
| virtual void CollectGarbage() OVERRIDE; |
| private: |
| - // |dict| is the dictionary that backs all data. plist_path is the name of the |
| - // plist file, used solely for implementing HasAccess(). |
| - RlzValueStoreMac(NSMutableDictionary* dict, NSString* plist_path); |
| - virtual ~RlzValueStoreMac(); |
| - friend class ScopedRlzValueStoreLock; |
| - |
| - // Returns the backing dictionary that should be written to disk. |
| - NSDictionary* dictionary(); |
| - |
| - // Returns the dictionary to which all data should be written. Usually, this |
| - // is just |dictionary()|, but if supplementary branding is used, it's a |
| - // subdirectory at key "brand_<supplementary branding code>". |
| - // Note that windows stores data at |
| - // rlz/name (e.g. "pingtime")/supplementalbranding/productcode |
| - // Mac on the other hand does |
| - // supplementalbranding/productcode/pingtime. |
| - NSMutableDictionary* WorkingDict(); |
| - |
| - // Returns the subdirectory of |WorkingDict()| used to store data for |
| - // product p. |
| - NSMutableDictionary* ProductDict(Product p); |
| - |
| - scoped_nsobject<NSMutableDictionary> dict_; |
| - scoped_nsobject<NSString> plist_path_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(RlzValueStoreMac); |
| + friend struct DefaultSingletonTraits<RlzValueStoreChromeOS>; |
| + |
| + // Used by JsonPrefStore to schedule write operations. |
| + static base::MessageLoopProxy* io_task_runner_; |
| + |
| + RlzValueStoreChromeOS(); |
| + virtual ~RlzValueStoreChromeOS(); |
| + |
| + // Retrieves list at path |list_name| from JSON store. |
| + base::ListValue* GetList(std::string list_name); |
| + // Adds |value| to list at |list_name| path in JSON store. |
| + bool AddValueToList(std::string list_name, base::Value* value); |
| + // Removes |value| from list at |list_name| path in JSON store. |
| + bool RemoveValueFromList(std::string list_name, const base::Value& value); |
| + |
| + // Store with RLZ data. |
| + scoped_refptr<PersistentPrefStore> rlz_store_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RlzValueStoreChromeOS); |
| }; |
| } // namespace rlz_lib |
| -#endif // RLZ_MAC_LIB_RLZ_VALUE_STORE_MAC_H_ |
| +#endif // RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |