OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/policy/affiliated_invalidation_service_provide
r_impl.h" | 5 #include "chrome/browser/chromeos/policy/affiliated_invalidation_service_provide
r_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 if (!device_invalidation_service_) { | 237 if (!device_invalidation_service_) { |
238 // The lack of a device-global invalidation service implies that another | 238 // The lack of a device-global invalidation service implies that another |
239 // connected invalidation service is being made available to consumers | 239 // connected invalidation service is being made available to consumers |
240 // already. There is no need to switch from that to the service which just | 240 // already. There is no need to switch from that to the service which just |
241 // connected. | 241 // connected. |
242 return; | 242 return; |
243 } | 243 } |
244 | 244 |
245 if (invalidation_service != device_invalidation_service_.get()) { | 245 // Make the invalidation service that just connected available to consumers. |
246 // If an invalidation service other than the device-global one connected, | 246 invalidation_service_ = nullptr; |
247 // destroy the device-global service. | 247 SetInvalidationService(invalidation_service); |
248 invalidation_service_ = nullptr; | 248 |
| 249 if (invalidation_service_ && |
| 250 device_invalidation_service_ && |
| 251 invalidation_service_ != device_invalidation_service_.get()) { |
| 252 // If a different invalidation service is being made available to consumers |
| 253 // now, destroy the device-global one. |
249 DestroyDeviceInvalidationService(); | 254 DestroyDeviceInvalidationService(); |
250 } | 255 } |
251 | 256 |
252 // Make the invalidation service that just connected available to consumers. | |
253 SetInvalidationService(invalidation_service); | |
254 } | 257 } |
255 | 258 |
256 void | 259 void |
257 AffiliatedInvalidationServiceProviderImpl::OnInvalidationServiceDisconnected( | 260 AffiliatedInvalidationServiceProviderImpl::OnInvalidationServiceDisconnected( |
258 invalidation::InvalidationService* invalidation_service) { | 261 invalidation::InvalidationService* invalidation_service) { |
259 DCHECK(!is_shut_down_); | 262 DCHECK(!is_shut_down_); |
260 | 263 |
261 if (invalidation_service != invalidation_service_) { | 264 if (invalidation_service != invalidation_service_) { |
262 // If the invalidation service which disconnected was not being made | 265 // If the invalidation service which disconnected was not being made |
263 // available to consumers, return. | 266 // available to consumers, return. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 OnInvalidationServiceSet(invalidation_service_)); | 339 OnInvalidationServiceSet(invalidation_service_)); |
337 } | 340 } |
338 | 341 |
339 void | 342 void |
340 AffiliatedInvalidationServiceProviderImpl::DestroyDeviceInvalidationService() { | 343 AffiliatedInvalidationServiceProviderImpl::DestroyDeviceInvalidationService() { |
341 device_invalidation_service_observer_.reset(); | 344 device_invalidation_service_observer_.reset(); |
342 device_invalidation_service_.reset(); | 345 device_invalidation_service_.reset(); |
343 } | 346 } |
344 | 347 |
345 } // namespace policy | 348 } // namespace policy |
OLD | NEW |