Commit bd319a43 authored by dmichael's avatar dmichael Committed by Commit bot

Make ProfileSyncService's WeakPtrFactory the last member

This will ensure that WeakPtrs are invalidated before any other members'
destructors are invoked. This is also one of the last classes needing to
change to allow us to turn on a Clang check for WeakPtrFactory member order.
Please see the bug for more details.

BUG=303818

Review URL: https://codereview.chromium.org/795003003

Cr-Commit-Position: refs/heads/master@{#308015}
parent 27e8203c
This diff is collapsed.
......@@ -1113,16 +1113,6 @@ class ProfileSyncService : public ProfileSyncServiceBase,
base::OneShotTimer<ProfileSyncService> request_access_token_retry_timer_;
net::BackoffEntry request_access_token_backoff_;
base::WeakPtrFactory<ProfileSyncService> weak_factory_;
// We don't use |weak_factory_| for the StartupController because the weak
// ptrs should be bound to the lifetime of ProfileSyncService and not to the
// [Initialize -> sync disabled/shutdown] lifetime. We don't pass
// StartupController an Unretained reference to future-proof against
// the controller impl changing to post tasks. Therefore, we have a separate
// factory.
base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_;
// States related to sync token and connection.
base::Time connection_status_update_time_;
syncer::ConnectionStatus connection_status_;
......@@ -1139,9 +1129,10 @@ class ProfileSyncService : public ProfileSyncServiceBase,
scoped_ptr<syncer::NetworkResources> network_resources_;
browser_sync::StartupController startup_controller_;
scoped_ptr<browser_sync::StartupController> startup_controller_;
browser_sync::BackupRollbackController backup_rollback_controller_;
scoped_ptr<browser_sync::BackupRollbackController>
backup_rollback_controller_;
// Mode of current backend.
BackendMode backend_mode_;
......@@ -1167,6 +1158,16 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// The full path to the sync data directory.
base::FilePath directory_path_;
base::WeakPtrFactory<ProfileSyncService> weak_factory_;
// We don't use |weak_factory_| for the StartupController because the weak
// ptrs should be bound to the lifetime of ProfileSyncService and not to the
// [Initialize -> sync disabled/shutdown] lifetime. We don't pass
// StartupController an Unretained reference to future-proof against
// the controller impl changing to post tasks. Therefore, we have a separate
// factory.
base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment