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