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

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

Issue 294123004: Move some sync/notifier to components/invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « sync/notifier/invalidation_notifier.h ('k') | sync/notifier/invalidation_notifier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/notifier/invalidation_notifier.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/histogram.h"
11 #include "google/cacheinvalidation/include/invalidation-client-factory.h"
12 #include "jingle/notifier/listener/push_client.h"
13 #include "net/url_request/url_request_context.h"
14 #include "sync/notifier/invalidation_handler.h"
15 #include "talk/xmpp/jid.h"
16 #include "talk/xmpp/xmppclientsettings.h"
17
18 namespace syncer {
19
20 InvalidationNotifier::InvalidationNotifier(
21 scoped_ptr<SyncNetworkChannel> network_channel,
22 const std::string& invalidator_client_id,
23 const UnackedInvalidationsMap& saved_invalidations,
24 const std::string& invalidation_bootstrap_data,
25 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker,
26 const std::string& client_info)
27 : state_(STOPPED),
28 saved_invalidations_(saved_invalidations),
29 invalidation_state_tracker_(invalidation_state_tracker),
30 client_info_(client_info),
31 invalidator_client_id_(invalidator_client_id),
32 invalidation_bootstrap_data_(invalidation_bootstrap_data),
33 invalidation_listener_(network_channel.Pass()) {
34 }
35
36 InvalidationNotifier::~InvalidationNotifier() {
37 DCHECK(CalledOnValidThread());
38 }
39
40 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) {
41 DCHECK(CalledOnValidThread());
42 registrar_.RegisterHandler(handler);
43 }
44
45 void InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler,
46 const ObjectIdSet& ids) {
47 DCHECK(CalledOnValidThread());
48 registrar_.UpdateRegisteredIds(handler, ids);
49 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds());
50 }
51
52 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) {
53 DCHECK(CalledOnValidThread());
54 registrar_.UnregisterHandler(handler);
55 }
56
57 InvalidatorState InvalidationNotifier::GetInvalidatorState() const {
58 DCHECK(CalledOnValidThread());
59 return registrar_.GetInvalidatorState();
60 }
61
62 void InvalidationNotifier::UpdateCredentials(
63 const std::string& email, const std::string& token) {
64 if (state_ == STOPPED) {
65 invalidation_listener_.Start(
66 base::Bind(&invalidation::CreateInvalidationClient),
67 invalidator_client_id_, client_info_, invalidation_bootstrap_data_,
68 saved_invalidations_,
69 invalidation_state_tracker_,
70 this);
71 state_ = STARTED;
72 }
73 invalidation_listener_.UpdateCredentials(email, token);
74 }
75
76 void InvalidationNotifier::RequestDetailedStatus(
77 base::Callback<void(const base::DictionaryValue&)> callback) const {
78 DCHECK(CalledOnValidThread());
79 invalidation_listener_.RequestDetailedStatus(callback);
80 }
81
82 void InvalidationNotifier::OnInvalidate(
83 const ObjectIdInvalidationMap& invalidation_map) {
84 DCHECK(CalledOnValidThread());
85 registrar_.DispatchInvalidationsToHandlers(invalidation_map);
86 }
87
88 void InvalidationNotifier::OnInvalidatorStateChange(InvalidatorState state) {
89 DCHECK(CalledOnValidThread());
90 registrar_.UpdateInvalidatorState(state);
91 }
92
93 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/invalidation_notifier.h ('k') | sync/notifier/invalidation_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698