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

Unified Diff: chrome/browser/ui/webui/options/media_galleries_handler.cc

Issue 24269007: Media Galleries API: Fix MediaGalleriesPreferences finders race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/media_galleries_handler.cc
diff --git a/chrome/browser/ui/webui/options/media_galleries_handler.cc b/chrome/browser/ui/webui/options/media_galleries_handler.cc
index 982aaeb2aa5c9a0f0b4f5e0278f870a58431c884..0a676f6a6fb25541a8a4d2f7701bc85c320a6292 100644
--- a/chrome/browser/ui/webui/options/media_galleries_handler.cc
+++ b/chrome/browser/ui/webui/options/media_galleries_handler.cc
@@ -47,12 +47,15 @@ void MediaGalleriesHandler::GetLocalizedValues(DictionaryValue* values) {
}
void MediaGalleriesHandler::InitializePage() {
- StorageMonitor::GetInstance()->EnsureInitialized(
- base::Bind(&MediaGalleriesHandler::InitializeOnStorageMonitorInit,
- weak_ptr_factory_.GetWeakPtr()));
+ Profile* profile = Profile::FromWebUI(web_ui());
+ MediaGalleriesPreferences* preferences =
+ g_browser_process->media_file_system_registry()->GetPreferences(profile);
+ preferences->EnsureInitialized(base::Bind(
+ &MediaGalleriesHandler::InitializeOnMediaGalleriesPreferencesInit,
+ weak_ptr_factory_.GetWeakPtr()));
}
-void MediaGalleriesHandler::InitializeOnStorageMonitorInit() {
+void MediaGalleriesHandler::InitializeOnMediaGalleriesPreferencesInit() {
Profile* profile = Profile::FromWebUI(web_ui());
if (!MediaGalleriesPreferences::APIHasBeenUsed(profile))
return;
@@ -90,6 +93,7 @@ void MediaGalleriesHandler::OnGalleriesChanged() {
Profile* profile = Profile::FromWebUI(web_ui());
MediaGalleriesPreferences* preferences =
g_browser_process->media_file_system_registry()->GetPreferences(profile);
+ DCHECK(preferences->IsInitialized());
ListValue list;
const MediaGalleriesPrefInfoMap& galleries = preferences->known_galleries();
@@ -138,6 +142,7 @@ void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) {
MediaGalleriesPreferences* preferences =
g_browser_process->media_file_system_registry()->GetPreferences(
Profile::FromWebUI(web_ui()));
+ DCHECK(preferences->IsInitialized());
preferences->ForgetGalleryById(id);
}
@@ -148,6 +153,7 @@ void MediaGalleriesHandler::FileSelected(const base::FilePath& path,
MediaGalleriesPreferences* preferences =
g_browser_process->media_file_system_registry()->GetPreferences(
Profile::FromWebUI(web_ui()));
+ DCHECK(preferences->IsInitialized());
preferences->AddGalleryByPath(path);
}

Powered by Google App Engine
This is Rietveld 408576698