Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: components/sync/engine_impl/js_mutation_event_observer.h

Issue 2915453002: Deprecate NonThreadSafe in components/sync in favor of SequenceChecker. (Closed)
Patch Set: fix comment Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ 6 #define COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/sequence_checker.h"
16 #include "components/sync/base/weak_handle.h" 16 #include "components/sync/base/weak_handle.h"
17 #include "components/sync/engine/sync_manager.h" 17 #include "components/sync/engine/sync_manager.h"
18 #include "components/sync/syncable/transaction_observer.h" 18 #include "components/sync/syncable/transaction_observer.h"
19 19
20 namespace tracked_objects { 20 namespace tracked_objects {
21 class Location; 21 class Location;
22 } // namespace tracked_objects 22 } // namespace tracked_objects
23 23
24 namespace syncer { 24 namespace syncer {
25 25
26 class JsEventDetails; 26 class JsEventDetails;
27 class JsEventHandler; 27 class JsEventHandler;
28 28
29 // Observes all change- and transaction-related events and routes a 29 // Observes all change- and transaction-related events and routes a
30 // summarized version to a JsEventHandler. 30 // summarized version to a JsEventHandler.
31 class JsMutationEventObserver : public SyncManager::ChangeObserver, 31 class JsMutationEventObserver : public SyncManager::ChangeObserver,
32 public syncable::TransactionObserver, 32 public syncable::TransactionObserver {
33 public base::NonThreadSafe {
34 public: 33 public:
35 JsMutationEventObserver(); 34 JsMutationEventObserver();
36 35
37 ~JsMutationEventObserver() override; 36 ~JsMutationEventObserver() override;
38 37
39 base::WeakPtr<JsMutationEventObserver> AsWeakPtr(); 38 base::WeakPtr<JsMutationEventObserver> AsWeakPtr();
40 39
41 void InvalidateWeakPtrs(); 40 void InvalidateWeakPtrs();
42 41
43 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler); 42 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler);
44 43
45 // SyncManager::ChangeObserver implementation. 44 // SyncManager::ChangeObserver implementation.
46 void OnChangesApplied(ModelType model_type, 45 void OnChangesApplied(ModelType model_type,
47 int64_t write_transaction_id, 46 int64_t write_transaction_id,
48 const ImmutableChangeRecordList& changes) override; 47 const ImmutableChangeRecordList& changes) override;
49 void OnChangesComplete(ModelType model_type) override; 48 void OnChangesComplete(ModelType model_type) override;
50 49
51 // syncable::TransactionObserver implementation. 50 // syncable::TransactionObserver implementation.
52 void OnTransactionWrite( 51 void OnTransactionWrite(
53 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, 52 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
54 ModelTypeSet models_with_changes) override; 53 ModelTypeSet models_with_changes) override;
55 54
56 private: 55 private:
57 WeakHandle<JsEventHandler> event_handler_; 56 WeakHandle<JsEventHandler> event_handler_;
58 57
59 void HandleJsEvent(const tracked_objects::Location& from_here, 58 void HandleJsEvent(const tracked_objects::Location& from_here,
60 const std::string& name, 59 const std::string& name,
61 const JsEventDetails& details); 60 const JsEventDetails& details);
62 61
62 SEQUENCE_CHECKER(sequence_checker_);
63
63 base::WeakPtrFactory<JsMutationEventObserver> weak_ptr_factory_; 64 base::WeakPtrFactory<JsMutationEventObserver> weak_ptr_factory_;
64 65
65 DISALLOW_COPY_AND_ASSIGN(JsMutationEventObserver); 66 DISALLOW_COPY_AND_ASSIGN(JsMutationEventObserver);
66 }; 67 };
67 68
68 } // namespace syncer 69 } // namespace syncer
69 70
70 #endif // COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_ 71 #endif // COMPONENTS_SYNC_ENGINE_IMPL_JS_MUTATION_EVENT_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698