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_INVALIDATOR_STORAGE_H_
6 #define COMPONENTS_INVALIDATION_INVALIDATOR_STORAGE_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/threading/thread_checker.h"
11 #include "sync/notifier/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 virtual ~InvalidatorStorage();
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 virtual void ClearAndSetNewClientId(const std::string
& client_id
) OVERRIDE
;
41 virtual std::string
GetInvalidatorClientId() const OVERRIDE
;
42 virtual void SetBootstrapData(const std::string
& data
) OVERRIDE
;
43 virtual std::string
GetBootstrapData() const OVERRIDE
;
44 virtual void SetSavedInvalidations(
45 const syncer::UnackedInvalidationsMap
& map
) OVERRIDE
;
46 virtual syncer::UnackedInvalidationsMap
GetSavedInvalidations()
48 virtual void Clear() OVERRIDE
;
51 base::ThreadChecker thread_checker_
;
53 PrefService
* const pref_service_
;
55 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage
);
58 } // namespace invalidation
60 #endif // COMPONENTS_INVALIDATION_INVALIDATOR_STORAGE_H_