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