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

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

Issue 10854050: sync: Remove WITH_NIGORI and WITHOUT_NIGORI flags (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 8 years, 4 months 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
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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 624
625 registrar_.reset(); 625 registrar_.reset();
626 chrome_sync_notification_bridge_.reset(); 626 chrome_sync_notification_bridge_.reset();
627 core_ = NULL; // Releases reference to core_. 627 core_ = NULL; // Releases reference to core_.
628 } 628 }
629 629
630 void SyncBackendHost::ConfigureDataTypes( 630 void SyncBackendHost::ConfigureDataTypes(
631 syncer::ConfigureReason reason, 631 syncer::ConfigureReason reason,
632 syncer::ModelTypeSet types_to_add, 632 syncer::ModelTypeSet types_to_add,
633 syncer::ModelTypeSet types_to_remove, 633 syncer::ModelTypeSet types_to_remove,
634 NigoriState nigori_state,
635 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, 634 const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
636 const base::Callback<void()>& retry_callback) { 635 const base::Callback<void()>& retry_callback) {
637 // Only one configure is allowed at a time. This is guaranteed by our 636 // Only one configure is allowed at a time. This is guaranteed by our
638 // callers. The SyncBackendHost requests one configure as the backend is 637 // callers. The SyncBackendHost requests one configure as the backend is
639 // initializing and waits for it to complete. After initialization, all 638 // initializing and waits for it to complete. After initialization, all
640 // configurations will pass through the DataTypeManager, which is careful to 639 // configurations will pass through the DataTypeManager, which is careful to
641 // never send a new configure request until the current request succeeds. 640 // never send a new configure request until the current request succeeds.
642 641
643 DCHECK_GT(initialization_state_, NOT_INITIALIZED); 642 DCHECK_GT(initialization_state_, NOT_INITIALIZED);
644 643
645 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add;
646 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove;
647 if (nigori_state == WITH_NIGORI) {
648 types_to_add_with_nigori.Put(syncer::NIGORI);
649 types_to_remove_with_nigori.Remove(syncer::NIGORI);
650 } else {
651 types_to_add_with_nigori.Remove(syncer::NIGORI);
652 types_to_remove_with_nigori.Put(syncer::NIGORI);
653 }
654
655 // The SyncBackendRegistrar's routing info will be updated by adding the 644 // The SyncBackendRegistrar's routing info will be updated by adding the
656 // types_to_add_with_nigori to the list then removing 645 // types_to_add to the list then removing types_to_remove. Any types which
657 // types_to_remove_with_nigori. Any types which are not in either of those 646 // are not in either of those sets will remain untouched.
658 // sets will remain untouched.
659 // 647 //
660 // Types which were not in the list previously are not fully downloaded, so we 648 // Types which were not in the list previously are not fully downloaded, so we
661 // must ask the syncer to download them. Any newly supported datatypes will 649 // must ask the syncer to download them. Any newly supported datatypes will
662 // not have been in that routing info list, so they will be among the types 650 // not have been in that routing info list, so they will be among the types
663 // downloaded if they are enabled. 651 // downloaded if they are enabled.
664 // 652 //
665 // The SyncBackendRegistrar's state was initially derived from the types 653 // The SyncBackendRegistrar's state was initially derived from the types
666 // marked initial_sync_ended when the sync database was loaded. Afterwards it 654 // marked initial_sync_ended when the sync database was loaded. Afterwards it
667 // is modified only by this function. We expect it to remain in sync with the 655 // is modified only by this function. We expect it to remain in sync with the
668 // backend because configuration requests are never aborted; they are retried 656 // backend because configuration requests are never aborted; they are retried
669 // until they succeed or the browser is closed. 657 // until they succeed or the browser is closed.
670 658
671 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( 659 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes(
672 types_to_add_with_nigori, types_to_remove_with_nigori); 660 types_to_add, types_to_remove);
673 if (!types_to_download.Empty()) 661 if (!types_to_download.Empty())
674 types_to_download.Put(syncer::NIGORI); 662 types_to_download.Put(syncer::NIGORI);
675 663
676 // TODO(sync): crbug.com/137550. 664 // TODO(sync): crbug.com/137550.
677 // It's dangerous to configure types that have progress markers. Types with 665 // It's dangerous to configure types that have progress markers. Types with
678 // progress markers can trigger a MIGRATION_DONE response. We are not 666 // progress markers can trigger a MIGRATION_DONE response. We are not
679 // prepared to handle a migration during a configure, so we must ensure that 667 // prepared to handle a migration during a configure, so we must ensure that
680 // all our types_to_download actually contain no data before we sync them. 668 // all our types_to_download actually contain no data before we sync them.
681 // 669 //
682 // The most common way to end up in this situation used to be types which had 670 // The most common way to end up in this situation used to be types which had
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 case NOT_INITIALIZED: 1309 case NOT_INITIALIZED:
1322 // This configuration should result in a download request if the nigori 1310 // This configuration should result in a download request if the nigori
1323 // type's initial_sync_ended bit is unset. If the download request 1311 // type's initial_sync_ended bit is unset. If the download request
1324 // contains progress markers, there is a risk that the server will try to 1312 // contains progress markers, there is a risk that the server will try to
1325 // trigger migration. That would be disastrous, so we must rely on the 1313 // trigger migration. That would be disastrous, so we must rely on the
1326 // sync manager to ensure that this type never has both progress markers 1314 // sync manager to ensure that this type never has both progress markers
1327 // and !initial_sync_ended. 1315 // and !initial_sync_ended.
1328 initialization_state_ = DOWNLOADING_NIGORI; 1316 initialization_state_ = DOWNLOADING_NIGORI;
1329 ConfigureDataTypes( 1317 ConfigureDataTypes(
1330 syncer::CONFIGURE_REASON_NEW_CLIENT, 1318 syncer::CONFIGURE_REASON_NEW_CLIENT,
1319 syncer::ModelTypeSet(syncer::NIGORI),
1331 syncer::ModelTypeSet(), 1320 syncer::ModelTypeSet(),
1332 syncer::ModelTypeSet(),
1333 WITH_NIGORI,
1334 // Calls back into this function. 1321 // Calls back into this function.
1335 base::Bind( 1322 base::Bind(
1336 &SyncBackendHost:: 1323 &SyncBackendHost::
1337 HandleNigoriConfigurationCompletedOnFrontendLoop, 1324 HandleNigoriConfigurationCompletedOnFrontendLoop,
1338 weak_ptr_factory_.GetWeakPtr(), js_backend), 1325 weak_ptr_factory_.GetWeakPtr(), js_backend),
1339 base::Bind(&SyncBackendHost::OnNigoriDownloadRetry, 1326 base::Bind(&SyncBackendHost::OnNigoriDownloadRetry,
1340 weak_ptr_factory_.GetWeakPtr())); 1327 weak_ptr_factory_.GetWeakPtr()));
1341 break; 1328 break;
1342 case DOWNLOADING_NIGORI: 1329 case DOWNLOADING_NIGORI:
1343 initialization_state_ = REFRESHING_NIGORI; 1330 initialization_state_ = REFRESHING_NIGORI;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 FROM_HERE, 1529 FROM_HERE,
1543 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1530 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1544 core_.get(), sync_thread_done_callback)); 1531 core_.get(), sync_thread_done_callback));
1545 } 1532 }
1546 1533
1547 #undef SDVLOG 1534 #undef SDVLOG
1548 1535
1549 #undef SLOG 1536 #undef SLOG
1550 1537
1551 } // namespace browser_sync 1538 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/glue/sync_backend_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698