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

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

Issue 2401223002: [Sync] Renaming sync/api* to sync/model*. (Closed)
Patch Set: Missed a comment in a DEPS file, and rebasing. Created 4 years, 2 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
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 COMPONENTS_SYNC_API_SYNCABLE_SERVICE_H_
6 #define COMPONENTS_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 "components/sync/api/attachments/attachment_store.h"
15 #include "components/sync/api/sync_change_processor.h"
16 #include "components/sync/api/sync_data.h"
17 #include "components/sync/api/sync_error.h"
18 #include "components/sync/api/sync_merge_result.h"
19 #include "components/sync/base/model_type.h"
20
21 namespace syncer {
22
23 class AttachmentService;
24 class SyncErrorFactory;
25
26 // TODO(zea): remove SupportsWeakPtr in favor of having all SyncableService
27 // implementers provide a way of getting a weak pointer to themselves.
28 // See crbug.com/100114.
29 class SyncableService : 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;
40
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 std::unique_ptr<SyncChangeProcessor> sync_processor,
54 std::unique_ptr<SyncErrorFactory> error_handler) = 0;
55
56 // Stop syncing the specified type and reset state.
57 virtual void StopSyncing(ModelType type) = 0;
58
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 SyncError ProcessSyncChanges(const tracked_objects::Location& from_here,
65 const SyncChangeList& change_list) override = 0;
66
67 // Returns AttachmentStore for use by sync when uploading or downloading
68 // attachments.
69 // GetAttachmentStoreForSync is called right before MergeDataAndStartSyncing.
70 // If at that time GetAttachmentStoreForSync returns NULL then datatype is
71 // considered not using attachments and all attempts to upload/download
72 // attachments will fail. Default implementation returns NULL. Datatype that
73 // uses sync attachments should create attachment store, implement
74 // GetAttachmentStoreForSync to return result of
75 // AttachmentStore::CreateAttachmentStoreForSync() from attachment store
76 // object.
77 virtual std::unique_ptr<AttachmentStoreForSync> GetAttachmentStoreForSync();
78
79 // Called by sync to provide AttachmentService to be used to download
80 // attachments.
81 // SetAttachmentService is called after GetAttachmentStore and right before
82 // MergeDataAndStartSyncing and only if GetAttachmentStore has returned a
83 // non-NULL store instance. Default implementation does nothing.
84 // Datatype that uses attachments must take ownerhip of the provided
85 // AttachmentService instance.
86 virtual void SetAttachmentService(
87 std::unique_ptr<AttachmentService> attachment_service);
88
89 protected:
90 ~SyncableService() override;
91 };
92
93 } // namespace syncer
94
95 #endif // COMPONENTS_SYNC_API_SYNCABLE_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync/api/sync_merge_result_unittest.cc ('k') | components/sync/api/syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698