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

Side by Side Diff: services/preferences/tracked/registry_hash_store_contents_win.cc

Issue 2926453002: Fix a race condition in ~RegistryHashStoreContentsWin (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « services/preferences/tracked/registry_hash_store_contents_win.h ('k') | no next file » | 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) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "services/preferences/tracked/registry_hash_store_contents_win.h" 5 #include "services/preferences/tracked/registry_hash_store_contents_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 return false; 68 return false;
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( 73 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin(
74 const base::string16& registry_path, 74 const base::string16& registry_path,
75 const base::string16& store_key) 75 const base::string16& store_key)
76 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + store_key), 76 : preference_key_name_(registry_path + L"\\PreferenceMACs\\" + store_key),
77 reset_on_delete_(base::StartsWith(store_key, 77 reset_on_delete_(false),
78 is_for_test_scoped_dir_(base::StartsWith(store_key,
78 base::ScopedTempDir::GetTempDirPrefix(), 79 base::ScopedTempDir::GetTempDirPrefix(),
79 base::CompareCase::INSENSITIVE_ASCII)) { 80 base::CompareCase::INSENSITIVE_ASCII)) {
80 } 81 }
81 82
82 RegistryHashStoreContentsWin::~RegistryHashStoreContentsWin() { 83 RegistryHashStoreContentsWin::~RegistryHashStoreContentsWin() {
83 if (reset_on_delete_) 84 if (reset_on_delete_)
84 Reset(); 85 Reset();
85 } 86 }
86 87
88 // To properly write to the Windows registry when Chrome is shutting down,
89 // a clone of this object is created and passed to a callback which will be
90 // run on a different thread. This could create a race condition if both the
91 // 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.
92 // the same time: only the clone should attempt to delete the registry key.
93 // Note that this only applies for scoped temporary profiles used in tests.
87 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin( 94 RegistryHashStoreContentsWin::RegistryHashStoreContentsWin(
88 const RegistryHashStoreContentsWin& other) = default; 95 const RegistryHashStoreContentsWin& other) :
96 preference_key_name_(other.preference_key_name_),
97 reset_on_delete_(other.is_for_test_scoped_dir_),
98 is_for_test_scoped_dir_(other.is_for_test_scoped_dir_) {
99 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.
100 };
89 101
90 bool RegistryHashStoreContentsWin::IsCopyable() const { 102 bool RegistryHashStoreContentsWin::IsCopyable() const {
91 return true; 103 return true;
92 } 104 }
93 105
94 std::unique_ptr<HashStoreContents> RegistryHashStoreContentsWin::MakeCopy() 106 std::unique_ptr<HashStoreContents> RegistryHashStoreContentsWin::MakeCopy()
95 const { 107 const {
96 return base::WrapUnique(new RegistryHashStoreContentsWin(*this)); 108 return base::WrapUnique(new RegistryHashStoreContentsWin(*this));
97 } 109 }
98 110
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 std::string RegistryHashStoreContentsWin::GetSuperMac() const { 196 std::string RegistryHashStoreContentsWin::GetSuperMac() const {
185 NOTREACHED() 197 NOTREACHED()
186 << "RegistryHashStoreContents does not support the GetSuperMac operation"; 198 << "RegistryHashStoreContents does not support the GetSuperMac operation";
187 return NULL; 199 return NULL;
188 } 200 }
189 201
190 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) { 202 void RegistryHashStoreContentsWin::SetSuperMac(const std::string& super_mac) {
191 NOTREACHED() 203 NOTREACHED()
192 << "RegistryHashStoreContents does not support the SetSuperMac operation"; 204 << "RegistryHashStoreContents does not support the SetSuperMac operation";
193 } 205 }
OLDNEW
« no previous file with comments | « services/preferences/tracked/registry_hash_store_contents_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698