OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_TEST_TEST_TRANSACTION_OBSERVER_H_ | 5 #ifndef SYNC_TEST_TEST_TRANSACTION_OBSERVER_H_ |
6 #define SYNC_TEST_TEST_TRANSACTION_OBSERVER_H_ | 6 #define SYNC_TEST_TEST_TRANSACTION_OBSERVER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "sync/internal_api/public/base/model_type.h" | 9 #include "sync/internal_api/public/base/model_type.h" |
10 #include "sync/syncable/transaction_observer.h" | 10 #include "sync/syncable/transaction_observer.h" |
11 #include "sync/syncable/write_transaction_info.h" | 11 #include "sync/syncable/write_transaction_info.h" |
12 | 12 |
13 namespace syncer { | 13 namespace syncer { |
14 namespace syncable { | 14 namespace syncable { |
15 | 15 |
16 // This class acts as a TransactionObserver for the syncable::Directory. | 16 // This class acts as a TransactionObserver for the syncable::Directory. |
17 // It gathers information that is useful for writing test assertions. | 17 // It gathers information that is useful for writing test assertions. |
18 class TestTransactionObserver : | 18 class TestTransactionObserver : |
19 public base::SupportsWeakPtr<TestTransactionObserver>, | 19 public base::SupportsWeakPtr<TestTransactionObserver>, |
20 public TransactionObserver { | 20 public TransactionObserver { |
21 public: | 21 public: |
22 TestTransactionObserver(); | 22 TestTransactionObserver(); |
23 virtual ~TestTransactionObserver(); | 23 virtual ~TestTransactionObserver(); |
24 virtual void OnTransactionWrite( | 24 virtual void OnTransactionWrite( |
25 const ImmutableWriteTransactionInfo& write_transaction_info, | 25 const ImmutableWriteTransactionInfo& write_transaction_info, |
26 ModelTypeSet models_with_changes) OVERRIDE; | 26 ModelTypeSet models_with_changes) override; |
27 | 27 |
28 // Returns the number of transactions observed. | 28 // Returns the number of transactions observed. |
29 // | 29 // |
30 // Transactions are generated only when meaningful changes are made. For most | 30 // Transactions are generated only when meaningful changes are made. For most |
31 // testing purposes, you may assume that this counts the number of syncer | 31 // testing purposes, you may assume that this counts the number of syncer |
32 // nudges generated. | 32 // nudges generated. |
33 int transactions_observed(); | 33 int transactions_observed(); |
34 | 34 |
35 private: | 35 private: |
36 DISALLOW_COPY_AND_ASSIGN(TestTransactionObserver); | 36 DISALLOW_COPY_AND_ASSIGN(TestTransactionObserver); |
37 | 37 |
38 int transactions_observed_; | 38 int transactions_observed_; |
39 }; | 39 }; |
40 | 40 |
41 } // namespace syncable | 41 } // namespace syncable |
42 } // namespace syncer | 42 } // namespace syncer |
43 | 43 |
44 | 44 |
45 #endif // SYNC_TEST_TEST_TRANSACTION_OBSERVER_H_ | 45 #endif // SYNC_TEST_TEST_TRANSACTION_OBSERVER_H_ |
OLD | NEW |