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

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: Fix autofill 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"
tim (not reviewing) 2011/04/07 22:04:25 i know it's a bit late now but.. maybe in a follow
Nicolas Zea 2011/04/08 16:53:42 My logic with this was to follow the whole "fronte
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(
34 ProfileSyncFactory* profile_sync_factory, 29 ProfileSyncFactory* profile_sync_factory,
35 Profile* profile, 30 Profile* profile,
36 ProfileSyncService* sync_service); 31 ProfileSyncService* sync_service);
37 virtual ~AutofillDataTypeController(); 32 virtual ~AutofillDataTypeController();
38 33
39 // DataTypeController implementation 34 // 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; 35 virtual syncable::ModelType type() const;
47
48 virtual browser_sync::ModelSafeGroup model_safe_group() const; 36 virtual browser_sync::ModelSafeGroup model_safe_group() const;
49 37
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. 38 // NotificationObserver implementation.
59 virtual void Observe(NotificationType type, 39 virtual void Observe(NotificationType type,
60 const NotificationSource& source, 40 const NotificationSource& source,
61 const NotificationDetails& details); 41 const NotificationDetails& details);
62 42
63 // PersonalDataManager::Observer implementation: 43 // PersonalDataManager::Observer implementation:
64 virtual void OnPersonalDataLoaded(); 44 virtual void OnPersonalDataLoaded();
65 45
66 protected: 46 protected:
67 virtual ProfileSyncFactory::SyncComponents CreateSyncComponents( 47 // NonFrontendDataTypeController interface.
68 ProfileSyncService* profile_sync_service, 48 virtual bool StartModels();
69 WebDatabase* web_database, 49 virtual bool KickOffAssociation();
70 PersonalDataManager* personal_data, 50 virtual void CreateSyncComponents();
71 browser_sync::UnrecoverableErrorHandler* error_handler); 51 virtual void CleanUpState();
72 ProfileSyncFactory* profile_sync_factory_; 52 virtual bool KickOffDestroy();
73 53 virtual void RecordUnrecoverableError(
74 private: 54 const tracked_objects::Location& from_here,
75 void StartImpl(); 55 const std::string& message);
76 void StartDone(StartResult result, State state); 56 virtual void RecordAssociationTime(base::TimeDelta time);
77 void StartDoneImpl(StartResult result, State state, 57 virtual void RecordStartFailure(StartResult result);
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 58
97 PersonalDataManager* personal_data_; 59 PersonalDataManager* personal_data_;
98 scoped_refptr<WebDataService> web_data_service_; 60 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_; 61 NotificationRegistrar notification_registrar_;
104 62
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); 63 DISALLOW_COPY_AND_ASSIGN(AutofillDataTypeController);
114 }; 64 };
115 65
116 } // namespace browser_sync 66 } // namespace browser_sync
117 67
118 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__ 68 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_DATA_TYPE_CONTROLLER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698