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