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

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..af1eef63e1e858c90ad4780af9ba2c655fea67bd 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;
@@ -69,12 +72,15 @@ void MediaGalleriesHandler::InitializeOnStorageMonitorInit() {
}
void MediaGalleriesHandler::RegisterMessages() {
- StorageMonitor::GetInstance()->EnsureInitialized(
- base::Bind(&MediaGalleriesHandler::RegisterOnStorageMonitorInit,
- 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::RegisterOnPreferencesInit,
+ weak_ptr_factory_.GetWeakPtr()));
}
-void MediaGalleriesHandler::RegisterOnStorageMonitorInit() {
+void MediaGalleriesHandler::RegisterOnPreferencesInit() {
web_ui()->RegisterMessageCallback(
"addNewGallery",
base::Bind(&MediaGalleriesHandler::HandleAddNewGallery,
@@ -90,6 +96,7 @@ void MediaGalleriesHandler::OnGalleriesChanged() {
Profile* profile = Profile::FromWebUI(web_ui());
MediaGalleriesPreferences* preferences =
g_browser_process->media_file_system_registry()->GetPreferences(profile);
+ DCHECK(preferences->IsInitialized());
vandebo (ex-Chrome) 2013/09/26 22:42:36 nit: remove
tommycli 2013/09/26 23:53:33 Done.
ListValue list;
const MediaGalleriesPrefInfoMap& galleries = preferences->known_galleries();
@@ -138,6 +145,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());
vandebo (ex-Chrome) 2013/09/26 22:42:36 nit: remove
tommycli 2013/09/26 23:53:33 Done.
preferences->ForgetGalleryById(id);
}
@@ -148,6 +156,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());
vandebo (ex-Chrome) 2013/09/26 22:42:36 nit: remove
tommycli 2013/09/26 23:53:33 Done.
preferences->AddGalleryByPath(path);
}

Powered by Google App Engine
This is Rietveld 408576698