OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/invalidation/ticl_invalidation_service.h" | 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/invalidation/invalidation_service_util.h" | 10 #include "chrome/browser/invalidation/invalidation_service_util.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
127 DVLOG(2) << "Unregistering"; | 127 DVLOG(2) << "Unregistering"; |
128 invalidator_registrar_->UnregisterHandler(handler); | 128 invalidator_registrar_->UnregisterHandler(handler); |
129 if (invalidator_) { | 129 if (invalidator_) { |
130 invalidator_->UpdateRegisteredIds( | 130 invalidator_->UpdateRegisteredIds( |
131 this, | 131 this, |
132 invalidator_registrar_->GetAllRegisteredIds()); | 132 invalidator_registrar_->GetAllRegisteredIds()); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 void TiclInvalidationService::AcknowledgeInvalidation( | |
137 const invalidation::ObjectId& id, | |
138 const syncer::AckHandle& ack_handle) { | |
139 DCHECK(CalledOnValidThread()); | |
140 if (invalidator_) { | |
141 invalidator_->Acknowledge(id, ack_handle); | |
142 } | |
143 } | |
144 | |
145 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { | 136 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { |
146 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
147 if (invalidator_) { | 138 if (invalidator_) { |
148 DVLOG(2) << "GetInvalidatorState returning " | 139 DVLOG(2) << "GetInvalidatorState returning " |
149 << invalidator_->GetInvalidatorState(); | 140 << invalidator_->GetInvalidatorState(); |
150 return invalidator_->GetInvalidatorState(); | 141 return invalidator_->GetInvalidatorState(); |
151 } else { | 142 } else { |
152 DVLOG(2) << "Invalidator currently stopped"; | 143 DVLOG(2) << "Invalidator currently stopped"; |
153 return syncer::TRANSIENT_INVALIDATION_ERROR; | 144 return syncer::TRANSIENT_INVALIDATION_ERROR; |
154 } | 145 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return; | 344 return; |
354 } | 345 } |
355 | 346 |
356 notifier::NotifierOptions options = | 347 notifier::NotifierOptions options = |
357 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | 348 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
358 options.request_context_getter = profile_->GetRequestContext(); | 349 options.request_context_getter = profile_->GetRequestContext(); |
359 options.auth_mechanism = "X-OAUTH2"; | 350 options.auth_mechanism = "X-OAUTH2"; |
360 invalidator_.reset(new syncer::NonBlockingInvalidator( | 351 invalidator_.reset(new syncer::NonBlockingInvalidator( |
361 options, | 352 options, |
362 invalidator_storage_->GetInvalidatorClientId(), | 353 invalidator_storage_->GetInvalidatorClientId(), |
363 invalidator_storage_->GetAllInvalidationStates(), | 354 invalidator_storage_->GetSavedInvalidations(), |
364 invalidator_storage_->GetBootstrapData(), | 355 invalidator_storage_->GetBootstrapData(), |
365 syncer::WeakHandle<syncer::InvalidationStateTracker>( | 356 syncer::WeakHandle<syncer::InvalidationStateTracker>( |
366 invalidator_storage_->AsWeakPtr()), | 357 invalidator_storage_->AsWeakPtr()), |
367 content::GetUserAgent(GURL()))); | 358 content::GetUserAgent(GURL()))); |
368 | 359 |
369 UpdateInvalidatorCredentials(); | 360 UpdateInvalidatorCredentials(); |
370 | 361 |
371 invalidator_->RegisterHandler(this); | 362 invalidator_->RegisterHandler(this); |
372 invalidator_->UpdateRegisteredIds( | 363 invalidator_->UpdateRegisteredIds( |
373 this, | 364 this, |
(...skipping 24 matching lines...) Expand all Loading... |
398 } | 389 } |
399 | 390 |
400 // This service always expects to have a valid invalidator storage. | 391 // This service always expects to have a valid invalidator storage. |
401 // So we must not only clear the old one, but also start a new one. | 392 // So we must not only clear the old one, but also start a new one. |
402 invalidator_storage_->Clear(); | 393 invalidator_storage_->Clear(); |
403 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 394 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
404 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 395 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
405 } | 396 } |
406 | 397 |
407 } // namespace invalidation | 398 } // namespace invalidation |
OLD | NEW |