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

Side by Side Diff: components/invalidation/impl/invalidation_notifier.cc

Issue 2909113002: Deprecate NonThreadSafe in components/invalidation in favor of SequenceChecker. (Closed)
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/invalidation/impl/invalidation_notifier.h" 5 #include "components/invalidation/impl/invalidation_notifier.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 18 matching lines...) Expand all
29 saved_invalidations_(saved_invalidations), 29 saved_invalidations_(saved_invalidations),
30 invalidation_state_tracker_(invalidation_state_tracker), 30 invalidation_state_tracker_(invalidation_state_tracker),
31 invalidation_state_tracker_task_runner_( 31 invalidation_state_tracker_task_runner_(
32 invalidation_state_tracker_task_runner), 32 invalidation_state_tracker_task_runner),
33 client_info_(client_info), 33 client_info_(client_info),
34 invalidator_client_id_(invalidator_client_id), 34 invalidator_client_id_(invalidator_client_id),
35 invalidation_bootstrap_data_(invalidation_bootstrap_data), 35 invalidation_bootstrap_data_(invalidation_bootstrap_data),
36 invalidation_listener_(std::move(network_channel)) {} 36 invalidation_listener_(std::move(network_channel)) {}
37 37
38 InvalidationNotifier::~InvalidationNotifier() { 38 InvalidationNotifier::~InvalidationNotifier() {
39 DCHECK(CalledOnValidThread()); 39 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
40 } 40 }
41 41
42 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) { 42 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) {
43 DCHECK(CalledOnValidThread()); 43 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
44 registrar_.RegisterHandler(handler); 44 registrar_.RegisterHandler(handler);
45 } 45 }
46 46
47 bool InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler, 47 bool InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler,
48 const ObjectIdSet& ids) { 48 const ObjectIdSet& ids) {
49 DCHECK(CalledOnValidThread()); 49 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
50 if (!registrar_.UpdateRegisteredIds(handler, ids)) 50 if (!registrar_.UpdateRegisteredIds(handler, ids))
51 return false; 51 return false;
52 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); 52 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds());
53 return true; 53 return true;
54 } 54 }
55 55
56 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { 56 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) {
57 DCHECK(CalledOnValidThread()); 57 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
58 registrar_.UnregisterHandler(handler); 58 registrar_.UnregisterHandler(handler);
59 } 59 }
60 60
61 InvalidatorState InvalidationNotifier::GetInvalidatorState() const { 61 InvalidatorState InvalidationNotifier::GetInvalidatorState() const {
62 DCHECK(CalledOnValidThread()); 62 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
63 return registrar_.GetInvalidatorState(); 63 return registrar_.GetInvalidatorState();
64 } 64 }
65 65
66 void InvalidationNotifier::UpdateCredentials( 66 void InvalidationNotifier::UpdateCredentials(
67 const std::string& email, const std::string& token) { 67 const std::string& email, const std::string& token) {
68 if (state_ == STOPPED) { 68 if (state_ == STOPPED) {
69 invalidation_listener_.Start( 69 invalidation_listener_.Start(
70 base::Bind(&invalidation::CreateInvalidationClient), 70 base::Bind(&invalidation::CreateInvalidationClient),
71 invalidator_client_id_, 71 invalidator_client_id_,
72 client_info_, 72 client_info_,
73 invalidation_bootstrap_data_, 73 invalidation_bootstrap_data_,
74 saved_invalidations_, 74 saved_invalidations_,
75 invalidation_state_tracker_, 75 invalidation_state_tracker_,
76 invalidation_state_tracker_task_runner_, 76 invalidation_state_tracker_task_runner_,
77 this); 77 this);
78 state_ = STARTED; 78 state_ = STARTED;
79 } 79 }
80 invalidation_listener_.UpdateCredentials(email, token); 80 invalidation_listener_.UpdateCredentials(email, token);
81 } 81 }
82 82
83 void InvalidationNotifier::RequestDetailedStatus( 83 void InvalidationNotifier::RequestDetailedStatus(
84 base::Callback<void(const base::DictionaryValue&)> callback) const { 84 base::Callback<void(const base::DictionaryValue&)> callback) const {
85 DCHECK(CalledOnValidThread()); 85 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
86 invalidation_listener_.RequestDetailedStatus(callback); 86 invalidation_listener_.RequestDetailedStatus(callback);
87 } 87 }
88 88
89 void InvalidationNotifier::OnInvalidate( 89 void InvalidationNotifier::OnInvalidate(
90 const ObjectIdInvalidationMap& invalidation_map) { 90 const ObjectIdInvalidationMap& invalidation_map) {
91 DCHECK(CalledOnValidThread()); 91 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
92 registrar_.DispatchInvalidationsToHandlers(invalidation_map); 92 registrar_.DispatchInvalidationsToHandlers(invalidation_map);
93 } 93 }
94 94
95 void InvalidationNotifier::OnInvalidatorStateChange(InvalidatorState state) { 95 void InvalidationNotifier::OnInvalidatorStateChange(InvalidatorState state) {
96 DCHECK(CalledOnValidThread()); 96 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
97 registrar_.UpdateInvalidatorState(state); 97 registrar_.UpdateInvalidatorState(state);
98 } 98 }
99 99
100 } // namespace syncer 100 } // namespace syncer
OLDNEW
« no previous file with comments | « components/invalidation/impl/invalidation_notifier.h ('k') | components/invalidation/impl/invalidation_service_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698