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

Side by Side Diff: sync/api/sync_change_processor.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_change.cc ('k') | sync/api/sync_change_processor.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_SYNC_CHANGE_PROCESSOR_H_
6 #define SYNC_API_SYNC_CHANGE_PROCESSOR_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "sync/api/sync_data.h"
12 #include "sync/api/sync_error.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/internal_api/public/base/model_type.h"
15
16 namespace tracked_objects {
17 class Location;
18 } // namespace tracked_objects
19
20 namespace syncer {
21
22 class SyncChange;
23
24 typedef std::vector<SyncChange> SyncChangeList;
25
26 // An interface for services that handle receiving SyncChanges.
27 class SYNC_EXPORT SyncChangeProcessor {
28 public:
29 // Whether a context change should force a datatype refresh or not.
30 enum ContextRefreshStatus { NO_REFRESH, REFRESH_NEEDED };
31 typedef base::Callback<void(const SyncData&)> GetSyncDataCallback;
32
33 SyncChangeProcessor();
34 virtual ~SyncChangeProcessor();
35
36 // Process a list of SyncChanges.
37 // Returns: A default SyncError (IsSet() == false) if no errors were
38 // encountered, and a filled SyncError (IsSet() == true)
39 // otherwise.
40 // Inputs:
41 // |from_here|: allows tracking of where sync changes originate.
42 // |change_list|: is the list of sync changes in need of processing.
43 virtual SyncError ProcessSyncChanges(
44 const tracked_objects::Location& from_here,
45 const SyncChangeList& change_list) = 0;
46
47 // Fills a list of SyncData. This should create an up to date representation
48 // of all the data known to the ChangeProcessor for |datatype|, and
49 // should match/be a subset of the server's view of that datatype.
50 //
51 // WARNING: This can be a potentially slow & memory intensive operation and
52 // should only be used when absolutely necessary / sparingly.
53 virtual SyncDataList GetAllSyncData(ModelType type) const = 0;
54
55 // Retrieves the SyncData identified by |type| and |sync_tag| and invokes
56 // |callback| asynchronously. If no such SyncData exists locally, IsValid on
57 // the SyncData passed to |callback| will return false.
58 //
59 // This is an asynchronous local operation that may result in disk IO.
60 //
61 // Refer to sync_data.h for a description of |sync_tag|.
62 //
63 // TODO(maniscalco): N.B. this method should really be pure virtual. An
64 // implentation is provided here just to verify that everything compiles.
65 // Update this method to be pure virtual (bug 353300).
66 virtual void GetSyncData(const ModelType& type,
67 const std::string& sync_tag,
68 const GetSyncDataCallback& callback) const {}
69
70 // Updates the context for |type|, triggering an optional context refresh.
71 // Default implementation does nothing. A type's context is a per-client blob
72 // that can affect all SyncData sent to/from the server, much like a cookie.
73 // TODO(zea): consider pulling the refresh logic into a separate method
74 // unrelated to datatype implementations.
75 virtual syncer::SyncError UpdateDataTypeContext(
76 ModelType type,
77 ContextRefreshStatus refresh_status,
78 const std::string& context);
79 };
80
81 } // namespace syncer
82
83 #endif // SYNC_API_SYNC_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « sync/api/sync_change.cc ('k') | sync/api/sync_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698