• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SYNCABLE_DIRECTORY_CHANGE_DELEGATE_H_
6 #define SYNC_SYNCABLE_DIRECTORY_CHANGE_DELEGATE_H_
7 
8 #include "sync/base/sync_export.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/syncable/write_transaction_info.h"
11 
12 namespace syncer {
13 namespace syncable {
14 
15 // This is an interface for listening to directory change events, triggered by
16 // the releasing of the syncable transaction. The delegate performs work to
17 // 1. Calculate changes, depending on the source of the transaction
18 //    (HandleCalculateChangesChangeEventFromSyncer/Syncapi).
19 // 2. Perform final work while the transaction is held
20 //    (HandleTransactionEndingChangeEvent).
21 // 3. Perform any work that should be done after the transaction is released.
22 //    (HandleTransactionCompleteChangeEvent).
23 //
24 // Note that these methods may be called on *any* thread.
25 class SYNC_EXPORT_PRIVATE DirectoryChangeDelegate {
26  public:
27   // Returns the handles of changed entries in |entry_changed|.
28   virtual void HandleCalculateChangesChangeEventFromSyncApi(
29       const ImmutableWriteTransactionInfo& write_transaction_info,
30       BaseTransaction* trans,
31       std::vector<int64>* entries_changed) = 0;
32   // Returns the handles of changed entries in |entry_changed|.
33   virtual void HandleCalculateChangesChangeEventFromSyncer(
34       const ImmutableWriteTransactionInfo& write_transaction_info,
35       BaseTransaction* trans,
36       std::vector<int64>* entries_changed) = 0;
37   // Must return the set of all ModelTypes that were modified in the
38   // transaction.
39   virtual ModelTypeSet HandleTransactionEndingChangeEvent(
40       const ImmutableWriteTransactionInfo& write_transaction_info,
41       BaseTransaction* trans) = 0;
42   virtual void HandleTransactionCompleteChangeEvent(
43       ModelTypeSet models_with_changes) = 0;
44  protected:
~DirectoryChangeDelegate()45   virtual ~DirectoryChangeDelegate() {}
46 };
47 
48 }  // namespace syncable
49 }  // namespace syncer
50 
51 #endif  // SYNC_SYNCABLE_DIRECTORY_CHANGE_DELEGATE_H_
52