| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Status codes for the result of an EjectDevice() call. | 63 // Status codes for the result of an EjectDevice() call. |
| 64 enum EjectStatus { | 64 enum EjectStatus { |
| 65 EJECT_OK, | 65 EJECT_OK, |
| 66 EJECT_IN_USE, | 66 EJECT_IN_USE, |
| 67 EJECT_NO_SUCH_DEVICE, | 67 EJECT_NO_SUCH_DEVICE, |
| 68 EJECT_FAILURE | 68 EJECT_FAILURE |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Returns a pointer to a created per-platform object with the StorageMonitor |
| 72 // interface. |
| 73 static StorageMonitor* Create(); |
| 74 |
| 71 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime | 75 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime |
| 72 // somewhat shorter than a process Singleton. | 76 // somewhat shorter than a process Singleton. |
| 73 static StorageMonitor* GetInstance(); | 77 static StorageMonitor* GetInstance(); |
| 74 | 78 |
| 79 StorageMonitor(); |
| 80 virtual ~StorageMonitor(); |
| 75 // Ensures that the storage monitor is initialized. The provided callback, If | 81 // Ensures that the storage monitor is initialized. The provided callback, If |
| 76 // non-null, will be called when initialization is complete. If initialization | 82 // non-null, will be called when initialization is complete. If initialization |
| 77 // has already completed, this callback will be invoked within the calling | 83 // has already completed, this callback will be invoked within the calling |
| 78 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and | 84 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and |
| 79 // |GetStorageInfoForPath| may not return the correct results. In addition, | 85 // |GetStorageInfoForPath| may not return the correct results. In addition, |
| 80 // registered observers will not be notified on device attachment/detachment. | 86 // registered observers will not be notified on device attachment/detachment. |
| 81 // Should be invoked on the UI thread; callbacks will be run on the UI thread. | 87 // Should be invoked on the UI thread; callbacks will be run on the UI thread. |
| 82 void EnsureInitialized(base::Closure callback); | 88 void EnsureInitialized(base::Closure callback); |
| 83 | 89 |
| 84 // Return true if the storage monitor has already been initialized. | 90 // Return true if the storage monitor has already been initialized. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 const std::string& device_id, | 130 const std::string& device_id, |
| 125 base::Callback<void(EjectStatus)> callback); | 131 base::Callback<void(EjectStatus)> callback); |
| 126 | 132 |
| 127 protected: | 133 protected: |
| 128 friend class ::MediaGalleriesPlatformAppBrowserTest; | 134 friend class ::MediaGalleriesPlatformAppBrowserTest; |
| 129 friend class ::MediaGalleriesPrivateApiTest; | 135 friend class ::MediaGalleriesPrivateApiTest; |
| 130 friend class ::MediaGalleriesPrivateEjectApiTest; | 136 friend class ::MediaGalleriesPrivateEjectApiTest; |
| 131 friend class MediaFileSystemRegistryTest; | 137 friend class MediaFileSystemRegistryTest; |
| 132 friend class ::SystemInfoStorageApiTest; | 138 friend class ::SystemInfoStorageApiTest; |
| 133 | 139 |
| 134 StorageMonitor(); | |
| 135 virtual ~StorageMonitor(); | |
| 136 | |
| 137 // Removes the existing singleton for testing. | 140 // Removes the existing singleton for testing. |
| 138 // (So that a new one can be created.) | 141 // (So that a new one can be created.) |
| 139 static void RemoveSingletonForTesting(); | 142 static void RemoveSingletonForTesting(); |
| 140 | 143 |
| 141 virtual Receiver* receiver() const; | 144 virtual Receiver* receiver() const; |
| 142 | 145 |
| 143 // Called to initialize the storage monitor. | 146 // Called to initialize the storage monitor. |
| 144 virtual void Init() = 0; | 147 virtual void Init() = 0; |
| 145 | 148 |
| 146 // Called by subclasses to mark the storage monitor as | 149 // Called by subclasses to mark the storage monitor as |
| (...skipping 27 matching lines...) Expand all Loading... |
| 174 | 177 |
| 175 // Map of all known storage devices,including fixed and removable storages. | 178 // Map of all known storage devices,including fixed and removable storages. |
| 176 StorageMap storage_map_; | 179 StorageMap storage_map_; |
| 177 | 180 |
| 178 scoped_ptr<TransientDeviceIds> transient_device_ids_; | 181 scoped_ptr<TransientDeviceIds> transient_device_ids_; |
| 179 }; | 182 }; |
| 180 | 183 |
| 181 } // namespace chrome | 184 } // namespace chrome |
| 182 | 185 |
| 183 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 186 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
| OLD | NEW |