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

Unified Diff: chrome/browser/storage_monitor/storage_monitor.h

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge Created 7 years, 7 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/storage_monitor/storage_monitor.h
diff --git a/chrome/browser/storage_monitor/storage_monitor.h b/chrome/browser/storage_monitor/storage_monitor.h
index b330a29de9c16bdb42d1c48fce6317717d5fb276..976bbddbcf5a15588cfda54577a51a2f84af0839 100644
--- a/chrome/browser/storage_monitor/storage_monitor.h
+++ b/chrome/browser/storage_monitor/storage_monitor.h
@@ -39,7 +39,15 @@ class TransientDeviceIds;
// implementations before the profile is initialized, so listeners can be
// created during profile construction. The platform-specific initialization,
// which can lead to calling registered listeners with notifications of
-// attached volumes, will happen after profile construction.
+// attached volumes, are done lazily at first use through the async
+// |Initialize()| method. That must be done before any of the registered
+// listeners will receive updates or calls to other API methods return
+// meaningful results.
+// A post-initialization |GetAttachedStorage()| call coupled with a
+// registered listener will receive a complete set, albeit potentially with
+// duplicates. This is because there's no tracking between when listeners were
+// registered and the state of initialization, and the fact that platforms
+// behave differently in how these notifications are provided.
class StorageMonitor {
public:
// This interface is provided to generators of storage notifications.
@@ -153,6 +161,10 @@ class StorageMonitor {
scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> >
observer_list_;
+ // Used to make sure we call initialize from the same thread as creation.
+ base::ThreadChecker thread_checker_;
+
+ bool initializing_;
bool initialized_;
std::vector<base::Closure> on_initialize_callbacks_;

Powered by Google App Engine
This is Rietveld 408576698