OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ |
6 #define COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ | 6 #define COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/sync_driver/data_type_error_handler.h" | |
12 #include "sync/internal_api/public/base_transaction.h" | 11 #include "sync/internal_api/public/base_transaction.h" |
13 #include "sync/internal_api/public/change_record.h" | 12 #include "sync/internal_api/public/change_record.h" |
14 #include "sync/internal_api/public/user_share.h" | 13 #include "sync/internal_api/public/user_share.h" |
15 | 14 |
16 namespace syncer { | 15 namespace syncer { |
| 16 class DataTypeErrorHandler; |
17 class UnrecoverableErrorHandler; | 17 class UnrecoverableErrorHandler; |
18 } // namespace syncer | 18 } // namespace syncer |
19 | 19 |
20 namespace sync_driver { | 20 namespace sync_driver { |
21 | 21 |
22 class ModelAssociator; | 22 class ModelAssociator; |
23 | 23 |
24 // An interface used to apply changes from the sync model to the browser's | 24 // An interface used to apply changes from the sync model to the browser's |
25 // native model. This does not currently distinguish between model data types. | 25 // native model. This does not currently distinguish between model data types. |
26 class ChangeProcessor { | 26 class ChangeProcessor { |
27 public: | 27 public: |
28 explicit ChangeProcessor(DataTypeErrorHandler* error_handler); | 28 explicit ChangeProcessor(syncer::DataTypeErrorHandler* error_handler); |
29 virtual ~ChangeProcessor(); | 29 virtual ~ChangeProcessor(); |
30 | 30 |
31 // Call when the processor should accept changes from either provided model | 31 // Call when the processor should accept changes from either provided model |
32 // and apply them to the other. Both the native model and sync_api are | 32 // and apply them to the other. Both the native model and sync_api are |
33 // expected to be initialized and loaded. You must have set a valid | 33 // expected to be initialized and loaded. You must have set a valid |
34 // ModelAssociator and UnrecoverableErrorHandler before using this method, and | 34 // ModelAssociator and UnrecoverableErrorHandler before using this method, and |
35 // the two models should be associated w.r.t the ModelAssociator provided. | 35 // the two models should be associated w.r.t the ModelAssociator provided. |
36 void Start(syncer::UserShare* share_handle); | 36 void Start(syncer::UserShare* share_handle); |
37 | 37 |
38 // Changes have been applied to the backend model and are ready to be | 38 // Changes have been applied to the backend model and are ready to be |
(...skipping 10 matching lines...) Expand all Loading... |
49 // This function is called once the transactional lock is released and it is | 49 // This function is called once the transactional lock is released and it is |
50 // safe to perform inter-thread or slow I/O operations. Note that not all | 50 // safe to perform inter-thread or slow I/O operations. Note that not all |
51 // datatypes need this, so we provide an empty default version. | 51 // datatypes need this, so we provide an empty default version. |
52 virtual void CommitChangesFromSyncModel(); | 52 virtual void CommitChangesFromSyncModel(); |
53 | 53 |
54 protected: | 54 protected: |
55 // These methods are invoked by Start() and Stop() to do | 55 // These methods are invoked by Start() and Stop() to do |
56 // implementation-specific work. | 56 // implementation-specific work. |
57 virtual void StartImpl() = 0; | 57 virtual void StartImpl() = 0; |
58 | 58 |
59 DataTypeErrorHandler* error_handler() const; | 59 syncer::DataTypeErrorHandler* error_handler() const; |
60 virtual syncer::UserShare* share_handle() const; | 60 virtual syncer::UserShare* share_handle() const; |
61 | 61 |
62 private: | 62 private: |
63 DataTypeErrorHandler* error_handler_; // Guaranteed to outlive us. | 63 syncer::DataTypeErrorHandler* error_handler_; // Guaranteed to outlive us. |
64 | 64 |
65 // The sync model we are processing changes from. | 65 // The sync model we are processing changes from. |
66 syncer::UserShare* share_handle_; | 66 syncer::UserShare* share_handle_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor); | 68 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace sync_driver | 71 } // namespace sync_driver |
72 | 72 |
73 #endif // COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ | 73 #endif // COMPONENTS_SYNC_DRIVER_CHANGE_PROCESSOR_H_ |
OLD | NEW |