| OLD | NEW |
| (Empty) |
| 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 COMPONENTS_SYNC_CORE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ | |
| 6 #define COMPONENTS_SYNC_CORE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "base/threading/non_thread_safe.h" | |
| 16 #include "components/sync/base/weak_handle.h" | |
| 17 #include "components/sync/core/sync_manager.h" | |
| 18 #include "components/sync/syncable/transaction_observer.h" | |
| 19 | |
| 20 namespace tracked_objects { | |
| 21 class Location; | |
| 22 } // namespace tracked_objects | |
| 23 | |
| 24 namespace syncer { | |
| 25 | |
| 26 class JsEventDetails; | |
| 27 class JsEventHandler; | |
| 28 | |
| 29 // Observes all change- and transaction-related events and routes a | |
| 30 // summarized version to a JsEventHandler. | |
| 31 class JsMutationEventObserver : public SyncManager::ChangeObserver, | |
| 32 public syncable::TransactionObserver, | |
| 33 public base::NonThreadSafe { | |
| 34 public: | |
| 35 JsMutationEventObserver(); | |
| 36 | |
| 37 ~JsMutationEventObserver() override; | |
| 38 | |
| 39 base::WeakPtr<JsMutationEventObserver> AsWeakPtr(); | |
| 40 | |
| 41 void InvalidateWeakPtrs(); | |
| 42 | |
| 43 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler); | |
| 44 | |
| 45 // SyncManager::ChangeObserver implementation. | |
| 46 void OnChangesApplied(ModelType model_type, | |
| 47 int64_t write_transaction_id, | |
| 48 const ImmutableChangeRecordList& changes) override; | |
| 49 void OnChangesComplete(ModelType model_type) override; | |
| 50 | |
| 51 // syncable::TransactionObserver implementation. | |
| 52 void OnTransactionWrite( | |
| 53 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
| 54 ModelTypeSet models_with_changes) override; | |
| 55 | |
| 56 private: | |
| 57 WeakHandle<JsEventHandler> event_handler_; | |
| 58 | |
| 59 void HandleJsEvent(const tracked_objects::Location& from_here, | |
| 60 const std::string& name, | |
| 61 const JsEventDetails& details); | |
| 62 | |
| 63 base::WeakPtrFactory<JsMutationEventObserver> weak_ptr_factory_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(JsMutationEventObserver); | |
| 66 }; | |
| 67 | |
| 68 } // namespace syncer | |
| 69 | |
| 70 #endif // COMPONENTS_SYNC_CORE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ | |
| OLD | NEW |