OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/sync/glue/sync_backend_host_impl.h" | 5 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // must ask the syncer to download them. Any newly supported datatypes will | 332 // must ask the syncer to download them. Any newly supported datatypes will |
333 // not have been in that routing info list, so they will be among the types | 333 // not have been in that routing info list, so they will be among the types |
334 // downloaded if they are enabled. | 334 // downloaded if they are enabled. |
335 // | 335 // |
336 // The SyncBackendRegistrar's state was initially derived from the types | 336 // The SyncBackendRegistrar's state was initially derived from the types |
337 // detected to have been downloaded in the database. Afterwards it is | 337 // detected to have been downloaded in the database. Afterwards it is |
338 // modified only by this function. We expect it to remain in sync with the | 338 // modified only by this function. We expect it to remain in sync with the |
339 // backend because configuration requests are never aborted; they are retried | 339 // backend because configuration requests are never aborted; they are retried |
340 // until they succeed or the backend is shut down. | 340 // until they succeed or the backend is shut down. |
341 | 341 |
342 syncer::ModelTypeSet previous_types = registrar_->GetLastConfiguredTypes(); | |
343 | |
344 syncer::ModelTypeSet disabled_types = | 342 syncer::ModelTypeSet disabled_types = |
345 GetDataTypesInState(DISABLED, config_state_map); | 343 GetDataTypesInState(DISABLED, config_state_map); |
346 syncer::ModelTypeSet fatal_types = | 344 syncer::ModelTypeSet fatal_types = |
347 GetDataTypesInState(FATAL, config_state_map); | 345 GetDataTypesInState(FATAL, config_state_map); |
348 syncer::ModelTypeSet crypto_types = | 346 syncer::ModelTypeSet crypto_types = |
349 GetDataTypesInState(CRYPTO, config_state_map); | 347 GetDataTypesInState(CRYPTO, config_state_map); |
350 syncer::ModelTypeSet unready_types = | 348 syncer::ModelTypeSet unready_types = |
351 GetDataTypesInState(UNREADY, config_state_map); | 349 GetDataTypesInState(UNREADY, config_state_map); |
| 350 |
352 disabled_types.PutAll(fatal_types); | 351 disabled_types.PutAll(fatal_types); |
353 | |
354 // TODO(zea): These types won't be fully purged if they are subsequently | |
355 // disabled by the user. Fix that. See crbug.com/386778 | |
356 disabled_types.PutAll(crypto_types); | 352 disabled_types.PutAll(crypto_types); |
357 disabled_types.PutAll(unready_types); | 353 disabled_types.PutAll(unready_types); |
358 | 354 |
359 syncer::ModelTypeSet active_types = | 355 syncer::ModelTypeSet active_types = |
360 GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map); | 356 GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map); |
361 syncer::ModelTypeSet clean_first_types = | 357 syncer::ModelTypeSet clean_first_types = |
362 GetDataTypesInState(CONFIGURE_CLEAN, config_state_map); | 358 GetDataTypesInState(CONFIGURE_CLEAN, config_state_map); |
363 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( | 359 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( |
364 syncer::Union(active_types, clean_first_types), | 360 syncer::Union(active_types, clean_first_types), |
365 disabled_types); | 361 disabled_types); |
(...skipping 22 matching lines...) Expand all Loading... |
388 // will not send a MIGRATION_DONE response in that case. We still need to be | 384 // will not send a MIGRATION_DONE response in that case. We still need to be |
389 // careful to not send progress markers for non-nigori types, though. If a | 385 // careful to not send progress markers for non-nigori types, though. If a |
390 // non-nigori type in the request requires migration, a MIGRATION_DONE | 386 // non-nigori type in the request requires migration, a MIGRATION_DONE |
391 // response will be sent. | 387 // response will be sent. |
392 | 388 |
393 syncer::ModelSafeRoutingInfo routing_info; | 389 syncer::ModelSafeRoutingInfo routing_info; |
394 registrar_->GetModelSafeRoutingInfo(&routing_info); | 390 registrar_->GetModelSafeRoutingInfo(&routing_info); |
395 | 391 |
396 syncer::ModelTypeSet current_types = registrar_->GetLastConfiguredTypes(); | 392 syncer::ModelTypeSet current_types = registrar_->GetLastConfiguredTypes(); |
397 syncer::ModelTypeSet types_to_purge = | 393 syncer::ModelTypeSet types_to_purge = |
398 syncer::Difference(previous_types, current_types); | 394 syncer::Difference(syncer::ModelTypeSet::All(), current_types); |
399 syncer::ModelTypeSet inactive_types = | 395 syncer::ModelTypeSet inactive_types = |
400 GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map); | 396 GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map); |
401 types_to_purge.RemoveAll(inactive_types); | 397 types_to_purge.RemoveAll(inactive_types); |
402 types_to_purge.RemoveAll(unready_types); | 398 types_to_purge.RemoveAll(unready_types); |
403 | 399 |
404 // If a type has already been disabled and unapplied or journaled, it will | 400 // If a type has already been disabled and unapplied or journaled, it will |
405 // not be part of the |types_to_purge| set, and therefore does not need | 401 // not be part of the |types_to_purge| set, and therefore does not need |
406 // to be acted on again. | 402 // to be acted on again. |
407 fatal_types.RetainAll(types_to_purge); | 403 fatal_types.RetainAll(types_to_purge); |
408 syncer::ModelTypeSet unapply_types = | 404 syncer::ModelTypeSet unapply_types = |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 872 |
877 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { | 873 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { |
878 return registrar_->sync_thread()->message_loop(); | 874 return registrar_->sync_thread()->message_loop(); |
879 } | 875 } |
880 | 876 |
881 } // namespace browser_sync | 877 } // namespace browser_sync |
882 | 878 |
883 #undef SDVLOG | 879 #undef SDVLOG |
884 | 880 |
885 #undef SLOG | 881 #undef SLOG |
OLD | NEW |