Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/sync/glue/autofill_data_type_controller.h

Issue 6811003: [Sync] Make generic non-frontend thread datatype controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copy paste :( Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__ 6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/waitable_event.h"
14 #include "chrome/browser/autofill/personal_data_manager.h" 12 #include "chrome/browser/autofill/personal_data_manager.h"
15 #include "chrome/browser/sync/profile_sync_factory.h" 13 #include "chrome/browser/sync/glue/non_frontend_data_type_controller.h"
16 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "content/common/notification_observer.h"
17 #include "chrome/browser/sync/glue/data_type_controller.h" 15 #include "content/common/notification_registrar.h"
18 16
19 class Profile; 17 class NotificationDetails;
20 class ProfileSyncFactory; 18 class NotificationType;
21 class ProfileSyncService; 19 class NotificationSource;
22 20
23 namespace browser_sync { 21 namespace browser_sync {
24 22
25 class AssociatorInterface;
26 class ChangeProcessor;
27
28 // A class that manages the startup and shutdown of autofill sync. 23 // A class that manages the startup and shutdown of autofill sync.
29 class AutofillDataTypeController : public DataTypeController, 24 class AutofillDataTypeController : public NonFrontendDataTypeController,
30 public NotificationObserver, 25 public NotificationObserver,
31 public PersonalDataManager::Observer { 26 public PersonalDataManager::Observer {
32 public: 27 public:
33 AutofillDataTypeController( 28 AutofillDataTypeController(ProfileSyncFactory* profile_sync_factory,
34 ProfileSyncFactory* profile_sync_factory, 29 Profile* profile);
35 Profile* profile,
36 ProfileSyncService* sync_service);
37 virtual ~AutofillDataTypeController(); 30 virtual ~AutofillDataTypeController();
38 31
39 // DataTypeController implementation 32 // NonFrontendDataTypeController implementation
40 virtual void Start(StartCallback* start_callback);
41
42 virtual void Stop();
43
44 virtual bool enabled();
45
46 virtual syncable::ModelType type() const; 33 virtual syncable::ModelType type() const;
47
48 virtual browser_sync::ModelSafeGroup model_safe_group() const; 34 virtual browser_sync::ModelSafeGroup model_safe_group() const;
49 35
50 virtual std::string name() const;
51
52 virtual State state() const;
53
54 // UnrecoverableHandler implementation
55 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
56 const std::string& message);
57
58 // NotificationObserver implementation. 36 // NotificationObserver implementation.
59 virtual void Observe(NotificationType type, 37 virtual void Observe(NotificationType type,
60 const NotificationSource& source, 38 const NotificationSource& source,
61 const NotificationDetails& details); 39 const NotificationDetails& details);
62 40
63 // PersonalDataManager::Observer implementation: 41 // PersonalDataManager::Observer implementation:
64 virtual void OnPersonalDataLoaded(); 42 virtual void OnPersonalDataLoaded();
65 43
66 protected: 44 protected:
67 virtual ProfileSyncFactory::SyncComponents CreateSyncComponents( 45 // NonFrontendDataTypeController interface.
68 ProfileSyncService* profile_sync_service, 46 virtual bool StartModels();
69 WebDatabase* web_database, 47 virtual bool StartAssociationAsync();
70 PersonalDataManager* personal_data, 48 virtual void CreateSyncComponents();
71 browser_sync::UnrecoverableErrorHandler* error_handler); 49 virtual void StopModels();
72 ProfileSyncFactory* profile_sync_factory_; 50 virtual bool StopAssociationAsync();
51 virtual void RecordUnrecoverableError(
52 const tracked_objects::Location& from_here,
53 const std::string& message);
54 virtual void RecordAssociationTime(base::TimeDelta time);
55 virtual void RecordStartFailure(StartResult result);
73 56
57 // Getters and setters
58 PersonalDataManager* personal_data() const;
59 WebDataService* web_data_service() const;
74 private: 60 private:
75 void StartImpl();
76 void StartDone(StartResult result, State state);
77 void StartDoneImpl(StartResult result, State state,
78 const tracked_objects::Location& location);
79 void StopImpl();
80 void StartFailed(StartResult result);
81 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
82 const std::string& message);
83
84 // Second-half of "Start" implementation, called once personal data has
85 // loaded.
86 void ContinueStartAfterPersonalDataLoaded();
87
88 void set_state(State state) {
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
90 state_ = state;
91 }
92
93 Profile* profile_;
94 ProfileSyncService* sync_service_;
95 State state_;
96
97 PersonalDataManager* personal_data_; 61 PersonalDataManager* personal_data_;
98 scoped_refptr<WebDataService> web_data_service_; 62 scoped_refptr<WebDataService> web_data_service_;
99 scoped_ptr<AssociatorInterface> model_associator_;
100 scoped_ptr<ChangeProcessor> change_processor_;
101 scoped_ptr<StartCallback> start_callback_;
102
103 NotificationRegistrar notification_registrar_; 63 NotificationRegistrar notification_registrar_;
104 64
105 base::Lock abort_association_lock_;
106 bool abort_association_;
107 base::WaitableEvent abort_association_complete_;
108
109 // Barrier to ensure that the datatype has been stopped on the DB thread
110 // from the UI thread.
111 base::WaitableEvent datatype_stopped_;
112
113 DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController); 65 DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
114 }; 66 };
115 67
116 } // namespace browser_sync 68 } // namespace browser_sync
117 69
118 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__ 70 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/sync/glue/autofill_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698