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

Side by Side Diff: chrome/browser/extensions/external_registry_loader_win.cc

Issue 2809293004: Fix windows registry loader to carry over prefs from file thread correctly (Closed)
Patch Set: add test Created 3 years, 8 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
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 "chrome/browser/extensions/external_registry_loader_win.h" 5 #include "chrome/browser/extensions/external_registry_loader_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_file.h" 10 #include "base/files/scoped_file.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 prefs->SetBoolean( 183 prefs->SetBoolean(
184 MakePrefName(id, ExternalProviderImpl::kMayBeUntrusted), 184 MakePrefName(id, ExternalProviderImpl::kMayBeUntrusted),
185 true); 185 true);
186 } 186 }
187 187
188 return prefs; 188 return prefs;
189 } 189 }
190 190
191 void ExternalRegistryLoader::LoadOnFileThread() { 191 void ExternalRegistryLoader::LoadOnFileThread() {
192 base::TimeTicks start_time = base::TimeTicks::Now(); 192 base::TimeTicks start_time = base::TimeTicks::Now();
193 prefs_ = LoadPrefsOnFileThread(); 193 std::unique_ptr<base::DictionaryValue> prefs = LoadPrefsOnFileThread();
194 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", 194 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin",
195 base::TimeTicks::Now() - start_time); 195 base::TimeTicks::Now() - start_time);
196 BrowserThread::PostTask( 196 BrowserThread::PostTask(
197 BrowserThread::UI, FROM_HERE, 197 BrowserThread::UI, FROM_HERE,
198 base::Bind(&ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry, 198 base::Bind(&ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry,
199 this)); 199 this, base::Passed(&prefs)));
200 } 200 }
201 201
202 void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry() { 202 void ExternalRegistryLoader::CompleteLoadAndStartWatchingRegistry(
203 std::unique_ptr<base::DictionaryValue> prefs) {
203 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 204 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
205 DCHECK(prefs);
206 prefs_ = std::move(prefs);
204 LoadFinished(); 207 LoadFinished();
Devlin 2017/04/12 19:32:06 I *think* this is safe - or rather, I think this w
lazyboy 2017/04/12 20:56:22 I was actually thinking about that while writing t
205 208
206 // Attempt to watch registry if we haven't already. 209 // Attempt to watch registry if we haven't already.
207 if (attempted_watching_registry_) 210 if (attempted_watching_registry_)
208 return; 211 return;
209 212
210 LONG result = ERROR_SUCCESS; 213 LONG result = ERROR_SUCCESS;
211 if ((result = hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions, 214 if ((result = hklm_key_.Create(HKEY_LOCAL_MACHINE, kRegistryExtensions,
212 KEY_NOTIFY | KEY_WOW64_32KEY)) == 215 KEY_NOTIFY | KEY_WOW64_32KEY)) ==
213 ERROR_SUCCESS) { 216 ERROR_SUCCESS) {
214 base::win::RegKey::ChangeCallback callback = 217 base::win::RegKey::ChangeCallback callback =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::TimeTicks start_time = base::TimeTicks::Now(); 251 base::TimeTicks start_time = base::TimeTicks::Now();
249 std::unique_ptr<base::DictionaryValue> prefs = LoadPrefsOnFileThread(); 252 std::unique_ptr<base::DictionaryValue> prefs = LoadPrefsOnFileThread();
250 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWinUpdate", 253 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWinUpdate",
251 base::TimeTicks::Now() - start_time); 254 base::TimeTicks::Now() - start_time);
252 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 255 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
253 base::Bind(&ExternalRegistryLoader::OnUpdated, this, 256 base::Bind(&ExternalRegistryLoader::OnUpdated, this,
254 base::Passed(&prefs))); 257 base::Passed(&prefs)));
255 } 258 }
256 259
257 } // namespace extensions 260 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698