OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 virtual void OnAuthError() = 0; | 64 virtual void OnAuthError() = 0; |
65 | 65 |
66 // We are no longer permitted to communicate with the server. Sync should | 66 // We are no longer permitted to communicate with the server. Sync should |
67 // be disabled and state cleaned up at once. | 67 // be disabled and state cleaned up at once. |
68 virtual void OnStopSyncingPermanently() = 0; | 68 virtual void OnStopSyncingPermanently() = 0; |
69 | 69 |
70 // Called to handle success/failure of clearing server data | 70 // Called to handle success/failure of clearing server data |
71 virtual void OnClearServerDataSucceeded() = 0; | 71 virtual void OnClearServerDataSucceeded() = 0; |
72 virtual void OnClearServerDataFailed() = 0; | 72 virtual void OnClearServerDataFailed() = 0; |
73 | 73 |
74 // The syncer requires a passphrase to decrypt sensitive | |
75 // updates. This is called when the first sensitive data type is | |
76 // setup by the user as well as anytime any the passphrase is | |
77 // changed in another synced client. if | |
78 // |passphrase_required_for_decryption| is false, the passphrase is | |
79 // required only for encryption. | |
80 virtual void OnPassphraseRequired(bool for_decryption) = 0; | |
81 | |
82 // Called when the passphrase provided by the user is | |
83 // accepted. After this is called, updates to sensitive nodes are | |
84 // encrypted using the accepted passphrase. | |
85 virtual void OnPassphraseAccepted() = 0; | |
tim (not reviewing)
2011/01/19 20:42:53
sweet, so you gonna write a sync_backend_host_unit
| |
86 | |
74 protected: | 87 protected: |
75 // Don't delete through SyncFrontend interface. | 88 // Don't delete through SyncFrontend interface. |
76 virtual ~SyncFrontend() { | 89 virtual ~SyncFrontend() { |
77 } | 90 } |
78 private: | 91 private: |
79 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); | 92 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); |
80 }; | 93 }; |
81 | 94 |
82 // A UI-thread safe API into the sync backend that "hosts" the top-level | 95 // A UI-thread safe API into the sync backend that "hosts" the top-level |
83 // syncapi element, the SyncManager, on its own thread. This class handles | 96 // syncapi element, the SyncManager, on its own thread. This class handles |
84 // dispatch of potentially blocking calls to appropriate threads and ensures | 97 // dispatch of potentially blocking calls to appropriate threads and ensures |
85 // that the SyncFrontend is only accessed on the UI loop. | 98 // that the SyncFrontend is only accessed on the UI loop. |
86 class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { | 99 class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { |
87 public: | 100 public: |
88 typedef sync_api::UserShare* UserShareHandle; | 101 typedef sync_api::UserShare* UserShareHandle; |
89 typedef sync_api::SyncManager::Status::Summary StatusSummary; | 102 typedef sync_api::SyncManager::Status::Summary StatusSummary; |
90 typedef sync_api::SyncManager::Status Status; | 103 typedef sync_api::SyncManager::Status Status; |
91 typedef std::map<ModelSafeGroup, | 104 typedef std::map<ModelSafeGroup, |
92 scoped_refptr<browser_sync::ModelSafeWorker> > WorkerMap; | 105 scoped_refptr<browser_sync::ModelSafeWorker> > WorkerMap; |
93 | 106 |
94 // Create a SyncBackendHost with a reference to the |frontend| that it serves | 107 // Create a SyncBackendHost with a reference to the |frontend| that it serves |
95 // and communicates to via the SyncFrontend interface (on the same thread | 108 // and communicates to via the SyncFrontend interface (on the same thread |
96 // it used to call the constructor). | 109 // it used to call the constructor). |
97 SyncBackendHost(SyncFrontend* frontend, | 110 SyncBackendHost(SyncFrontend* frontend, Profile* profile); |
98 Profile* profile, | |
99 const FilePath& profile_path, | |
100 const DataTypeController::TypeMap& data_type_controllers); | |
101 // For testing. | 111 // For testing. |
102 // TODO(skrul): Extract an interface so this is not needed. | 112 // TODO(skrul): Extract an interface so this is not needed. |
103 SyncBackendHost(); | 113 SyncBackendHost(); |
104 ~SyncBackendHost(); | 114 ~SyncBackendHost(); |
105 | 115 |
106 // Called on |frontend_loop_| to kick off asynchronous initialization. | 116 // Called on |frontend_loop_| to kick off asynchronous initialization. |
107 // As a fallback when no cached auth information is available, try to | 117 // As a fallback when no cached auth information is available, try to |
108 // bootstrap authentication using |lsid|, if it isn't empty. | 118 // bootstrap authentication using |lsid|, if it isn't empty. |
109 // Optionally delete the Sync Data folder (if it's corrupt). | 119 // Optionally delete the Sync Data folder (if it's corrupt). |
110 void Initialize(const GURL& service_url, | 120 void Initialize(const GURL& service_url, |
(...skipping 21 matching lines...) Expand all Loading... | |
132 | 142 |
133 // Called on |frontend_loop_| to kick off shutdown. | 143 // Called on |frontend_loop_| to kick off shutdown. |
134 // |sync_disabled| indicates if syncing is being disabled or not. | 144 // |sync_disabled| indicates if syncing is being disabled or not. |
135 // See the implementation and Core::DoShutdown for details. | 145 // See the implementation and Core::DoShutdown for details. |
136 void Shutdown(bool sync_disabled); | 146 void Shutdown(bool sync_disabled); |
137 | 147 |
138 // Changes the set of data types that are currently being synced. | 148 // Changes the set of data types that are currently being synced. |
139 // The ready_task will be run when all of the requested data types | 149 // The ready_task will be run when all of the requested data types |
140 // are up-to-date and ready for activation. The task will cancelled | 150 // are up-to-date and ready for activation. The task will cancelled |
141 // upon shutdown. The method takes ownership of the task pointer. | 151 // upon shutdown. The method takes ownership of the task pointer. |
142 virtual void ConfigureDataTypes(const syncable::ModelTypeSet& types, | 152 virtual void ConfigureDataTypes( |
143 CancelableTask* ready_task); | 153 const DataTypeController::TypeMap& data_type_controllers, |
154 const syncable::ModelTypeSet& types, | |
155 CancelableTask* ready_task); | |
144 | 156 |
145 syncable::AutofillMigrationState | 157 syncable::AutofillMigrationState |
146 GetAutofillMigrationState(); | 158 GetAutofillMigrationState(); |
147 | 159 |
148 void SetAutofillMigrationState( | 160 void SetAutofillMigrationState( |
149 syncable::AutofillMigrationState state); | 161 syncable::AutofillMigrationState state); |
150 | 162 |
151 syncable::AutofillMigrationDebugInfo | 163 syncable::AutofillMigrationDebugInfo |
152 GetAutofillMigrationDebugInfo(); | 164 GetAutofillMigrationDebugInfo(); |
153 | 165 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 | 511 |
500 // The frontend which we serve (and are owned by). | 512 // The frontend which we serve (and are owned by). |
501 SyncFrontend* frontend_; | 513 SyncFrontend* frontend_; |
502 | 514 |
503 // The change processors that handle the different data types. | 515 // The change processors that handle the different data types. |
504 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 516 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
505 | 517 |
506 // Path of the folder that stores the sync data files. | 518 // Path of the folder that stores the sync data files. |
507 FilePath sync_data_folder_path_; | 519 FilePath sync_data_folder_path_; |
508 | 520 |
509 // List of registered data type controllers. | |
510 DataTypeController::TypeMap data_type_controllers_; | |
511 | |
512 // A task that should be called once data type configuration is | 521 // A task that should be called once data type configuration is |
513 // complete. | 522 // complete. |
514 scoped_ptr<CancelableTask> configure_ready_task_; | 523 scoped_ptr<CancelableTask> configure_ready_task_; |
515 | 524 |
516 // The set of types that we are waiting to be initially synced in a | 525 // The set of types that we are waiting to be initially synced in a |
517 // configuration cycle. | 526 // configuration cycle. |
518 syncable::ModelTypeSet configure_initial_sync_types_; | 527 syncable::ModelTypeSet configure_initial_sync_types_; |
519 | 528 |
520 // UI-thread cache of the last AuthErrorState received from syncapi. | 529 // UI-thread cache of the last AuthErrorState received from syncapi. |
521 GoogleServiceAuthError last_auth_error_; | 530 GoogleServiceAuthError last_auth_error_; |
522 | 531 |
523 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 532 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
524 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; | 533 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; |
525 | 534 |
526 // Whether we've processed the initialization complete callback. | 535 // Whether we've processed the initialization complete callback. |
527 bool syncapi_initialized_; | 536 bool syncapi_initialized_; |
528 | 537 |
529 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 538 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
530 }; | 539 }; |
531 | 540 |
532 } // namespace browser_sync | 541 } // namespace browser_sync |
533 | 542 |
534 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 543 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
OLD | NEW |