OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ | 5 #ifndef RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |
6 #define RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ | 6 #define RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |
7 | 7 |
8 #include "base/prefs/persistent_pref_store.h" | 8 #include "base/prefs/persistent_pref_store.h" |
9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
10 #include "rlz/lib/rlz_value_store.h" | 10 #include "rlz/lib/rlz_value_store.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class ListValue; | 13 class ListValue; |
14 class SequencedTaskRunner; | 14 class SequencedTaskRunner; |
15 class Value; | 15 class Value; |
16 } | 16 } |
17 | 17 |
18 template <typename T> struct DefaultSingletonTraits; | 18 template <typename T> struct DefaultSingletonTraits; |
19 | 19 |
20 namespace rlz_lib { | 20 namespace rlz_lib { |
21 | 21 |
22 // An implementation of RlzValueStore for ChromeOS. Unlike Mac and Win | 22 // An implementation of RlzValueStore for ChromeOS. Unlike Mac and Win |
23 // counterparts, it's non thread-safe and should only be accessed on a single | 23 // counterparts, it's non thread-safe and should only be accessed on a single |
24 // Thread instance that has a MessageLoop. | 24 // Thread instance that has a MessageLoop. |
25 class RlzValueStoreChromeOS : public RlzValueStore, | 25 class RlzValueStoreChromeOS : public RlzValueStore { |
26 public base::NonThreadSafe { | |
27 public: | 26 public: |
28 static RlzValueStoreChromeOS* GetInstance(); | 27 static RlzValueStoreChromeOS* GetInstance(); |
29 | 28 |
30 // Sets the MessageLoopProxy that underlying PersistentPrefStore will post I/O | 29 // Sets the MessageLoopProxy that underlying PersistentPrefStore will post I/O |
31 // tasks to. Must be called before the first GetInstance() call. | 30 // tasks to. Must be called before the first GetInstance() call. |
32 static void SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner); | 31 static void SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner); |
33 | 32 |
| 33 // Must be invoked during shutdown to commit pending I/O. |
| 34 static void Cleanup(); |
| 35 |
34 // Resets the store to its initial state. Should only be used for testing. | 36 // Resets the store to its initial state. Should only be used for testing. |
35 // Same restrictions as for calling GetInstance() for the first time apply, | 37 // Same restrictions as for calling GetInstance() for the first time apply, |
36 // i.e. must call SetIOTaskRunner first. | 38 // i.e. must call SetIOTaskRunner first. |
37 static void ResetForTesting(); | 39 static void ResetForTesting(); |
38 | 40 |
39 // RlzValueStore overrides: | 41 // RlzValueStore overrides: |
40 virtual bool HasAccess(AccessType type) OVERRIDE; | 42 virtual bool HasAccess(AccessType type) OVERRIDE; |
41 | 43 |
42 virtual bool WritePingTime(Product product, int64 time) OVERRIDE; | 44 virtual bool WritePingTime(Product product, int64 time) OVERRIDE; |
43 virtual bool ReadPingTime(Product product, int64* time) OVERRIDE; | 45 virtual bool ReadPingTime(Product product, int64* time) OVERRIDE; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 90 |
89 // Store with RLZ data. | 91 // Store with RLZ data. |
90 scoped_refptr<PersistentPrefStore> rlz_store_; | 92 scoped_refptr<PersistentPrefStore> rlz_store_; |
91 | 93 |
92 DISALLOW_COPY_AND_ASSIGN(RlzValueStoreChromeOS); | 94 DISALLOW_COPY_AND_ASSIGN(RlzValueStoreChromeOS); |
93 }; | 95 }; |
94 | 96 |
95 } // namespace rlz_lib | 97 } // namespace rlz_lib |
96 | 98 |
97 #endif // RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ | 99 #endif // RLZ_CHROMEOS_LIB_RLZ_VALUE_STORE_CHROMEOS_H_ |
OLD | NEW |