OLD | NEW |
---|---|
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 "components/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/browser/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1523 } | 1523 } |
1524 | 1524 |
1525 bool ProfileSyncService::CanConfigureDataTypes() const { | 1525 bool ProfileSyncService::CanConfigureDataTypes() const { |
1526 return IsFirstSetupComplete() && !IsSetupInProgress(); | 1526 return IsFirstSetupComplete() && !IsSetupInProgress(); |
1527 } | 1527 } |
1528 | 1528 |
1529 bool ProfileSyncService::IsFirstSetupInProgress() const { | 1529 bool ProfileSyncService::IsFirstSetupInProgress() const { |
1530 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress(); | 1530 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress(); |
1531 } | 1531 } |
1532 | 1532 |
1533 void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { | 1533 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> |
1534 // This method is a no-op if |setup_in_progress_| remains unchanged. | 1534 ProfileSyncService::GetSetupInProgressHandle() { |
1535 if (startup_controller_->IsSetupInProgress() == setup_in_progress) | 1535 if (++outstanding_setup_in_progress_handles_ == 1 && |
1536 return; | 1536 !startup_controller_->IsSetupInProgress()) { |
maxbogue
2016/06/10 17:28:46
You could probably DCHECK the !IsSetupInProgress p
tommycli
2016/06/10 18:58:21
Done. You're right that would really surprise me.
| |
1537 startup_controller_->SetSetupInProgress(true); | |
1538 NotifyObservers(); | |
1539 } | |
1537 | 1540 |
1538 startup_controller_->SetSetupInProgress(setup_in_progress); | 1541 return std::unique_ptr<sync_driver::SyncSetupInProgressHandle>( |
1539 if (!setup_in_progress && IsBackendInitialized()) | 1542 new sync_driver::SyncSetupInProgressHandle( |
1540 ReconfigureDatatypeManager(); | 1543 base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed, |
1541 NotifyObservers(); | 1544 weak_factory_.GetWeakPtr()))); |
1542 } | 1545 } |
1543 | 1546 |
1544 bool ProfileSyncService::IsSyncAllowed() const { | 1547 bool ProfileSyncService::IsSyncAllowed() const { |
1545 return IsSyncAllowedByFlag() && !IsManaged() && IsSyncAllowedByPlatform(); | 1548 return IsSyncAllowedByFlag() && !IsManaged() && IsSyncAllowedByPlatform(); |
1546 } | 1549 } |
1547 | 1550 |
1548 bool ProfileSyncService::IsSyncActive() const { | 1551 bool ProfileSyncService::IsSyncActive() const { |
1549 return backend_initialized_ && data_type_manager_ && | 1552 return backend_initialized_ && data_type_manager_ && |
1550 data_type_manager_->state() != DataTypeManager::STOPPED; | 1553 data_type_manager_->state() != DataTypeManager::STOPPED; |
1551 } | 1554 } |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2537 } | 2540 } |
2538 | 2541 |
2539 std::string ProfileSyncService::unrecoverable_error_message() const { | 2542 std::string ProfileSyncService::unrecoverable_error_message() const { |
2540 return unrecoverable_error_message_; | 2543 return unrecoverable_error_message_; |
2541 } | 2544 } |
2542 | 2545 |
2543 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() | 2546 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() |
2544 const { | 2547 const { |
2545 return unrecoverable_error_location_; | 2548 return unrecoverable_error_location_; |
2546 } | 2549 } |
2550 | |
2551 void ProfileSyncService::OnSetupInProgressHandleDestroyed() { | |
2552 // Don't re-start Sync until all outstanding handles are destroyed. | |
2553 if (--outstanding_setup_in_progress_handles_ != 0) | |
2554 return; | |
2555 | |
2556 if (!startup_controller_->IsSetupInProgress()) | |
maxbogue
2016/06/10 17:28:46
Same as above, would it make sense to DCHECK inste
tommycli
2016/06/10 18:58:20
Done.
| |
2557 return; | |
2558 | |
2559 startup_controller_->SetSetupInProgress(false); | |
2560 if (IsBackendInitialized()) | |
2561 ReconfigureDatatypeManager(); | |
2562 NotifyObservers(); | |
2563 } | |
OLD | NEW |