OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
17 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
18 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
19 #include "google_apis/gaia/oauth2_token_service.h" | 20 #include "google_apis/gaia/oauth2_token_service.h" |
20 #include "sync/base/sync_export.h" | 21 #include "sync/base/sync_export.h" |
21 #include "sync/internal_api/public/base/invalidation_interface.h" | 22 #include "sync/internal_api/public/base/invalidation_interface.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // 2. Updates to existing items with synced parents & predecessors. | 111 // 2. Updates to existing items with synced parents & predecessors. |
111 // 3. New items with synced parents & predecessors. | 112 // 3. New items with synced parents & predecessors. |
112 // 4. Items with parents & predecessors in |changes|. | 113 // 4. Items with parents & predecessors in |changes|. |
113 // 5. Repeat #4 until all items are in |changes|. | 114 // 5. Repeat #4 until all items are in |changes|. |
114 // | 115 // |
115 // Thus, an implementation of OnChangesApplied should be able to | 116 // Thus, an implementation of OnChangesApplied should be able to |
116 // process the change records in the order without having to worry about | 117 // process the change records in the order without having to worry about |
117 // forward dependencies. But since deletions come before reparent | 118 // forward dependencies. But since deletions come before reparent |
118 // operations, a delete may temporarily orphan a node that is | 119 // operations, a delete may temporarily orphan a node that is |
119 // updated later in the list. | 120 // updated later in the list. |
120 virtual void OnChangesApplied( | 121 virtual void OnChangesApplied(ModelType model_type, |
121 ModelType model_type, | 122 int64_t model_version, |
122 int64 model_version, | 123 const BaseTransaction* trans, |
123 const BaseTransaction* trans, | 124 const ImmutableChangeRecordList& changes) = 0; |
124 const ImmutableChangeRecordList& changes) = 0; | |
125 | 125 |
126 // OnChangesComplete gets called when the TransactionComplete event is | 126 // OnChangesComplete gets called when the TransactionComplete event is |
127 // posted (after OnChangesApplied finishes), after the transaction lock | 127 // posted (after OnChangesApplied finishes), after the transaction lock |
128 // and the change channel mutex are released. | 128 // and the change channel mutex are released. |
129 // | 129 // |
130 // The purpose of this function is to support processors that require | 130 // The purpose of this function is to support processors that require |
131 // split-transactions changes. For example, if a model processor wants to | 131 // split-transactions changes. For example, if a model processor wants to |
132 // perform blocking I/O due to a change, it should calculate the changes | 132 // perform blocking I/O due to a change, it should calculate the changes |
133 // while holding the transaction lock (from within OnChangesApplied), buffer | 133 // while holding the transaction lock (from within OnChangesApplied), buffer |
134 // those changes, let the transaction fall out of scope, and then commit | 134 // those changes, let the transaction fall out of scope, and then commit |
(...skipping 19 matching lines...) Expand all Loading... |
154 // TODO(sync, long-term): Ideally, ChangeDelegate/Observer would | 154 // TODO(sync, long-term): Ideally, ChangeDelegate/Observer would |
155 // be passed a transformed version of EntryKernelMutation instead | 155 // be passed a transformed version of EntryKernelMutation instead |
156 // of a transaction that would have to be used to look up the | 156 // of a transaction that would have to be used to look up the |
157 // changed nodes. That is, ChangeDelegate::OnChangesApplied() | 157 // changed nodes. That is, ChangeDelegate::OnChangesApplied() |
158 // would still be called under the transaction, but all the needed | 158 // would still be called under the transaction, but all the needed |
159 // data will be passed down. | 159 // data will be passed down. |
160 // | 160 // |
161 // Even more ideally, we would have sync semantics such that we'd | 161 // Even more ideally, we would have sync semantics such that we'd |
162 // be able to apply changes without being under a transaction. | 162 // be able to apply changes without being under a transaction. |
163 // But that's a ways off... | 163 // But that's a ways off... |
164 virtual void OnChangesApplied( | 164 virtual void OnChangesApplied(ModelType model_type, |
165 ModelType model_type, | 165 int64_t write_transaction_id, |
166 int64 write_transaction_id, | 166 const ImmutableChangeRecordList& changes) = 0; |
167 const ImmutableChangeRecordList& changes) = 0; | |
168 | 167 |
169 virtual void OnChangesComplete(ModelType model_type) = 0; | 168 virtual void OnChangesComplete(ModelType model_type) = 0; |
170 | 169 |
171 protected: | 170 protected: |
172 virtual ~ChangeObserver(); | 171 virtual ~ChangeObserver(); |
173 }; | 172 }; |
174 | 173 |
175 // An interface the embedding application implements to receive | 174 // An interface the embedding application implements to receive |
176 // notifications from the SyncManager. Register an observer via | 175 // notifications from the SyncManager. Register an observer via |
177 // SyncManager::AddObserver. All methods are called only on the | 176 // SyncManager::AddObserver. All methods are called only on the |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // | 398 // |
400 // This is an asynchronous operation that requires interaction with the sync | 399 // This is an asynchronous operation that requires interaction with the sync |
401 // server. The operation will automatically be retried with backoff until it | 400 // server. The operation will automatically be retried with backoff until it |
402 // completes successfully or sync is shutdown. | 401 // completes successfully or sync is shutdown. |
403 virtual void ClearServerData(const ClearServerDataCallback& callback) = 0; | 402 virtual void ClearServerData(const ClearServerDataCallback& callback) = 0; |
404 }; | 403 }; |
405 | 404 |
406 } // namespace syncer | 405 } // namespace syncer |
407 | 406 |
408 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 407 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
OLD | NEW |