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