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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor.h

Issue 24269007: Media Galleries API: Fix MediaGalleriesPreferences finders race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 18 matching lines...) Expand all
29 class MediaTransferProtocolManager; 29 class MediaTransferProtocolManager;
30 } 30 }
31 31
32 // Base class for platform-specific instances watching for removable storage 32 // Base class for platform-specific instances watching for removable storage
33 // attachments/detachments. 33 // attachments/detachments.
34 // Lifecycle contracts: This class is created in the browser process 34 // Lifecycle contracts: This class is created in the browser process
35 // before the profile is initialized, so listeners can be 35 // before the profile is initialized, so listeners can be
36 // created during profile construction. The platform-specific initialization, 36 // created during profile construction. The platform-specific initialization,
37 // which can lead to calling registered listeners with notifications of 37 // which can lead to calling registered listeners with notifications of
38 // attached volumes, are done lazily at first use through the async 38 // attached volumes, are done lazily at first use through the async
39 // |Initialize()| method. That must be done before any of the registered 39 // |EnsureInitialized()| method. That must be done before any of the registered
40 // listeners will receive updates or calls to other API methods return 40 // listeners will receive updates or calls to other API methods return
41 // meaningful results. 41 // meaningful results.
42 // A post-initialization |GetAttachedStorage()| call coupled with a 42 // A post-initialization |GetAttachedStorage()| call coupled with a
43 // registered listener will receive a complete set, albeit potentially with 43 // registered listener will receive a complete set, albeit potentially with
44 // duplicates. This is because there's no tracking between when listeners were 44 // duplicates. This is because there's no tracking between when listeners were
45 // registered and the state of initialization, and the fact that platforms 45 // registered and the state of initialization, and the fact that platforms
46 // behave differently in how these notifications are provided. 46 // behave differently in how these notifications are provided.
47 class StorageMonitor { 47 class StorageMonitor {
48 public: 48 public:
49 // This interface is provided to generators of storage notifications. 49 // This interface is provided to generators of storage notifications.
(...skipping 19 matching lines...) Expand all
69 static StorageMonitor* Create(); 69 static StorageMonitor* Create();
70 70
71 // Returns a pointer to an object owned by BrowserProcess, with lifetime 71 // Returns a pointer to an object owned by BrowserProcess, with lifetime
72 // starting before main message loop start, and ending after main message loop 72 // starting before main message loop start, and ending after main message loop
73 // shutdown. Called outside it's lifetime (or with no browser process), 73 // shutdown. Called outside it's lifetime (or with no browser process),
74 // returns NULL. 74 // returns NULL.
75 static StorageMonitor* GetInstance(); 75 static StorageMonitor* GetInstance();
76 76
77 virtual ~StorageMonitor(); 77 virtual ~StorageMonitor();
78 78
79 // Ensures that the storage monitor is initialized. The provided callback, If 79 // Ensures that the storage monitor is initialized. The provided callback, if
80 // non-null, will be called when initialization is complete. If initialization 80 // non-null, will be called when initialization is complete. If initialization
81 // has already completed, this callback will be invoked within the calling 81 // has already completed, this callback will be invoked within the calling
82 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and 82 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and
83 // |GetStorageInfoForPath| may not return the correct results. In addition, 83 // |GetStorageInfoForPath| may not return the correct results. In addition,
84 // registered observers will not be notified on device attachment/detachment. 84 // registered observers will not be notified on device attachment/detachment.
85 // Should be invoked on the UI thread; callbacks will be run on the UI thread. 85 // Should be invoked on the UI thread; callbacks will be run on the UI thread.
86 void EnsureInitialized(base::Closure callback); 86 void EnsureInitialized(base::Closure callback);
87 87
88 // Return true if the storage monitor has already been initialized. 88 // Return true if the storage monitor has already been initialized.
89 bool IsInitialized(); 89 bool IsInitialized() const;
90 90
91 // Finds the device that contains |path| and populates |device_info|. 91 // Finds the device that contains |path| and populates |device_info|.
92 // Should be able to handle any path on the local system, not just removable 92 // Should be able to handle any path on the local system, not just removable
93 // storage. Returns false if unable to find the device. 93 // storage. Returns false if unable to find the device.
94 virtual bool GetStorageInfoForPath( 94 virtual bool GetStorageInfoForPath(
95 const base::FilePath& path, 95 const base::FilePath& path,
96 StorageInfo* device_info) const = 0; 96 StorageInfo* device_info) const = 0;
97 97
98 // TODO(gbillock): make this either unnecessary (implementation-specific) or 98 // TODO(gbillock): make this either unnecessary (implementation-specific) or
99 // platform-independent. 99 // platform-independent.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // For manipulating storage_map_ structure. 171 // For manipulating storage_map_ structure.
172 mutable base::Lock storage_lock_; 172 mutable base::Lock storage_lock_;
173 173
174 // Map of all known storage devices,including fixed and removable storages. 174 // Map of all known storage devices,including fixed and removable storages.
175 StorageMap storage_map_; 175 StorageMap storage_map_;
176 176
177 scoped_ptr<TransientDeviceIds> transient_device_ids_; 177 scoped_ptr<TransientDeviceIds> transient_device_ids_;
178 }; 178 };
179 179
180 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ 180 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698