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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
// Copyright (c) 2010 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_AUTOFILL_DATA_TYPE_CONTROLLER_H__
#define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
#pragma once
#include <string>
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/sync/profile_sync_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
class Profile;
class ProfileSyncFactory;
class ProfileSyncService;
namespace browser_sync {
class AssociatorInterface;
class ChangeProcessor;
// A class that manages the startup and shutdown of autofill sync.
class AutofillDataTypeController : public DataTypeController,
public NotificationObserver,
public PersonalDataManager::Observer {
public:
AutofillDataTypeController(
ProfileSyncFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service);
virtual ~AutofillDataTypeController();
// DataTypeController implementation
virtual void Start(StartCallback* start_callback);
virtual void Stop();
virtual bool enabled();
virtual syncable::ModelType type();
virtual browser_sync::ModelSafeGroup model_safe_group();
virtual const char* name() const;
virtual State state();
// UnrecoverableHandler implementation
virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
const std::string& message);
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
// PersonalDataManager::Observer implementation:
virtual void OnPersonalDataLoaded();
protected:
virtual ProfileSyncFactory::SyncComponents CreateSyncComponents(
ProfileSyncService* profile_sync_service,
WebDatabase* web_database,
PersonalDataManager* personal_data,
browser_sync::UnrecoverableErrorHandler* error_handler);
ProfileSyncFactory* profile_sync_factory_;
private:
void StartImpl();
void StartDone(StartResult result, State state);
void StartDoneImpl(StartResult result, State state);
void StopImpl();
void StartFailed(StartResult result);
void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
const std::string& message);
// Second-half of "Start" implementation, called once personal data has
// loaded.
void ContinueStartAfterPersonalDataLoaded();
void set_state(State state) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
state_ = state;
}
Profile* profile_;
ProfileSyncService* sync_service_;
State state_;
PersonalDataManager* personal_data_;
scoped_refptr<WebDataService> web_data_service_;
scoped_ptr<AssociatorInterface> model_associator_;
scoped_ptr<ChangeProcessor> change_processor_;
scoped_ptr<StartCallback> start_callback_;
NotificationRegistrar notification_registrar_;
Lock abort_association_lock_;
bool abort_association_;
base::WaitableEvent abort_association_complete_;
// Barrier to ensure that the datatype has been stopped on the DB thread
// from the UI thread.
base::WaitableEvent datatype_stopped_;
DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
};
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
|