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

Side by Side Diff: chrome/browser/sync/glue/typed_url_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_TYPED_URL_DATA_TYPE_CONTROLLER_H__ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
6 #define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__ 6 #define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_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"
12 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/waitable_event.h" 12 #include "chrome/browser/sync/glue/non_frontend_data_type_controller.h"
14 #include "chrome/browser/sync/glue/data_type_controller.h"
15 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "content/browser/cancelable_request.h" 13 #include "content/browser/cancelable_request.h"
17 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
18 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
19 #include "content/common/notification_type.h" 16 #include "content/common/notification_type.h"
20 17
21 class NotificationSource; 18 class NotificationSource;
22 class NotificationDetails; 19 class NotificationDetails;
23 class HistoryService; 20 class HistoryService;
24 class Profile;
25 class ProfileSyncFactory;
26 class ProfileSyncService;
27 21
28 namespace history { 22 namespace history {
29 class HistoryBackend; 23 class HistoryBackend;
30 } 24 }
31 25
32 namespace browser_sync { 26 namespace browser_sync {
33 27
34 class AssociatorInterface;
35 class ChangeProcessor;
36 class ControlTask; 28 class ControlTask;
37 29
38 // A class that manages the startup and shutdown of typed_url sync. 30 // A class that manages the startup and shutdown of typed_url sync.
39 class TypedUrlDataTypeController : public DataTypeController, 31 class TypedUrlDataTypeController : public NonFrontendDataTypeController,
40 public NotificationObserver, 32 public NotificationObserver,
41 public CancelableRequestConsumerBase { 33 public CancelableRequestConsumerBase {
42 public: 34 public:
43 TypedUrlDataTypeController( 35 TypedUrlDataTypeController(
44 ProfileSyncFactory* profile_sync_factory, 36 ProfileSyncFactory* profile_sync_factory,
45 Profile* profile, 37 Profile* profile,
46 ProfileSyncService* sync_service); 38 ProfileSyncService* sync_service);
47 virtual ~TypedUrlDataTypeController(); 39 virtual ~TypedUrlDataTypeController();
48 40
49 // DataTypeController implementation 41 // NonFrontendDataTypeController implementation
50 virtual void Start(StartCallback* start_callback);
51
52 virtual void Stop();
53
54 virtual bool enabled();
55
56 virtual syncable::ModelType type() const; 42 virtual syncable::ModelType type() const;
57
58 virtual browser_sync::ModelSafeGroup model_safe_group() const; 43 virtual browser_sync::ModelSafeGroup model_safe_group() const;
59 44
60 virtual std::string name() const;
61
62 virtual State state() const;
63
64 // UnrecoverableHandler implementation
65 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
66 const std::string& message);
67
68 // NotificationObserver implementation. 45 // NotificationObserver implementation.
69 virtual void Observe(NotificationType type, 46 virtual void Observe(NotificationType type,
70 const NotificationSource& source, 47 const NotificationSource& source,
71 const NotificationDetails& details); 48 const NotificationDetails& details);
72 49
73 // CancelableRequestConsumerBase implementation. 50 // CancelableRequestConsumerBase implementation.
74 virtual void OnRequestAdded(CancelableRequestProvider* provider, 51 virtual void OnRequestAdded(CancelableRequestProvider* provider,
75 CancelableRequestProvider::Handle handle) {} 52 CancelableRequestProvider::Handle handle) {}
76
77 virtual void OnRequestRemoved(CancelableRequestProvider* provider, 53 virtual void OnRequestRemoved(CancelableRequestProvider* provider,
78 CancelableRequestProvider::Handle handle) {} 54 CancelableRequestProvider::Handle handle) {}
79
80 virtual void WillExecute(CancelableRequestProvider* provider, 55 virtual void WillExecute(CancelableRequestProvider* provider,
81 CancelableRequestProvider::Handle handle) {} 56 CancelableRequestProvider::Handle handle) {}
82
83 virtual void DidExecute(CancelableRequestProvider* provider, 57 virtual void DidExecute(CancelableRequestProvider* provider,
84 CancelableRequestProvider::Handle handle) {} 58 CancelableRequestProvider::Handle handle) {}
85 59
86 private: 60 private:
87 friend class ControlTask; 61 friend class ControlTask;
88 void StartImpl(history::HistoryBackend* backend);
89 void StartDone(StartResult result, State state);
90 void StartDoneImpl(StartResult result, State state);
91 void StopImpl();
92 void StartFailed(StartResult result);
93 void OnUnrecoverableErrorImpl(const tracked_objects::Location& from_here,
94 const std::string& message);
95 62
96 void set_state(State state) { 63 // NonFrontendDataTypeController interface.
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 virtual bool StartModels();
98 state_ = state; 65 virtual bool KickOffAssociation();
99 } 66 virtual void CreateSyncComponents();
67 virtual void CleanUpState();
68 virtual bool KickOffDestroy();
69 virtual void RecordUnrecoverableError(
70 const tracked_objects::Location& from_here,
71 const std::string& message);
72 virtual void RecordAssociationTime(base::TimeDelta time);
73 virtual void RecordStartFailure(StartResult result);
100 74
101 ProfileSyncFactory* profile_sync_factory_; 75 // Helper method to launch Associate() and Destroy() on the history thread.
102 Profile* profile_; 76 void RunOnHistoryThread(bool start, history::HistoryBackend* backend);
103 ProfileSyncService* sync_service_;
104 State state_;
105 77
106 scoped_ptr<AssociatorInterface> model_associator_; 78 history::HistoryBackend* backend_;
107 scoped_ptr<ChangeProcessor> change_processor_;
108 scoped_ptr<StartCallback> start_callback_;
109 scoped_refptr<HistoryService> history_service_; 79 scoped_refptr<HistoryService> history_service_;
110
111 NotificationRegistrar notification_registrar_; 80 NotificationRegistrar notification_registrar_;
112 81
113 base::Lock abort_association_lock_;
114 bool abort_association_;
115 base::WaitableEvent abort_association_complete_;
116
117 // Barrier to ensure that the datatype has been stopped on the DB thread
118 // from the UI thread.
119 base::WaitableEvent datatype_stopped_;
120
121 DISALLOW_COPY_AND_ASSIGN(TypedUrlDataTypeController); 82 DISALLOW_COPY_AND_ASSIGN(TypedUrlDataTypeController);
122 }; 83 };
123 84
124 } // namespace browser_sync 85 } // namespace browser_sync
125 86
126 #endif // CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__ 87 #endif // CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698