| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "sync/api/sync_change_processor.h" | 14 #include "sync/api/sync_change_processor.h" |
| 14 #include "sync/api/sync_data.h" | 15 #include "sync/api/sync_data.h" |
| 15 #include "sync/api/sync_error.h" | 16 #include "sync/api/sync_error.h" |
| 16 #include "sync/api/sync_merge_result.h" | 17 #include "sync/api/sync_merge_result.h" |
| 17 #include "sync/base/sync_export.h" | 18 #include "sync/base/sync_export.h" |
| 18 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
| 19 | 20 |
| 20 namespace syncer { | 21 namespace syncer { |
| 21 | 22 |
| 22 class SyncErrorFactory; | 23 class SyncErrorFactory; |
| 23 | 24 |
| 24 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService | 25 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService |
| 25 // implementers provide a way of getting a weak pointer to themselves. | 26 // implementers provide a way of getting a weak pointer to themselves. |
| 26 // See crbug.com/100114. | 27 // See crbug.com/100114. |
| 27 class SYNC_EXPORT SyncableService | 28 class SYNC_EXPORT SyncableService |
| 28 : public SyncChangeProcessor, | 29 : public SyncChangeProcessor, |
| 29 public base::SupportsWeakPtr<SyncableService> { | 30 public base::SupportsWeakPtr<SyncableService> { |
| 30 public: | 31 public: |
| 32 // A StartSyncFlare is useful when your SyncableService has a need for sync |
| 33 // to start ASAP, typically because a local change event has occurred but |
| 34 // MergeDataAndStartSyncing hasn't been called yet, meaning you don't have a |
| 35 // SyncChangeProcessor. The sync subsystem will respond soon after invoking |
| 36 // Run() on your flare by calling MergeDataAndStartSyncing. The ModelType |
| 37 // parameter is included so that the recieving end can track usage and timing |
| 38 // statistics, make optimizations or tradeoffs by type, etc. |
| 39 typedef base::Callback<void(ModelType)> StartSyncFlare; |
| 40 |
| 31 // Informs the service to begin syncing the specified synced datatype |type|. | 41 // Informs the service to begin syncing the specified synced datatype |type|. |
| 32 // The service should then merge |initial_sync_data| into it's local data, | 42 // The service should then merge |initial_sync_data| into it's local data, |
| 33 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the | 43 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the |
| 34 // two. After this, the SyncableService's local data should match the server | 44 // two. After this, the SyncableService's local data should match the server |
| 35 // data, and the service should be ready to receive and process any further | 45 // data, and the service should be ready to receive and process any further |
| 36 // SyncChange's as they occur. | 46 // SyncChange's as they occur. |
| 37 // Returns: a SyncMergeResult whose error field reflects whether an error | 47 // Returns: a SyncMergeResult whose error field reflects whether an error |
| 38 // was encountered while merging the two models. The merge result | 48 // was encountered while merging the two models. The merge result |
| 39 // may also contain optional merge statistics. | 49 // may also contain optional merge statistics. |
| 40 virtual SyncMergeResult MergeDataAndStartSyncing( | 50 virtual SyncMergeResult MergeDataAndStartSyncing( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 60 const tracked_objects::Location& from_here, | 70 const tracked_objects::Location& from_here, |
| 61 const SyncChangeList& change_list) OVERRIDE = 0; | 71 const SyncChangeList& change_list) OVERRIDE = 0; |
| 62 | 72 |
| 63 protected: | 73 protected: |
| 64 virtual ~SyncableService(); | 74 virtual ~SyncableService(); |
| 65 }; | 75 }; |
| 66 | 76 |
| 67 } // namespace syncer | 77 } // namespace syncer |
| 68 | 78 |
| 69 #endif // SYNC_API_SYNCABLE_SERVICE_H_ | 79 #endif // SYNC_API_SYNCABLE_SERVICE_H_ |
| OLD | NEW |