Chromium Code Reviews| 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 |
| 25 // Used as a parameter to InjectStartSyncFlare. The StartSyncFlare is useful | |
| 26 // when your SyncableService has a need for sync to start ASAP, typically | |
| 27 // because a local change event has occurred but MergeDataAndStartSyncing | |
| 28 // hasn't been called yet, meaning you don't have a SyncChangeProcessor. | |
| 29 // The sync subsystem will respond soon after invoking Run() on your flare | |
| 30 // by calling MergeDataAndStartSyncing. The ModelType parameter is included so | |
| 31 // that the recieving end can track usage and timing statistics, make | |
| 32 // optimizations or tradeoffs by type, etc. | |
| 33 typedef base::Callback<void(ModelType)> StartSyncFlare; | |
| 34 | |
| 24 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService | 35 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService |
| 25 // implementers provide a way of getting a weak pointer to themselves. | 36 // implementers provide a way of getting a weak pointer to themselves. |
| 26 // See crbug.com/100114. | 37 // See crbug.com/100114. |
| 27 class SYNC_EXPORT SyncableService | 38 class SYNC_EXPORT SyncableService |
| 28 : public SyncChangeProcessor, | 39 : public SyncChangeProcessor, |
| 29 public base::SupportsWeakPtr<SyncableService> { | 40 public base::SupportsWeakPtr<SyncableService> { |
| 30 public: | 41 public: |
| 42 // Provides a StartSyncFlare to the SyncableService. | |
| 43 // TODO(tim): BUG 80194. Make pure virtual. | |
| 44 virtual void InjectStartSyncFlare(const StartSyncFlare& flare); | |
|
Nicolas Zea
2013/05/01 22:37:04
Is this really necessary? Why can't a datatype jus
tim (not reviewing)
2013/05/01 23:20:44
Is there an elegant way to get a hold of a profile
Nicolas Zea
2013/05/02 18:01:07
I'm fine with passing the more specific thing, i.e
| |
| 45 | |
| 31 // Informs the service to begin syncing the specified synced datatype |type|. | 46 // 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, | 47 // The service should then merge |initial_sync_data| into it's local data, |
| 33 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the | 48 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the |
| 34 // two. After this, the SyncableService's local data should match the server | 49 // 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 | 50 // data, and the service should be ready to receive and process any further |
| 36 // SyncChange's as they occur. | 51 // SyncChange's as they occur. |
| 37 // Returns: a SyncMergeResult whose error field reflects whether an error | 52 // Returns: a SyncMergeResult whose error field reflects whether an error |
| 38 // was encountered while merging the two models. The merge result | 53 // was encountered while merging the two models. The merge result |
| 39 // may also contain optional merge statistics. | 54 // may also contain optional merge statistics. |
| 40 virtual SyncMergeResult MergeDataAndStartSyncing( | 55 virtual SyncMergeResult MergeDataAndStartSyncing( |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 60 const tracked_objects::Location& from_here, | 75 const tracked_objects::Location& from_here, |
| 61 const SyncChangeList& change_list) OVERRIDE = 0; | 76 const SyncChangeList& change_list) OVERRIDE = 0; |
| 62 | 77 |
| 63 protected: | 78 protected: |
| 64 virtual ~SyncableService(); | 79 virtual ~SyncableService(); |
| 65 }; | 80 }; |
| 66 | 81 |
| 67 } // namespace syncer | 82 } // namespace syncer |
| 68 | 83 |
| 69 #endif // SYNC_API_SYNCABLE_SERVICE_H_ | 84 #endif // SYNC_API_SYNCABLE_SERVICE_H_ |
| OLD | NEW |