Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/sync/invalidations/invalidator_storage.h

Issue 10451058: sync: move invalidation version prefs out of SyncPrefs into InvalidatorStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers
6 // to use PrefService as persistence for invalidation state. It is not thread
7 // safe, and lives on the UI thread.
8
9 #ifndef CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_
10 #define CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_
11
12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "sync/notifier/invalidation_state_tracker.h"
17 #include "sync/syncable/model_type.h"
18
19 class PrefService;
20
21 namespace base {
22 class DictionaryValue;
23 }
24
25 namespace browser_sync {
26
27 // TODO(tim): Bug 124137. We may want to move this outside of sync/ into a
28 // browser/invalidations directory, or re-organize to have a browser
29 // subdirectory that contains signin/ sync/ invalidations/ and other cloud
30 // services. For now this is still tied to sync while we refactor, so minimize
31 // churn and keep it here.
32 class InvalidatorStorage : public base::SupportsWeakPtr<InvalidatorStorage>,
33 public sync_notifier::InvalidationStateTracker {
34 public:
35 // |pref_service| may be NULL (for unit tests), but in that case no setter
36 // methods should be called. Does not own |pref_service|.
37 explicit InvalidatorStorage(PrefService* pref_service);
38 virtual ~InvalidatorStorage();
39
40 // Erases invalidation versions and state stored on disk.
41 void Clear();
42
43 // InvalidationStateTracker implementation.
44 virtual sync_notifier::InvalidationVersionMap GetAllMaxVersions() const
45 OVERRIDE;
46 virtual void SetMaxVersion(syncable::ModelType model_type,
47 int64 max_version) OVERRIDE;
48 // TODO(tim): These are not yet used. Bug 124140.
49 virtual void SetInvalidationState(const std::string& state) OVERRIDE;
50 virtual std::string GetInvalidationState() const OVERRIDE;
51
52 private:
53 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap);
54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeOutOfRange);
55 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeInvalidFormat);
56 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeEmptyDictionary);
57 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeBasic);
58
59 base::NonThreadSafe non_thread_safe_;
60
61 // Helpers to convert between InvalidationVersionMap <--> DictionaryValue.
62 static void DeserializeMap(const base::DictionaryValue* max_versions_dict,
63 sync_notifier::InvalidationVersionMap* map);
64 static void SerializeMap(const sync_notifier::InvalidationVersionMap& map,
65 base::DictionaryValue* to_dict);
66
67 // May be NULL.
68 PrefService* const pref_service_;
69
70 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage);
71 };
72
73 } // namespace browser_sync
74
75 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_unittest.cc ('k') | chrome/browser/sync/invalidations/invalidator_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698