| 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/logging.h" | 8 #include "base/logging.h" | 
| 8 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" | 
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" | 
|  | 11 #include "google/cacheinvalidation/include/invalidation-client-factory.h" | 
| 10 #include "jingle/notifier/listener/push_client.h" | 12 #include "jingle/notifier/listener/push_client.h" | 
| 11 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" | 
| 12 #include "sync/internal_api/public/base/model_type_payload_map.h" | 14 #include "sync/internal_api/public/base/model_type_payload_map.h" | 
| 13 #include "sync/notifier/sync_notifier_observer.h" | 15 #include "sync/notifier/sync_notifier_observer.h" | 
| 14 #include "talk/xmpp/jid.h" | 16 #include "talk/xmpp/jid.h" | 
| 15 #include "talk/xmpp/xmppclientsettings.h" | 17 #include "talk/xmpp/xmppclientsettings.h" | 
| 16 | 18 | 
| 17 namespace syncer { | 19 namespace syncer { | 
| 18 | 20 | 
| 19 InvalidationNotifier::InvalidationNotifier( | 21 InvalidationNotifier::InvalidationNotifier( | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 30       invalidation_client_(push_client.Pass()) { | 32       invalidation_client_(push_client.Pass()) { | 
| 31 } | 33 } | 
| 32 | 34 | 
| 33 InvalidationNotifier::~InvalidationNotifier() { | 35 InvalidationNotifier::~InvalidationNotifier() { | 
| 34   DCHECK(CalledOnValidThread()); | 36   DCHECK(CalledOnValidThread()); | 
| 35 } | 37 } | 
| 36 | 38 | 
| 37 void InvalidationNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, | 39 void InvalidationNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler, | 
| 38                                                const ObjectIdSet& ids) { | 40                                                const ObjectIdSet& ids) { | 
| 39   DCHECK(CalledOnValidThread()); | 41   DCHECK(CalledOnValidThread()); | 
| 40   invalidation_client_.RegisterIds(helper_.UpdateRegisteredIds(handler, ids)); | 42   const ObjectIdSet& all_registered_ids = | 
|  | 43       helper_.UpdateRegisteredIds(handler, ids); | 
|  | 44   invalidation_client_.UpdateRegisteredIds(all_registered_ids); | 
| 41 } | 45 } | 
| 42 | 46 | 
| 43 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { | 47 void InvalidationNotifier::SetUniqueId(const std::string& unique_id) { | 
| 44   DCHECK(CalledOnValidThread()); | 48   DCHECK(CalledOnValidThread()); | 
| 45   invalidation_client_id_ = unique_id; | 49   invalidation_client_id_ = unique_id; | 
| 46   DVLOG(1) << "Setting unique ID to " << unique_id; | 50   DVLOG(1) << "Setting unique ID to " << unique_id; | 
| 47   CHECK(!invalidation_client_id_.empty()); | 51   CHECK(!invalidation_client_id_.empty()); | 
| 48 } | 52 } | 
| 49 | 53 | 
| 50 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { | 54 void InvalidationNotifier::SetStateDeprecated(const std::string& state) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 64     UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", true); | 68     UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", true); | 
| 65   } else { | 69   } else { | 
| 66     UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", false); | 70     UMA_HISTOGRAM_BOOLEAN("InvalidationNotifier.UsefulSetState", false); | 
| 67   } | 71   } | 
| 68 } | 72 } | 
| 69 | 73 | 
| 70 void InvalidationNotifier::UpdateCredentials( | 74 void InvalidationNotifier::UpdateCredentials( | 
| 71     const std::string& email, const std::string& token) { | 75     const std::string& email, const std::string& token) { | 
| 72   if (state_ == STOPPED) { | 76   if (state_ == STOPPED) { | 
| 73     invalidation_client_.Start( | 77     invalidation_client_.Start( | 
|  | 78         base::Bind(&invalidation::CreateInvalidationClient), | 
| 74         invalidation_client_id_, client_info_, invalidation_state_, | 79         invalidation_client_id_, client_info_, invalidation_state_, | 
| 75         initial_max_invalidation_versions_, | 80         initial_max_invalidation_versions_, | 
| 76         invalidation_state_tracker_, | 81         invalidation_state_tracker_, | 
| 77         this); | 82         this); | 
| 78     invalidation_state_.clear(); | 83     invalidation_state_.clear(); | 
| 79     state_ = STARTED; | 84     state_ = STARTED; | 
| 80   } | 85   } | 
| 81   invalidation_client_.UpdateCredentials(email, token); | 86   invalidation_client_.UpdateCredentials(email, token); | 
| 82 } | 87 } | 
| 83 | 88 | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 96   helper_.EmitOnNotificationsEnabled(); | 101   helper_.EmitOnNotificationsEnabled(); | 
| 97 } | 102 } | 
| 98 | 103 | 
| 99 void InvalidationNotifier::OnNotificationsDisabled( | 104 void InvalidationNotifier::OnNotificationsDisabled( | 
| 100     NotificationsDisabledReason reason) { | 105     NotificationsDisabledReason reason) { | 
| 101   DCHECK(CalledOnValidThread()); | 106   DCHECK(CalledOnValidThread()); | 
| 102   helper_.EmitOnNotificationsDisabled(reason); | 107   helper_.EmitOnNotificationsDisabled(reason); | 
| 103 } | 108 } | 
| 104 | 109 | 
| 105 }  // namespace syncer | 110 }  // namespace syncer | 
| OLD | NEW | 
|---|