| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 SYNC_API_SYNCABLE_SERVICE_H_ | 5 #ifndef SYNC_API_SYNCABLE_SERVICE_H_ |
| 6 #define SYNC_API_SYNCABLE_SERVICE_H_ | 6 #define SYNC_API_SYNCABLE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "sync/api/attachments/attachment_store.h" | 14 #include "sync/api/attachments/attachment_store.h" |
| 15 #include "sync/api/sync_change_processor.h" | 15 #include "sync/api/sync_change_processor.h" |
| 16 #include "sync/api/sync_data.h" | 16 #include "sync/api/sync_data.h" |
| 17 #include "sync/api/sync_error.h" | 17 #include "sync/api/sync_error.h" |
| 18 #include "sync/api/sync_merge_result.h" | 18 #include "sync/api/sync_merge_result.h" |
| 19 #include "sync/base/sync_export.h" | 19 #include "sync/base/sync_export.h" |
| 20 #include "sync/internal_api/public/base/model_type.h" | 20 #include "sync/internal_api/public/base/model_type.h" |
| 21 | 21 |
| 22 namespace syncer { | 22 namespace syncer { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the | 45 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the |
| 46 // two. After this, the SyncableService's local data should match the server | 46 // two. After this, the SyncableService's local data should match the server |
| 47 // data, and the service should be ready to receive and process any further | 47 // data, and the service should be ready to receive and process any further |
| 48 // SyncChange's as they occur. | 48 // SyncChange's as they occur. |
| 49 // Returns: a SyncMergeResult whose error field reflects whether an error | 49 // Returns: a SyncMergeResult whose error field reflects whether an error |
| 50 // was encountered while merging the two models. The merge result | 50 // was encountered while merging the two models. The merge result |
| 51 // may also contain optional merge statistics. | 51 // may also contain optional merge statistics. |
| 52 virtual SyncMergeResult MergeDataAndStartSyncing( | 52 virtual SyncMergeResult MergeDataAndStartSyncing( |
| 53 ModelType type, | 53 ModelType type, |
| 54 const SyncDataList& initial_sync_data, | 54 const SyncDataList& initial_sync_data, |
| 55 scoped_ptr<SyncChangeProcessor> sync_processor, | 55 std::unique_ptr<SyncChangeProcessor> sync_processor, |
| 56 scoped_ptr<SyncErrorFactory> error_handler) = 0; | 56 std::unique_ptr<SyncErrorFactory> error_handler) = 0; |
| 57 | 57 |
| 58 // Stop syncing the specified type and reset state. | 58 // Stop syncing the specified type and reset state. |
| 59 virtual void StopSyncing(ModelType type) = 0; | 59 virtual void StopSyncing(ModelType type) = 0; |
| 60 | 60 |
| 61 // SyncChangeProcessor interface. | 61 // SyncChangeProcessor interface. |
| 62 // Process a list of new SyncChanges and update the local data as necessary. | 62 // Process a list of new SyncChanges and update the local data as necessary. |
| 63 // Returns: A default SyncError (IsSet() == false) if no errors were | 63 // Returns: A default SyncError (IsSet() == false) if no errors were |
| 64 // encountered, and a filled SyncError (IsSet() == true) | 64 // encountered, and a filled SyncError (IsSet() == true) |
| 65 // otherwise. | 65 // otherwise. |
| 66 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here, | 66 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here, |
| 67 const SyncChangeList& change_list) override = 0; | 67 const SyncChangeList& change_list) override = 0; |
| 68 | 68 |
| 69 // Returns AttachmentStore for use by sync when uploading or downloading | 69 // Returns AttachmentStore for use by sync when uploading or downloading |
| 70 // attachments. | 70 // attachments. |
| 71 // GetAttachmentStoreForSync is called right before MergeDataAndStartSyncing. | 71 // GetAttachmentStoreForSync is called right before MergeDataAndStartSyncing. |
| 72 // If at that time GetAttachmentStoreForSync returns NULL then datatype is | 72 // If at that time GetAttachmentStoreForSync returns NULL then datatype is |
| 73 // considered not using attachments and all attempts to upload/download | 73 // considered not using attachments and all attempts to upload/download |
| 74 // attachments will fail. Default implementation returns NULL. Datatype that | 74 // attachments will fail. Default implementation returns NULL. Datatype that |
| 75 // uses sync attachments should create attachment store, implement | 75 // uses sync attachments should create attachment store, implement |
| 76 // GetAttachmentStoreForSync to return result of | 76 // GetAttachmentStoreForSync to return result of |
| 77 // AttachmentStore::CreateAttachmentStoreForSync() from attachment store | 77 // AttachmentStore::CreateAttachmentStoreForSync() from attachment store |
| 78 // object. | 78 // object. |
| 79 virtual scoped_ptr<AttachmentStoreForSync> GetAttachmentStoreForSync(); | 79 virtual std::unique_ptr<AttachmentStoreForSync> GetAttachmentStoreForSync(); |
| 80 | 80 |
| 81 // Called by sync to provide AttachmentService to be used to download | 81 // Called by sync to provide AttachmentService to be used to download |
| 82 // attachments. | 82 // attachments. |
| 83 // SetAttachmentService is called after GetAttachmentStore and right before | 83 // SetAttachmentService is called after GetAttachmentStore and right before |
| 84 // MergeDataAndStartSyncing and only if GetAttachmentStore has returned a | 84 // MergeDataAndStartSyncing and only if GetAttachmentStore has returned a |
| 85 // non-NULL store instance. Default implementation does nothing. | 85 // non-NULL store instance. Default implementation does nothing. |
| 86 // Datatype that uses attachments must take ownerhip of the provided | 86 // Datatype that uses attachments must take ownerhip of the provided |
| 87 // AttachmentService instance. | 87 // AttachmentService instance. |
| 88 virtual void SetAttachmentService( | 88 virtual void SetAttachmentService( |
| 89 scoped_ptr<AttachmentService> attachment_service); | 89 std::unique_ptr<AttachmentService> attachment_service); |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 ~SyncableService() override; | 92 ~SyncableService() override; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace syncer | 95 } // namespace syncer |
| 96 | 96 |
| 97 #endif // SYNC_API_SYNCABLE_SERVICE_H_ | 97 #endif // SYNC_API_SYNCABLE_SERVICE_H_ |
| OLD | NEW |