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

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

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 (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 #include "components/sync/engine_impl/js_mutation_event_observer.h" 5 #include "components/sync/engine_impl/js_mutation_event_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "components/sync/js/js_event_details.h" 13 #include "components/sync/js/js_event_details.h"
14 #include "components/sync/js/js_event_handler.h" 14 #include "components/sync/js/js_event_handler.h"
15 15
16 namespace syncer { 16 namespace syncer {
17 17
18 JsMutationEventObserver::JsMutationEventObserver() : weak_ptr_factory_(this) {} 18 JsMutationEventObserver::JsMutationEventObserver() : weak_ptr_factory_(this) {}
19 19
20 JsMutationEventObserver::~JsMutationEventObserver() { 20 JsMutationEventObserver::~JsMutationEventObserver() {
21 DCHECK(CalledOnValidThread()); 21 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
22 } 22 }
23 23
24 base::WeakPtr<JsMutationEventObserver> JsMutationEventObserver::AsWeakPtr() { 24 base::WeakPtr<JsMutationEventObserver> JsMutationEventObserver::AsWeakPtr() {
25 return weak_ptr_factory_.GetWeakPtr(); 25 return weak_ptr_factory_.GetWeakPtr();
26 } 26 }
27 27
28 void JsMutationEventObserver::InvalidateWeakPtrs() { 28 void JsMutationEventObserver::InvalidateWeakPtrs() {
29 weak_ptr_factory_.InvalidateWeakPtrs(); 29 weak_ptr_factory_.InvalidateWeakPtrs();
30 } 30 }
31 31
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return; 75 return;
76 } 76 }
77 base::DictionaryValue details; 77 base::DictionaryValue details;
78 details.SetString("modelType", ModelTypeToString(model_type)); 78 details.SetString("modelType", ModelTypeToString(model_type));
79 HandleJsEvent(FROM_HERE, "onChangesComplete", JsEventDetails(&details)); 79 HandleJsEvent(FROM_HERE, "onChangesComplete", JsEventDetails(&details));
80 } 80 }
81 81
82 void JsMutationEventObserver::OnTransactionWrite( 82 void JsMutationEventObserver::OnTransactionWrite(
83 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, 83 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
84 ModelTypeSet models_with_changes) { 84 ModelTypeSet models_with_changes) {
85 DCHECK(CalledOnValidThread()); 85 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
86 if (!event_handler_.IsInitialized()) { 86 if (!event_handler_.IsInitialized()) {
87 return; 87 return;
88 } 88 }
89 base::DictionaryValue details; 89 base::DictionaryValue details;
90 details.Set("writeTransactionInfo", 90 details.Set("writeTransactionInfo",
91 write_transaction_info.Get().ToValue(kChangeLimit)); 91 write_transaction_info.Get().ToValue(kChangeLimit));
92 details.Set("modelsWithChanges", ModelTypeSetToValue(models_with_changes)); 92 details.Set("modelsWithChanges", ModelTypeSetToValue(models_with_changes));
93 HandleJsEvent(FROM_HERE, "onTransactionWrite", JsEventDetails(&details)); 93 HandleJsEvent(FROM_HERE, "onTransactionWrite", JsEventDetails(&details));
94 } 94 }
95 95
96 void JsMutationEventObserver::HandleJsEvent( 96 void JsMutationEventObserver::HandleJsEvent(
97 const tracked_objects::Location& from_here, 97 const tracked_objects::Location& from_here,
98 const std::string& name, 98 const std::string& name,
99 const JsEventDetails& details) { 99 const JsEventDetails& details) {
100 if (!event_handler_.IsInitialized()) { 100 if (!event_handler_.IsInitialized()) {
101 NOTREACHED(); 101 NOTREACHED();
102 return; 102 return;
103 } 103 }
104 event_handler_.Call(from_here, &JsEventHandler::HandleJsEvent, name, details); 104 event_handler_.Call(from_here, &JsEventHandler::HandleJsEvent, name, details);
105 } 105 }
106 106
107 } // namespace syncer 107 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/js_mutation_event_observer.h ('k') | components/sync/engine_impl/sync_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698