Don't enable DWM rendering policy on Windows with custom frames.
[chromium-blink-merge.git] / sync / notifier / invalidation_notifier.cc
blobb67165ff6a3598ab42083ac506c13f4b969bc421
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.
5 #include "sync/notifier/invalidation_notifier.h"
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"
18 namespace syncer {
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()) {
36 InvalidationNotifier::~InvalidationNotifier() {
37 DCHECK(CalledOnValidThread());
40 void InvalidationNotifier::RegisterHandler(InvalidationHandler* handler) {
41 DCHECK(CalledOnValidThread());
42 registrar_.RegisterHandler(handler);
45 void InvalidationNotifier::UpdateRegisteredIds(InvalidationHandler* handler,
46 const ObjectIdSet& ids) {
47 DCHECK(CalledOnValidThread());
48 registrar_.UpdateRegisteredIds(handler, ids);
49 invalidation_listener_.UpdateRegisteredIds(registrar_.GetAllRegisteredIds());
52 void InvalidationNotifier::UnregisterHandler(InvalidationHandler* handler) {
53 DCHECK(CalledOnValidThread());
54 registrar_.UnregisterHandler(handler);
57 InvalidatorState InvalidationNotifier::GetInvalidatorState() const {
58 DCHECK(CalledOnValidThread());
59 return registrar_.GetInvalidatorState();
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;
73 invalidation_listener_.UpdateCredentials(email, token);
76 void InvalidationNotifier::OnInvalidate(
77 const ObjectIdInvalidationMap& invalidation_map) {
78 DCHECK(CalledOnValidThread());
79 registrar_.DispatchInvalidationsToHandlers(invalidation_map);
82 void InvalidationNotifier::OnInvalidatorStateChange(InvalidatorState state) {
83 DCHECK(CalledOnValidThread());
84 registrar_.UpdateInvalidatorState(state);
87 } // namespace syncer