OLD | NEW |
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" |
11 #include "google/cacheinvalidation/include/invalidation-client-factory.h" | 11 #include "google/cacheinvalidation/include/invalidation-client-factory.h" |
12 #include "jingle/notifier/listener/push_client.h" | 12 #include "jingle/notifier/listener/push_client.h" |
13 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" |
14 #include "sync/notifier/sync_notifier_observer.h" | 14 #include "sync/notifier/invalidation_handler.h" |
15 #include "talk/xmpp/jid.h" | 15 #include "talk/xmpp/jid.h" |
16 #include "talk/xmpp/xmppclientsettings.h" | 16 #include "talk/xmpp/xmppclientsettings.h" |
17 | 17 |
18 namespace syncer { | 18 namespace syncer { |
19 | 19 |
20 InvalidationNotifier::InvalidationNotifier( | 20 InvalidationNotifier::InvalidationNotifier( |
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_client_(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(SyncNotifierObserver* 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(SyncNotifierObserver* 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_client_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds()); |
48 } | 48 } |
49 | 49 |
50 void InvalidationNotifier::UnregisterHandler(SyncNotifierObserver* 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 invalidation_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(!invalidation_client_id_.empty()); |
60 } | 60 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 registrar_.EmitOnNotificationsEnabled(); | 109 registrar_.EmitOnNotificationsEnabled(); |
110 } | 110 } |
111 | 111 |
112 void InvalidationNotifier::OnNotificationsDisabled( | 112 void InvalidationNotifier::OnNotificationsDisabled( |
113 NotificationsDisabledReason reason) { | 113 NotificationsDisabledReason reason) { |
114 DCHECK(CalledOnValidThread()); | 114 DCHECK(CalledOnValidThread()); |
115 registrar_.EmitOnNotificationsDisabled(reason); | 115 registrar_.EmitOnNotificationsDisabled(reason); |
116 } | 116 } |
117 | 117 |
118 } // namespace syncer | 118 } // namespace syncer |
OLD | NEW |