1 // Copyright 2014 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 COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_STORAGE_H_
6 #define COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_STORAGE_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/threading/thread_checker.h"
11 #include "components/invalidation/impl/invalidation_state_tracker.h"
13 class PrefRegistrySimple
;
16 namespace user_prefs
{
17 class PrefRegistrySyncable
;
20 namespace invalidation
{
22 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers
23 // to use PrefService as persistence for invalidation state. It is not thread
24 // safe, and lives on the UI thread.
25 class InvalidatorStorage
: public syncer::InvalidationStateTracker
{
27 // |pref_service| may not be NULL and must outlive |this|.
28 explicit InvalidatorStorage(PrefService
* pref_service
);
29 ~InvalidatorStorage() override
;
31 // Register prefs to be used by per-Profile instances of this class which
32 // store invalidation state in Profile prefs.
33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
35 // Register prefs to be used by a device-global instance of this class which
36 // stores invalidation state in local state. This is used on Chrome OS only.
37 static void RegisterPrefs(PrefRegistrySimple
* registry
);
39 // InvalidationStateTracker implementation.
40 void ClearAndSetNewClientId(const std::string
& client_id
) override
;
41 std::string
GetInvalidatorClientId() const override
;
42 void SetBootstrapData(const std::string
& data
) override
;
43 std::string
GetBootstrapData() const override
;
44 void SetSavedInvalidations(
45 const syncer::UnackedInvalidationsMap
& map
) override
;
46 syncer::UnackedInvalidationsMap
GetSavedInvalidations() const override
;
47 void Clear() override
;
50 base::ThreadChecker thread_checker_
;
52 PrefService
* const pref_service_
;
54 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage
);
57 } // namespace invalidation
59 #endif // COMPONENTS_INVALIDATION_IMPL_INVALIDATOR_STORAGE_H_