blob: 4820b33fe717bcaddd6a261f0ed3bd71c0b16021 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_GLUE_PREFERENCE_CHANGE_PROCESSOR_H_
#define CHROME_BROWSER_SYNC_GLUE_PREFERENCE_CHANGE_PROCESSOR_H_
#include "base/scoped_ptr.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/common/notification_observer.h"
namespace browser_sync {
class PreferenceModelAssociator;
class UnrecoverableErrorHandler;
// This class is responsible for taking changes from the PrefService and
// applying them to the sync_api 'syncable' model, and vice versa. All
// operations and use of this class are from the UI thread.
class PreferenceChangeProcessor : public ChangeProcessor,
public NotificationObserver {
public:
PreferenceChangeProcessor(PreferenceModelAssociator* model_associator,
UnrecoverableErrorHandler* error_handler);
virtual ~PreferenceChangeProcessor();
// NotificationObserver implementation.
// PrefService -> sync_api model change application.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
// sync_api model -> PrefService change application.
virtual void ApplyChangesFromSyncModel(
const sync_api::BaseTransaction* trans,
const sync_api::SyncManager::ChangeRecord* changes,
int change_count);
protected:
virtual void StartImpl(Profile* profile);
virtual void StopImpl();
private:
bool WritePreference(sync_api::WriteNode* node,
const std::wstring& name,
const Value* value);
Value* ReadPreference(sync_api::ReadNode* node, std::wstring* name);
void StartObserving();
void StopObserving();
// The model we are processing changes from. Non-NULL when |running_| is true.
PrefService* pref_service_;
// The two models should be associated according to this ModelAssociator.
PreferenceModelAssociator* model_associator_;
DISALLOW_COPY_AND_ASSIGN(PreferenceChangeProcessor);
};
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_GLUE_PREFERENCE_CHANGE_PROCESSOR_H_
|