OLD | NEW |
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_SYNC_BACKEND_HOST_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/sync/js/js_backend.h" | 27 #include "chrome/browser/sync/js/js_backend.h" |
28 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" | 28 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" |
29 #include "chrome/browser/sync/syncable/model_type.h" | 29 #include "chrome/browser/sync/syncable/model_type.h" |
30 #include "chrome/browser/sync/weak_handle.h" | 30 #include "chrome/browser/sync/weak_handle.h" |
31 #include "chrome/common/net/gaia/google_service_auth_error.h" | 31 #include "chrome/common/net/gaia/google_service_auth_error.h" |
32 #include "googleurl/src/gurl.h" | 32 #include "googleurl/src/gurl.h" |
33 #include "net/url_request/url_request_context_getter.h" | 33 #include "net/url_request/url_request_context_getter.h" |
34 | 34 |
35 class CancelableTask; | 35 class CancelableTask; |
36 class Profile; | 36 class Profile; |
| 37 class ProfileSyncFactory; |
37 | 38 |
38 namespace net { | 39 namespace net { |
39 class URLRequestContextGetter; | 40 class URLRequestContextGetter; |
40 } | 41 } |
41 | 42 |
42 namespace browser_sync { | 43 namespace browser_sync { |
43 | 44 |
44 namespace sessions { | 45 namespace sessions { |
45 struct SyncSessionSnapshot; | 46 struct SyncSessionSnapshot; |
46 } | 47 } |
47 | 48 |
48 class ChangeProcessor; | 49 class ChangeProcessor; |
| 50 class DataTypeController; |
49 class JsEventHandler; | 51 class JsEventHandler; |
50 | 52 |
51 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 53 // SyncFrontend is the interface used by SyncBackendHost to communicate with |
52 // the entity that created it and, presumably, is interested in sync-related | 54 // the entity that created it and, presumably, is interested in sync-related |
53 // activity. | 55 // activity. |
54 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 56 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread |
55 // used to create that SyncBackendHost. | 57 // used to create that SyncBackendHost. |
56 class SyncFrontend { | 58 class SyncFrontend { |
57 public: | 59 public: |
58 SyncFrontend() {} | 60 SyncFrontend() {} |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // encrypted using the accepted passphrase. | 96 // encrypted using the accepted passphrase. |
95 virtual void OnPassphraseAccepted() = 0; | 97 virtual void OnPassphraseAccepted() = 0; |
96 | 98 |
97 virtual void OnEncryptionComplete( | 99 virtual void OnEncryptionComplete( |
98 const syncable::ModelTypeSet& encrypted_types) = 0; | 100 const syncable::ModelTypeSet& encrypted_types) = 0; |
99 | 101 |
100 // Called to perform migration of |types|. | 102 // Called to perform migration of |types|. |
101 virtual void OnMigrationNeededForTypes( | 103 virtual void OnMigrationNeededForTypes( |
102 const syncable::ModelTypeSet& types) = 0; | 104 const syncable::ModelTypeSet& types) = 0; |
103 | 105 |
| 106 // Get the list of types that can be enabled. |
| 107 virtual void GetRegisteredDataTypes(syncable::ModelTypeSet* types) const = 0; |
| 108 |
| 109 // Get the list of types that are enabled. |
| 110 virtual void GetPreferredDataTypes(syncable::ModelTypeSet* types) const = 0; |
| 111 |
| 112 // Register a DataTypeController. |
| 113 virtual void RegisterDataTypeController( |
| 114 browser_sync::DataTypeController* data_type_controller) = 0; |
| 115 |
104 protected: | 116 protected: |
105 // Don't delete through SyncFrontend interface. | 117 // Don't delete through SyncFrontend interface. |
106 virtual ~SyncFrontend() { | 118 virtual ~SyncFrontend() { |
107 } | 119 } |
108 private: | 120 private: |
109 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); | 121 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); |
110 }; | 122 }; |
111 | 123 |
112 // A UI-thread safe API into the sync backend that "hosts" the top-level | 124 // A UI-thread safe API into the sync backend that "hosts" the top-level |
113 // syncapi element, the SyncManager, on its own thread. This class handles | 125 // syncapi element, the SyncManager, on its own thread. This class handles |
(...skipping 13 matching lines...) Expand all Loading... |
127 // For testing. | 139 // For testing. |
128 // TODO(skrul): Extract an interface so this is not needed. | 140 // TODO(skrul): Extract an interface so this is not needed. |
129 SyncBackendHost(); | 141 SyncBackendHost(); |
130 virtual ~SyncBackendHost(); | 142 virtual ~SyncBackendHost(); |
131 | 143 |
132 // Called on |frontend_loop_| to kick off asynchronous initialization. | 144 // Called on |frontend_loop_| to kick off asynchronous initialization. |
133 // As a fallback when no cached auth information is available, try to | 145 // As a fallback when no cached auth information is available, try to |
134 // bootstrap authentication using |lsid|, if it isn't empty. | 146 // bootstrap authentication using |lsid|, if it isn't empty. |
135 // Optionally delete the Sync Data folder (if it's corrupt). | 147 // Optionally delete the Sync Data folder (if it's corrupt). |
136 void Initialize(SyncFrontend* frontend, | 148 void Initialize(SyncFrontend* frontend, |
| 149 ProfileSyncFactory* factory, |
137 const WeakHandle<JsEventHandler>& event_handler, | 150 const WeakHandle<JsEventHandler>& event_handler, |
138 const GURL& service_url, | 151 const GURL& service_url, |
139 const syncable::ModelTypeSet& initial_types, | 152 const syncable::ModelTypeSet& initial_types, |
140 const sync_api::SyncCredentials& credentials, | 153 const sync_api::SyncCredentials& credentials, |
141 bool delete_sync_data_folder); | 154 bool delete_sync_data_folder); |
142 | 155 |
143 // Called from |frontend_loop| to update SyncCredentials. | 156 // Called from |frontend_loop| to update SyncCredentials. |
144 void UpdateCredentials(const sync_api::SyncCredentials& credentials); | 157 void UpdateCredentials(const sync_api::SyncCredentials& credentials); |
145 | 158 |
146 // This starts the SyncerThread running a Syncer object to communicate with | 159 // This starts the SyncerThread running a Syncer object to communicate with |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 // SyncBackendHost may read (on the UI thread or sync thread) from registrar_ | 604 // SyncBackendHost may read (on the UI thread or sync thread) from registrar_ |
592 // without acquiring the lock (which is typically "read ModelSafeWorker | 605 // without acquiring the lock (which is typically "read ModelSafeWorker |
593 // pointer value", and then invoke methods), because lifetimes are managed on | 606 // pointer value", and then invoke methods), because lifetimes are managed on |
594 // the UI thread. Of course, this comment only applies to ModelSafeWorker | 607 // the UI thread. Of course, this comment only applies to ModelSafeWorker |
595 // impls that are themselves thread-safe, such as UIModelWorker. | 608 // impls that are themselves thread-safe, such as UIModelWorker. |
596 mutable base::Lock registrar_lock_; | 609 mutable base::Lock registrar_lock_; |
597 | 610 |
598 // The frontend which we serve (and are owned by). | 611 // The frontend which we serve (and are owned by). |
599 SyncFrontend* frontend_; | 612 SyncFrontend* frontend_; |
600 | 613 |
| 614 // The factory for creating DataTypeControllers. |
| 615 ProfileSyncFactory* profile_sync_factory_; |
| 616 |
601 // The change processors that handle the different data types. | 617 // The change processors that handle the different data types. |
602 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 618 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
603 | 619 |
604 // Path of the folder that stores the sync data files. | 620 // Path of the folder that stores the sync data files. |
605 FilePath sync_data_folder_path_; | 621 FilePath sync_data_folder_path_; |
606 | 622 |
607 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; | 623 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; |
608 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; | 624 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; |
609 | 625 |
610 // UI-thread cache of the last AuthErrorState received from syncapi. | 626 // UI-thread cache of the last AuthErrorState received from syncapi. |
611 GoogleServiceAuthError last_auth_error_; | 627 GoogleServiceAuthError last_auth_error_; |
612 | 628 |
613 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 629 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
614 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; | 630 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; |
615 | 631 |
616 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 632 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
617 }; | 633 }; |
618 | 634 |
619 } // namespace browser_sync | 635 } // namespace browser_sync |
620 | 636 |
621 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 637 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |