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

Side by Side Diff: components/sync/driver/change_processor.h

Issue 2508003002: [Sync] Move ChangeProcessor to model/. (Closed)
Patch Set: Created 4 years, 1 month 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 | « components/sync/BUILD.gn ('k') | components/sync/driver/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 2014 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_DRIVER_CHANGE_PROCESSOR_H_
6 #define COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "components/sync/model/data_type_error_handler.h"
14 #include "components/sync/syncable/base_transaction.h"
15 #include "components/sync/syncable/change_record.h"
16 #include "components/sync/syncable/user_share.h"
17
18 namespace syncer {
19
20 class ModelAssociator;
21 class UnrecoverableErrorHandler;
22
23 // An interface used to apply changes from the sync model to the browser's
24 // native model. This does not currently distinguish between model data types.
25 class ChangeProcessor {
26 public:
27 explicit ChangeProcessor(std::unique_ptr<DataTypeErrorHandler> error_handler);
28 virtual ~ChangeProcessor();
29
30 // Call when the processor should accept changes from either provided model
31 // and apply them to the other. Both the native model and sync_api are
32 // expected to be initialized and loaded. You must have set a valid
33 // ModelAssociator and UnrecoverableErrorHandler before using this method, and
34 // the two models should be associated w.r.t the ModelAssociator provided.
35 void Start(UserShare* share_handle);
36
37 // Changes have been applied to the backend model and are ready to be
38 // applied to the frontend model.
39 virtual void ApplyChangesFromSyncModel(
40 const BaseTransaction* trans,
41 int64_t model_version,
42 const ImmutableChangeRecordList& changes) = 0;
43
44 // The changes found in ApplyChangesFromSyncModel may be too slow to be
45 // performed while holding a [Read/Write]Transaction lock or may interact
46 // with another thread, which might itself be waiting on the transaction lock,
47 // putting us at risk of deadlock.
48 // This function is called once the transactional lock is released and it is
49 // safe to perform inter-thread or slow I/O operations. Note that not all
50 // datatypes need this, so we provide an empty default version.
51 virtual void CommitChangesFromSyncModel();
52
53 protected:
54 // These methods are invoked by Start() and Stop() to do
55 // implementation-specific work.
56 virtual void StartImpl() = 0;
57
58 DataTypeErrorHandler* error_handler() const;
59 virtual UserShare* share_handle() const;
60
61 private:
62 std::unique_ptr<DataTypeErrorHandler> error_handler_;
63
64 // The sync model we are processing changes from.
65 UserShare* share_handle_;
66
67 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor);
68 };
69
70 } // namespace syncer
71
72 #endif // COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/driver/change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698