Chromium Code Reviews| Index: services/preferences/tracked/registry_hash_store_contents_win.cc |
| diff --git a/services/preferences/tracked/registry_hash_store_contents_win.cc b/services/preferences/tracked/registry_hash_store_contents_win.cc |
| index 76ee57f3cd1caa8aef225a751e17b6578fac7985..5ac0c773486fb44ae33541acd5299489e0b24c48 100644 |
| --- a/services/preferences/tracked/registry_hash_store_contents_win.cc |
| +++ b/services/preferences/tracked/registry_hash_store_contents_win.cc |
| @@ -74,7 +74,8 @@ RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( |
| const base::string16& registry_path, |
| const base::string16& store_key) |
| : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + store_key), |
| - reset_on_delete_(base::StartsWith(store_key, |
| + reset_on_delete_(false), |
| + is_for_test_scoped_dir_(base::StartsWith(store_key, |
| base::ScopedTempDir::GetTempDirPrefix(), |
| base::CompareCase::INSENSITIVE_ASCII)) { |
| } |
| @@ -84,8 +85,19 @@ RegistryHashStoreContentsWin::~RegistryHashStoreContentsWin() { |
| Reset(); |
| } |
| +// To properly write to the Windows registry when Chrome is shutting down, |
| +// a clone of this object is created and passed to a callback which will be |
| +// run on a different thread. This could create a race condition if both the |
| +// orignal and clone are destructed (and try to delete the registry key) at |
|
gab
2017/06/05 18:04:21
s/destructed/destroyed/
proberge
2017/06/06 21:29:52
Done.
|
| +// the same time: only the clone should attempt to delete the registry key. |
| +// Note that this only applies for scoped temporary profiles used in tests. |
| RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( |
| - const RegistryHashStoreContentsWin& other) = default; |
| + const RegistryHashStoreContentsWin& other) : |
| + preference_key_name_(other.preference_key_name_), |
| + reset_on_delete_(other.is_for_test_scoped_dir_), |
| + is_for_test_scoped_dir_(other.is_for_test_scoped_dir_) { |
| + DCHECK_EQ(other.reset_on_delete_, false); |
|
gab
2017/06/05 18:04:21
DCHECK(!other.reset_on_delete_);
proberge
2017/06/06 21:29:52
Done.
|
| +}; |
| bool RegistryHashStoreContentsWin::IsCopyable() const { |
| return true; |