Fix location of supervised user token file on non-chromeos.
[chromium-blink-merge.git] / sync / api / syncable_service.h
blob81b6018b32afb23a18d939fd8078a528dcf76def
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
3 // found in the LICENSE file.
5 #ifndef SYNC_API_SYNCABLE_SERVICE_H_
6 #define SYNC_API_SYNCABLE_SERVICE_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "sync/api/sync_change_processor.h"
15 #include "sync/api/sync_data.h"
16 #include "sync/api/sync_error.h"
17 #include "sync/api/sync_merge_result.h"
18 #include "sync/base/sync_export.h"
19 #include "sync/internal_api/public/base/model_type.h"
21 namespace syncer {
23 class SyncErrorFactory;
25 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService
26 // implementers provide a way of getting a weak pointer to themselves.
27 // See crbug.com/100114.
28 class SYNC_EXPORT SyncableService
29 : public SyncChangeProcessor,
30 public base::SupportsWeakPtr<SyncableService> {
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;
41 // Informs the service to begin syncing the specified synced datatype |type|.
42 // The service should then merge |initial_sync_data| into it's local data,
43 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the
44 // two. After this, the SyncableService's local data should match the server
45 // data, and the service should be ready to receive and process any further
46 // SyncChange's as they occur.
47 // Returns: a SyncMergeResult whose error field reflects whether an error
48 // was encountered while merging the two models. The merge result
49 // may also contain optional merge statistics.
50 virtual SyncMergeResult MergeDataAndStartSyncing(
51 ModelType type,
52 const SyncDataList& initial_sync_data,
53 scoped_ptr<SyncChangeProcessor> sync_processor,
54 scoped_ptr<SyncErrorFactory> error_handler) = 0;
56 // Stop syncing the specified type and reset state.
57 virtual void StopSyncing(ModelType type) = 0;
59 // SyncChangeProcessor interface.
60 // Process a list of new SyncChanges and update the local data as necessary.
61 // Returns: A default SyncError (IsSet() == false) if no errors were
62 // encountered, and a filled SyncError (IsSet() == true)
63 // otherwise.
64 virtual SyncError ProcessSyncChanges(
65 const tracked_objects::Location& from_here,
66 const SyncChangeList& change_list) OVERRIDE = 0;
68 protected:
69 virtual ~SyncableService();
72 } // namespace syncer
74 #endif // SYNC_API_SYNCABLE_SERVICE_H_