Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 11474036: Remove initial_sync_ended bits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/about_sync_util.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/sync/glue/sync_backend_host.h" 7 #include "chrome/browser/sync/glue/sync_backend_host.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // The SyncBackendRegistrar's routing info will be updated by adding the 669 // The SyncBackendRegistrar's routing info will be updated by adding the
670 // types_to_add to the list then removing types_to_remove. Any types which 670 // types_to_add to the list then removing types_to_remove. Any types which
671 // are not in either of those sets will remain untouched. 671 // are not in either of those sets will remain untouched.
672 // 672 //
673 // Types which were not in the list previously are not fully downloaded, so we 673 // Types which were not in the list previously are not fully downloaded, so we
674 // must ask the syncer to download them. Any newly supported datatypes will 674 // must ask the syncer to download them. Any newly supported datatypes will
675 // not have been in that routing info list, so they will be among the types 675 // not have been in that routing info list, so they will be among the types
676 // downloaded if they are enabled. 676 // downloaded if they are enabled.
677 // 677 //
678 // The SyncBackendRegistrar's state was initially derived from the types 678 // The SyncBackendRegistrar's state was initially derived from the types
679 // marked initial_sync_ended when the sync database was loaded. Afterwards it 679 // detected to have been downloaded in the database. Afterwards it is
680 // is modified only by this function. We expect it to remain in sync with the 680 // modified only by this function. We expect it to remain in sync with the
681 // backend because configuration requests are never aborted; they are retried 681 // backend because configuration requests are never aborted; they are retried
682 // until they succeed or the browser is closed. 682 // until they succeed or the backend is shut down.
683 683
684 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( 684 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes(
685 types_to_add, types_to_remove); 685 types_to_add, types_to_remove);
686 if (!types_to_download.Empty()) 686 if (!types_to_download.Empty())
687 types_to_download.Put(syncer::NIGORI); 687 types_to_download.Put(syncer::NIGORI);
688 688
689 // TODO(sync): crbug.com/137550. 689 // TODO(sync): crbug.com/137550.
690 // It's dangerous to configure types that have progress markers. Types with 690 // It's dangerous to configure types that have progress markers. Types with
691 // progress markers can trigger a MIGRATION_DONE response. We are not 691 // progress markers can trigger a MIGRATION_DONE response. We are not
692 // prepared to handle a migration during a configure, so we must ensure that 692 // prepared to handle a migration during a configure, so we must ensure that
693 // all our types_to_download actually contain no data before we sync them. 693 // all our types_to_download actually contain no data before we sync them.
694 // 694 //
695 // The most common way to end up in this situation used to be types which had 695 // One common way to end up in this situation used to be types which
696 // !initial_sync_ended, but did have some progress markers. We avoid problems 696 // downloaded some or all of their data but have not applied it yet. We avoid
697 // with those types by purging the data of any such partially synced types 697 // problems with those types by purging the data of any such partially synced
698 // soon after we load the directory. 698 // types soon after we load the directory.
699 // 699 //
700 // Another possible scenario is that we have newly supported or newly enabled 700 // Another possible scenario is that we have newly supported or newly enabled
701 // data types being downloaded here but the nigori type, which is always 701 // data types being downloaded here but the nigori type, which is always
702 // included in any GetUpdates request, requires migration. The server has 702 // included in any GetUpdates request, requires migration. The server has
703 // code to detect this scenario based on the configure reason, the fact that 703 // code to detect this scenario based on the configure reason, the fact that
704 // the nigori type is the only requested type which requires migration, and 704 // the nigori type is the only requested type which requires migration, and
705 // that the requested types list includes at least one non-nigori type. It 705 // that the requested types list includes at least one non-nigori type. It
706 // will not send a MIGRATION_DONE response in that case. We still need to be 706 // will not send a MIGRATION_DONE response in that case. We still need to be
707 // careful to not send progress markers for non-nigori types, though. If a 707 // careful to not send progress markers for non-nigori types, though. If a
708 // non-nigori type in the request requires migration, a MIGRATION_DONE 708 // non-nigori type in the request requires migration, a MIGRATION_DONE
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1232
1233 if (!sync_manager_->GetUserShare()) { // NULL in some tests. 1233 if (!sync_manager_->GetUserShare()) { // NULL in some tests.
1234 DVLOG(1) << "Skipping initialization of DeviceInfo"; 1234 DVLOG(1) << "Skipping initialization of DeviceInfo";
1235 host_.Call( 1235 host_.Call(
1236 FROM_HERE, 1236 FROM_HERE,
1237 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, 1237 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop,
1238 true); 1238 true);
1239 return; 1239 return;
1240 } 1240 }
1241 1241
1242 if (!sync_manager_->InitialSyncEndedTypes().HasAll(syncer::ControlTypes())) {
Nicolas Zea 2012/12/11 02:12:40 Could you add a unit test for this case? (i.e. whe
rlarocque 2012/12/11 19:23:03 Good idea. Done.
1243 LOG(ERROR) << "Failed to download control types";
1244 host_.Call(
1245 FROM_HERE,
1246 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop,
1247 false);
1248 return;
1249 }
1250
1242 // Initialize device info. This is asynchronous on some platforms, so we 1251 // Initialize device info. This is asynchronous on some platforms, so we
1243 // provide a callback for when it finishes. 1252 // provide a callback for when it finishes.
1244 synced_device_tracker_.reset( 1253 synced_device_tracker_.reset(
1245 new SyncedDeviceTracker(sync_manager_->GetUserShare(), 1254 new SyncedDeviceTracker(sync_manager_->GetUserShare(),
1246 sync_manager_->cache_guid())); 1255 sync_manager_->cache_guid()));
1247 synced_device_tracker_->InitLocalDeviceInfo( 1256 synced_device_tracker_->InitLocalDeviceInfo(
1248 base::Bind(&SyncBackendHost::Core::DoFinishInitialProcessControlTypes, 1257 base::Bind(&SyncBackendHost::Core::DoFinishInitialProcessControlTypes,
1249 this)); 1258 this));
1250 } 1259 }
1251 1260
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 DVLOG(1) << "Connection status changed: " 1597 DVLOG(1) << "Connection status changed: "
1589 << syncer::ConnectionStatusToString(status); 1598 << syncer::ConnectionStatusToString(status);
1590 frontend_->OnConnectionStatusChange(status); 1599 frontend_->OnConnectionStatusChange(status);
1591 } 1600 }
1592 1601
1593 #undef SDVLOG 1602 #undef SDVLOG
1594 1603
1595 #undef SLOG 1604 #undef SLOG
1596 1605
1597 } // namespace browser_sync 1606 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/about_sync_util.cc ('k') | chrome/browser/sync/test_profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698