Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / invalidation / invalidator_storage.h
blob75c3f907259782dc87a479c58dcabf39cfbcd693
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.
9 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_
10 #define CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_
12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h"
16 #include "sync/notifier/invalidation_state_tracker.h"
17 #include "sync/notifier/unacked_invalidation_set.h"
19 class PrefService;
21 namespace base {
22 class DictionaryValue;
23 class ListValue;
26 namespace user_prefs {
27 class PrefRegistrySyncable;
30 namespace invalidation {
32 class InvalidatorStorage : public base::SupportsWeakPtr<InvalidatorStorage>,
33 public syncer::InvalidationStateTracker {
34 public:
35 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
37 // |pref_service| may not be NULL. Does not own |pref_service|.
38 explicit InvalidatorStorage(PrefService* pref_service);
39 virtual ~InvalidatorStorage();
41 // InvalidationStateTracker implementation.
42 virtual void SetInvalidatorClientId(const std::string& client_id) OVERRIDE;
43 virtual std::string GetInvalidatorClientId() const OVERRIDE;
44 virtual void SetBootstrapData(const std::string& data) OVERRIDE;
45 virtual std::string GetBootstrapData() const OVERRIDE;
46 virtual void SetSavedInvalidations(
47 const syncer::UnackedInvalidationsMap& map) OVERRIDE;
48 virtual syncer::UnackedInvalidationsMap GetSavedInvalidations()
49 const OVERRIDE;
50 virtual void Clear() OVERRIDE;
52 private:
53 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap);
54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
55 DeserializeFromListOutOfRange);
56 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
57 DeserializeFromListInvalidFormat);
58 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
59 DeserializeFromListWithDuplicates);
60 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
61 DeserializeFromEmptyList);
62 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic);
63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
64 DeserializeFromListMissingOptionalValues);
65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange);
66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat);
67 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
68 DeserializeMapEmptyDictionary);
69 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic);
70 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences);
72 base::ThreadChecker thread_checker_;
74 PrefService* const pref_service_;
76 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage);
79 } // namespace invalidation
81 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_