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

Side by Side Diff: sync/notifier/invalidation_notifier.cc

Issue 10907070: [Sync] Rename classes in sync/ that start with Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 3 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 | Annotate | Revision Log
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 "sync/notifier/invalidation_notifier.h" 5 #include "sync/notifier/invalidation_notifier.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 10 matching lines...) Expand all
21 scoped_ptr<notifier::PushClient> push_client, 21 scoped_ptr<notifier::PushClient> push_client,
22 const InvalidationVersionMap& initial_max_invalidation_versions, 22 const InvalidationVersionMap& initial_max_invalidation_versions,
23 const std::string& initial_invalidation_state, 23 const std::string& initial_invalidation_state,
24 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, 24 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker,
25 const std::string& client_info) 25 const std::string& client_info)
26 : state_(STOPPED), 26 : state_(STOPPED),
27 initial_max_invalidation_versions_(initial_max_invalidation_versions), 27 initial_max_invalidation_versions_(initial_max_invalidation_versions),
28 invalidation_state_tracker_(invalidation_state_tracker), 28 invalidation_state_tracker_(invalidation_state_tracker),
29 client_info_(client_info), 29 client_info_(client_info),
30 invalidation_state_(initial_invalidation_state), 30 invalidation_state_(initial_invalidation_state),
31 invalidation_client_(push_client.Pass()) { 31 invalidation_listener_(push_client.Pass()) {
32 } 32 }
33 33
34 InvalidationNotifier::~InvalidationNotifier() { 34 InvalidationNotifier::~InvalidationNotifier() {
35 DCHECK(CalledOnValidThread()); 35 DCHECK(CalledOnValidThread());
36 } 36 }
37 37
38 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) { 38 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) {
39 DCHECK(CalledOnValidThread()); 39 DCHECK(CalledOnValidThread());
40 registrar_.RegisterHandler(handler); 40 registrar_.RegisterHandler(handler);
41 } 41 }
42 42
43 void InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler, 43 void InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler,
44 const ObjectIdSet& ids) { 44 const ObjectIdSet& ids) {
45 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
46 registrar_.UpdateRegisteredIds(handler, ids); 46 registrar_.UpdateRegisteredIds(handler, ids);
47 invalidation_client_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); 47 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds());
48 } 48 }
49 49
50 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) { 50 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) {
51 DCHECK(CalledOnValidThread()); 51 DCHECK(CalledOnValidThread());
52 registrar_.UnregisterHandler(handler); 52 registrar_.UnregisterHandler(handler);
53 } 53 }
54 54
55 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { 55 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) {
56 DCHECK(CalledOnValidThread()); 56 DCHECK(CalledOnValidThread());
57 invalidation_client_id_ = unique_id; 57 client_id_ = unique_id;
58 DVLOG(1) << "Setting unique ID to " << unique_id; 58 DVLOG(1) << "Setting unique ID to " << unique_id;
59 CHECK(!invalidation_client_id_.empty()); 59 CHECK(!client_id_.empty());
60 } 60 }
61 61
62 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { 62 void InvalidationNotifier::SetStateDeprecated(const std::string& state) {
63 DCHECK(CalledOnValidThread()); 63 DCHECK(CalledOnValidThread());
64 DCHECK_LT(state_, STARTED); 64 DCHECK_LT(state_, STARTED);
65 if (invalidation_state_.empty()) { 65 if (invalidation_state_.empty()) {
66 // Migrate state from sync to invalidation state tracker (bug 66 // Migrate state from sync to invalidation state tracker (bug
67 // 124140). We've just been handed state from the syncable::Directory, and 67 // 124140). We've just been handed state from the syncable::Directory, and
68 // the initial invalidation state was empty, implying we've never written 68 // the initial invalidation state was empty, implying we've never written
69 // to the new store. Do this here to ensure we always migrate (even if 69 // to the new store. Do this here to ensure we always migrate (even if
70 // we fail to establish an initial connection or receive an initial 70 // we fail to establish an initial connection or receive an initial
71 // invalidation) so that we can make the old code obsolete as soon as 71 // invalidation) so that we can make the old code obsolete as soon as
72 // possible. 72 // possible.
73 invalidation_state_ = state; 73 invalidation_state_ = state;
74 invalidation_state_tracker_.Call( 74 invalidation_state_tracker_.Call(
75 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state); 75 FROM_HERE, &InvalidationStateTracker::SetInvalidationState, state);
76 UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", true); 76 UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", true);
77 } else { 77 } else {
78 UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", false); 78 UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", false);
79 } 79 }
80 } 80 }
81 81
82 void InvalidationNotifier::UpdateCredentials( 82 void InvalidationNotifier::UpdateCredentials(
83 const std::string& email, const std::string& token) { 83 const std::string& email, const std::string& token) {
84 if (state_ == STOPPED) { 84 if (state_ == STOPPED) {
85 invalidation_client_.Start( 85 invalidation_listener_.Start(
86 base::Bind(&invalidation::CreateInvalidationClient), 86 base::Bind(&invalidation::CreateInvalidationClient),
87 invalidation_client_id_, client_info_, invalidation_state_, 87 client_id_, client_info_, invalidation_state_,
88 initial_max_invalidation_versions_, 88 initial_max_invalidation_versions_,
89 invalidation_state_tracker_, 89 invalidation_state_tracker_,
90 this); 90 this);
91 invalidation_state_.clear(); 91 invalidation_state_.clear();
92 state_ = STARTED; 92 state_ = STARTED;
93 } 93 }
94 invalidation_client_.UpdateCredentials(email, token); 94 invalidation_listener_.UpdateCredentials(email, token);
95 } 95 }
96 96
97 void InvalidationNotifier::SendNotification( 97 void InvalidationNotifier::SendNotification(
98 const ObjectIdStateMap& id_state_map) { 98 const ObjectIdStateMap& id_state_map) {
99 DCHECK(CalledOnValidThread()); 99 DCHECK(CalledOnValidThread());
100 // Do nothing. 100 // Do nothing.
101 } 101 }
102 102
103 void InvalidationNotifier::OnInvalidate(const ObjectIdStateMap& id_state_map) { 103 void InvalidationNotifier::OnInvalidate(const ObjectIdStateMap& id_state_map) {
104 DCHECK(CalledOnValidThread()); 104 DCHECK(CalledOnValidThread());
105 registrar_.DispatchInvalidationsToHandlers(id_state_map, REMOTE_NOTIFICATION); 105 registrar_.DispatchInvalidationsToHandlers(id_state_map, REMOTE_NOTIFICATION);
106 } 106 }
107 107
108 void InvalidationNotifier::OnNotificationsEnabled() { 108 void InvalidationNotifier::OnNotificationsEnabled() {
109 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
110 registrar_.EmitOnNotificationsEnabled(); 110 registrar_.EmitOnNotificationsEnabled();
111 } 111 }
112 112
113 void InvalidationNotifier::OnNotificationsDisabled( 113 void InvalidationNotifier::OnNotificationsDisabled(
114 NotificationsDisabledReason reason) { 114 NotificationsDisabledReason reason) {
115 DCHECK(CalledOnValidThread()); 115 DCHECK(CalledOnValidThread());
116 registrar_.EmitOnNotificationsDisabled(reason); 116 registrar_.EmitOnNotificationsDisabled(reason);
117 } 117 }
118 118
119 } // namespace syncer 119 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698