| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_API_SYNCABLE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/sync/api/sync_change_processor.h" | 14 #include "chrome/browser/sync/api/sync_change_processor.h" |
| 14 #include "chrome/browser/sync/api/sync_data.h" | 15 #include "chrome/browser/sync/api/sync_data.h" |
| 15 #include "chrome/browser/sync/api/sync_error.h" | 16 #include "chrome/browser/sync/api/sync_error.h" |
| 16 #include "sync/syncable/model_type.h" | 17 #include "sync/syncable/model_type.h" |
| 17 | 18 |
| 18 class SyncData; | |
| 19 | |
| 20 typedef std::vector<SyncData> SyncDataList; | 19 typedef std::vector<SyncData> SyncDataList; |
| 21 | 20 |
| 22 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService | 21 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService |
| 23 // implementers provide a way of getting a weak pointer to themselves. | 22 // implementers provide a way of getting a weak pointer to themselves. |
| 24 // See crbug.com/100114. | 23 // See crbug.com/100114. |
| 25 class SyncableService : public SyncChangeProcessor, | 24 class SyncableService : public SyncChangeProcessor, |
| 26 public base::SupportsWeakPtr<SyncableService> { | 25 public base::SupportsWeakPtr<SyncableService> { |
| 27 public: | 26 public: |
| 28 // Informs the service to begin syncing the specified synced datatype |type|. | 27 // Informs the service to begin syncing the specified synced datatype |type|. |
| 29 // The service should then merge |initial_sync_data| into it's local data, | 28 // The service should then merge |initial_sync_data| into it's local data, |
| 30 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the | 29 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the |
| 31 // two. After this, the SyncableService's local data should match the server | 30 // two. After this, the SyncableService's local data should match the server |
| 32 // data, and the service should be ready to receive and process any further | 31 // data, and the service should be ready to receive and process any further |
| 33 // SyncChange's as they occur. | 32 // SyncChange's as they occur. |
| 34 // Returns: A default SyncError (IsSet() == false) if no errors were | 33 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 35 // encountered, and a filled SyncError (IsSet() == true) | 34 // encountered, and a filled SyncError (IsSet() == true) |
| 36 // otherwise. | 35 // otherwise. |
| 37 virtual SyncError MergeDataAndStartSyncing( | 36 virtual SyncError MergeDataAndStartSyncing( |
| 38 syncable::ModelType type, | 37 syncable::ModelType type, |
| 39 const SyncDataList& initial_sync_data, | 38 const SyncDataList& initial_sync_data, |
| 40 SyncChangeProcessor* sync_processor) = 0; | 39 scoped_ptr<SyncChangeProcessor> sync_processor) = 0; |
| 41 | 40 |
| 42 // Stop syncing the specified type and reset state. | 41 // Stop syncing the specified type and reset state. |
| 43 virtual void StopSyncing(syncable::ModelType type) = 0; | 42 virtual void StopSyncing(syncable::ModelType type) = 0; |
| 44 | 43 |
| 45 // Fills a list of SyncData from the local data. This should create an up | 44 // Fills a list of SyncData from the local data. This should create an up |
| 46 // to date representation of the SyncableService's view of that datatype, and | 45 // to date representation of the SyncableService's view of that datatype, and |
| 47 // should match/be a subset of the server's view of that datatype. | 46 // should match/be a subset of the server's view of that datatype. |
| 48 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; | 47 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const = 0; |
| 49 | 48 |
| 50 // SyncChangeProcessor interface. | 49 // SyncChangeProcessor interface. |
| 51 // Process a list of new SyncChanges and update the local data as necessary. | 50 // Process a list of new SyncChanges and update the local data as necessary. |
| 52 // Returns: A default SyncError (IsSet() == false) if no errors were | 51 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 53 // encountered, and a filled SyncError (IsSet() == true) | 52 // encountered, and a filled SyncError (IsSet() == true) |
| 54 // otherwise. | 53 // otherwise. |
| 55 virtual SyncError ProcessSyncChanges( | 54 virtual SyncError ProcessSyncChanges( |
| 56 const tracked_objects::Location& from_here, | 55 const tracked_objects::Location& from_here, |
| 57 const SyncChangeList& change_list) OVERRIDE = 0; | 56 const SyncChangeList& change_list) OVERRIDE = 0; |
| 58 | 57 |
| 59 protected: | 58 protected: |
| 60 virtual ~SyncableService(); | 59 virtual ~SyncableService(); |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ | 62 #endif // CHROME_BROWSER_SYNC_API_SYNCABLE_SERVICE_H_ |
| OLD | NEW |