Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: sync/api/syncable_service.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/api/sync_merge_result_unittest.cc ('k') | sync/api/syncable_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef SYNC_API_SYNCABLE_SERVICE_H_
6 #define SYNC_API_SYNCABLE_SERVICE_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h"
14 #include "sync/api/attachments/attachment_store.h"
15 #include "sync/api/sync_change_processor.h"
16 #include "sync/api/sync_data.h"
17 #include "sync/api/sync_error.h"
18 #include "sync/api/sync_merge_result.h"
19 #include "sync/base/sync_export.h"
20 #include "sync/internal_api/public/base/model_type.h"
21
22 namespace syncer {
23
24 class AttachmentService;
25 class SyncErrorFactory;
26
27 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService
28 // implementers provide a way of getting a weak pointer to themselves.
29 // See crbug.com/100114.
30 class SYNC_EXPORT SyncableService
31 : public SyncChangeProcessor,
32 public base::SupportsWeakPtr<SyncableService> {
33 public:
34 // A StartSyncFlare is useful when your SyncableService has a need for sync
35 // to start ASAP, typically because a local change event has occurred but
36 // MergeDataAndStartSyncing hasn't been called yet, meaning you don't have a
37 // SyncChangeProcessor. The sync subsystem will respond soon after invoking
38 // Run() on your flare by calling MergeDataAndStartSyncing. The ModelType
39 // parameter is included so that the recieving end can track usage and timing
40 // statistics, make optimizations or tradeoffs by type, etc.
41 typedef base::Callback<void(ModelType)> StartSyncFlare;
42
43 // Informs the service to begin syncing the specified synced datatype |type|.
44 // The service should then merge |initial_sync_data| into it's local data,
45 // calling |sync_processor|'s ProcessSyncChanges as necessary to reconcile the
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
48 // SyncChange's as they occur.
49 // Returns: a SyncMergeResult whose error field reflects whether an error
50 // was encountered while merging the two models. The merge result
51 // may also contain optional merge statistics.
52 virtual SyncMergeResult MergeDataAndStartSyncing(
53 ModelType type,
54 const SyncDataList& initial_sync_data,
55 std::unique_ptr<SyncChangeProcessor> sync_processor,
56 std::unique_ptr<SyncErrorFactory> error_handler) = 0;
57
58 // Stop syncing the specified type and reset state.
59 virtual void StopSyncing(ModelType type) = 0;
60
61 // SyncChangeProcessor interface.
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
64 // encountered, and a filled SyncError (IsSet() == true)
65 // otherwise.
66 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here,
67 const SyncChangeList& change_list) override = 0;
68
69 // Returns AttachmentStore for use by sync when uploading or downloading
70 // attachments.
71 // GetAttachmentStoreForSync is called right before MergeDataAndStartSyncing.
72 // If at that time GetAttachmentStoreForSync returns NULL then datatype is
73 // considered not using attachments and all attempts to upload/download
74 // attachments will fail. Default implementation returns NULL. Datatype that
75 // uses sync attachments should create attachment store, implement
76 // GetAttachmentStoreForSync to return result of
77 // AttachmentStore::CreateAttachmentStoreForSync() from attachment store
78 // object.
79 virtual std::unique_ptr<AttachmentStoreForSync> GetAttachmentStoreForSync();
80
81 // Called by sync to provide AttachmentService to be used to download
82 // attachments.
83 // SetAttachmentService is called after GetAttachmentStore and right before
84 // MergeDataAndStartSyncing and only if GetAttachmentStore has returned a
85 // non-NULL store instance. Default implementation does nothing.
86 // Datatype that uses attachments must take ownerhip of the provided
87 // AttachmentService instance.
88 virtual void SetAttachmentService(
89 std::unique_ptr<AttachmentService> attachment_service);
90
91 protected:
92 ~SyncableService() override;
93 };
94
95 } // namespace syncer
96
97 #endif // SYNC_API_SYNCABLE_SERVICE_H_
OLDNEW
« no previous file with comments | « sync/api/sync_merge_result_unittest.cc ('k') | sync/api/syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698