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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_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/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "chrome/browser/google_service_auth_error.h" | 17 #include "chrome/browser/google_service_auth_error.h" |
18 #include "chrome/browser/pref_member.h" | 18 #include "chrome/browser/pref_member.h" |
19 #include "chrome/browser/sync/glue/data_type_controller.h" | 19 #include "chrome/browser/sync/glue/data_type_controller.h" |
20 #include "chrome/browser/sync/glue/data_type_manager.h" | 20 #include "chrome/browser/sync/glue/data_type_manager.h" |
| 21 #include "chrome/browser/sync/glue/session_model_associator.h" |
21 #include "chrome/browser/sync/glue/sync_backend_host.h" | 22 #include "chrome/browser/sync/glue/sync_backend_host.h" |
22 #include "chrome/browser/sync/notification_method.h" | 23 #include "chrome/browser/sync/notification_method.h" |
23 #include "chrome/browser/sync/profile_sync_service_observer.h" | 24 #include "chrome/browser/sync/profile_sync_service_observer.h" |
24 #include "chrome/browser/sync/sync_setup_wizard.h" | 25 #include "chrome/browser/sync/sync_setup_wizard.h" |
25 #include "chrome/browser/sync/syncable/model_type.h" | 26 #include "chrome/browser/sync/syncable/model_type.h" |
26 #include "chrome/browser/sync/unrecoverable_error_handler.h" | 27 #include "chrome/browser/sync/unrecoverable_error_handler.h" |
27 #include "chrome/common/notification_observer.h" | 28 #include "chrome/common/notification_observer.h" |
28 #include "chrome/common/notification_registrar.h" | 29 #include "chrome/common/notification_registrar.h" |
29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
30 | 31 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // class is constructed. | 121 // class is constructed. |
121 void Initialize(); | 122 void Initialize(); |
122 | 123 |
123 // Registers a data type controller with the sync service. This | 124 // Registers a data type controller with the sync service. This |
124 // makes the data type controller available for use, it does not | 125 // makes the data type controller available for use, it does not |
125 // enable or activate the synchronization of the data type (see | 126 // enable or activate the synchronization of the data type (see |
126 // ActivateDataType). Takes ownership of the pointer. | 127 // ActivateDataType). Takes ownership of the pointer. |
127 void RegisterDataTypeController( | 128 void RegisterDataTypeController( |
128 browser_sync::DataTypeController* data_type_controller); | 129 browser_sync::DataTypeController* data_type_controller); |
129 | 130 |
| 131 // Returns the session model associator associated with this type, but only if |
| 132 // the associator is running. If it is doing anything else, it will return |
| 133 // null. |
| 134 browser_sync::SessionModelAssociator* GetSessionModelAssociator(); |
| 135 |
130 // Fills state_map with a map of current data types that are possible to | 136 // Fills state_map with a map of current data types that are possible to |
131 // sync, as well as their states. | 137 // sync, as well as their states. |
132 void GetDataTypeControllerStates( | 138 void GetDataTypeControllerStates( |
133 browser_sync::DataTypeController::StateMap* state_map) const; | 139 browser_sync::DataTypeController::StateMap* state_map) const; |
134 | 140 |
135 // Enables/disables sync for user. | 141 // Enables/disables sync for user. |
136 virtual void EnableForUser(gfx::NativeWindow parent_window); | 142 virtual void EnableForUser(gfx::NativeWindow parent_window); |
137 virtual void DisableForUser(); | 143 virtual void DisableForUser(); |
138 | 144 |
139 // Whether sync is enabled by user or not. | 145 // Whether sync is enabled by user or not. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 294 |
289 // Checks whether the Cryptographer is ready to encrypt and decrypt updates | 295 // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
290 // for sensitive data types. | 296 // for sensitive data types. |
291 virtual bool IsCryptographerReady() const; | 297 virtual bool IsCryptographerReady() const; |
292 | 298 |
293 // Sets the Cryptographer's passphrase. This will check asynchronously whether | 299 // Sets the Cryptographer's passphrase. This will check asynchronously whether |
294 // the passphrase is valid and notify ProfileSyncServiceObservers via the | 300 // the passphrase is valid and notify ProfileSyncServiceObservers via the |
295 // NotificationService when the outcome is known. | 301 // NotificationService when the outcome is known. |
296 virtual void SetPassphrase(const std::string& passphrase); | 302 virtual void SetPassphrase(const std::string& passphrase); |
297 | 303 |
| 304 // Returns whether processing changes is allowed. Check this before doing |
| 305 // any model-modifying operations. |
| 306 bool ShouldPushChanges(); |
| 307 |
298 protected: | 308 protected: |
299 // Used by ProfileSyncServiceMock only. | 309 // Used by ProfileSyncServiceMock only. |
300 // | 310 // |
301 // TODO(akalin): Separate this class out into an abstract | 311 // TODO(akalin): Separate this class out into an abstract |
302 // ProfileSyncService interface and a ProfileSyncServiceImpl class | 312 // ProfileSyncService interface and a ProfileSyncServiceImpl class |
303 // so we don't need this hack anymore. | 313 // so we don't need this hack anymore. |
304 ProfileSyncService(); | 314 ProfileSyncService(); |
305 | 315 |
306 // Helper to install and configure a data type manager. | 316 // Helper to install and configure a data type manager. |
307 void ConfigureDataTypeManager(); | 317 void ConfigureDataTypeManager(); |
308 | 318 |
309 // Returns whether processing changes is allowed. Check this before doing | |
310 // any model-modifying operations. | |
311 bool ShouldPushChanges(); | |
312 | |
313 // Starts up the backend sync components. | 319 // Starts up the backend sync components. |
314 void StartUp(); | 320 void StartUp(); |
315 // Shuts down the backend sync components. | 321 // Shuts down the backend sync components. |
316 // |sync_disabled| indicates if syncing is being disabled or not. | 322 // |sync_disabled| indicates if syncing is being disabled or not. |
317 void Shutdown(bool sync_disabled); | 323 void Shutdown(bool sync_disabled); |
318 | 324 |
319 // Methods to register and remove preferences. | 325 // Methods to register and remove preferences. |
320 void RegisterPreferences(); | 326 void RegisterPreferences(); |
321 void ClearPreferences(); | 327 void ClearPreferences(); |
322 | 328 |
(...skipping 14 matching lines...) Expand all Loading... |
337 // Our asynchronous backend to communicate with sync components living on | 343 // Our asynchronous backend to communicate with sync components living on |
338 // other threads. | 344 // other threads. |
339 scoped_ptr<browser_sync::SyncBackendHost> backend_; | 345 scoped_ptr<browser_sync::SyncBackendHost> backend_; |
340 | 346 |
341 // Cache of the last name the client attempted to authenticate. | 347 // Cache of the last name the client attempted to authenticate. |
342 std::string last_attempted_user_email_; | 348 std::string last_attempted_user_email_; |
343 | 349 |
344 private: | 350 private: |
345 friend class ProfileSyncServiceTest; | 351 friend class ProfileSyncServiceTest; |
346 friend class ProfileSyncServicePreferenceTest; | 352 friend class ProfileSyncServicePreferenceTest; |
| 353 friend class ProfileSyncServiceSessionTest; |
347 friend class ProfileSyncServiceTestHarness; | 354 friend class ProfileSyncServiceTestHarness; |
348 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); | 355 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); |
349 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, | 356 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, |
350 UnrecoverableErrorSuspendsService); | 357 UnrecoverableErrorSuspendsService); |
351 | 358 |
352 // If |delete_sync_data_folder| is true, then this method will delete all | 359 // If |delete_sync_data_folder| is true, then this method will delete all |
353 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). | 360 // previous "Sync Data" folders. (useful if the folder is partial/corrupt). |
354 void InitializeBackend(bool delete_sync_data_folder); | 361 void InitializeBackend(bool delete_sync_data_folder); |
355 | 362 |
356 // Initializes the various settings from the command line. | 363 // Initializes the various settings from the command line. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 451 |
445 // This allows us to gracefully handle an ABORTED return code from the | 452 // This allows us to gracefully handle an ABORTED return code from the |
446 // DataTypeManager in the event that the server informed us to cease and | 453 // DataTypeManager in the event that the server informed us to cease and |
447 // desist syncing immediately. | 454 // desist syncing immediately. |
448 bool expect_sync_configuration_aborted_; | 455 bool expect_sync_configuration_aborted_; |
449 | 456 |
450 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 457 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
451 }; | 458 }; |
452 | 459 |
453 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 460 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |