Chromium Code Reviews| 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 an object owned by the BrowserMainParts, with lifetime | 71 // Returns a pointer to a created per-platform object with the StorageMonitor |
| 72 // somewhat shorter than a process Singleton. | 72 // interface. |
| 73 static StorageMonitor* Create(); | |
| 74 | |
| 75 // Returns a pointer to an object owned by BrowserProcess, with lifetime | |
| 76 // starting before main message loop start, and ending after main message loop | |
| 77 // shutdown. | |
| 73 static StorageMonitor* GetInstance(); | 78 static StorageMonitor* GetInstance(); |
| 74 | 79 |
| 80 StorageMonitor(); | |
|
Lei Zhang
2013/07/03 23:25:10
The ctor should be protected, so one has to use Ge
Greg Billock
2013/07/08 18:50:07
Done. Shall I move Create() and friend needed clas
| |
| 81 virtual ~StorageMonitor(); | |
| 82 | |
| 75 // Ensures that the storage monitor is initialized. The provided callback, If | 83 // Ensures that the storage monitor is initialized. The provided callback, If |
| 76 // non-null, will be called when initialization is complete. If initialization | 84 // non-null, will be called when initialization is complete. If initialization |
| 77 // has already completed, this callback will be invoked within the calling | 85 // has already completed, this callback will be invoked within the calling |
| 78 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and | 86 // stack. Before the callback is run, calls to |GetAllAvailableStorages| and |
| 79 // |GetStorageInfoForPath| may not return the correct results. In addition, | 87 // |GetStorageInfoForPath| may not return the correct results. In addition, |
| 80 // registered observers will not be notified on device attachment/detachment. | 88 // 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. | 89 // Should be invoked on the UI thread; callbacks will be run on the UI thread. |
| 82 void EnsureInitialized(base::Closure callback); | 90 void EnsureInitialized(base::Closure callback); |
| 83 | 91 |
| 84 // Return true if the storage monitor has already been initialized. | 92 // 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, | 132 const std::string& device_id, |
| 125 base::Callback<void(EjectStatus)> callback); | 133 base::Callback<void(EjectStatus)> callback); |
| 126 | 134 |
| 127 protected: | 135 protected: |
| 128 friend class ::MediaGalleriesPlatformAppBrowserTest; | 136 friend class ::MediaGalleriesPlatformAppBrowserTest; |
| 129 friend class ::MediaGalleriesPrivateApiTest; | 137 friend class ::MediaGalleriesPrivateApiTest; |
| 130 friend class ::MediaGalleriesPrivateEjectApiTest; | 138 friend class ::MediaGalleriesPrivateEjectApiTest; |
| 131 friend class MediaFileSystemRegistryTest; | 139 friend class MediaFileSystemRegistryTest; |
| 132 friend class ::SystemInfoStorageApiTest; | 140 friend class ::SystemInfoStorageApiTest; |
| 133 | 141 |
| 134 StorageMonitor(); | |
| 135 virtual ~StorageMonitor(); | |
| 136 | |
| 137 // Removes the existing singleton for testing. | |
| 138 // (So that a new one can be created.) | |
| 139 static void RemoveSingletonForTesting(); | |
| 140 | |
| 141 virtual Receiver* receiver() const; | 142 virtual Receiver* receiver() const; |
| 142 | 143 |
| 143 // Called to initialize the storage monitor. | 144 // Called to initialize the storage monitor. |
| 144 virtual void Init() = 0; | 145 virtual void Init() = 0; |
| 145 | 146 |
| 146 // Called by subclasses to mark the storage monitor as | 147 // Called by subclasses to mark the storage monitor as |
| 147 // fully initialized. Must be called on the UI thread. | 148 // fully initialized. Must be called on the UI thread. |
| 148 void MarkInitialized(); | 149 void MarkInitialized(); |
| 149 | 150 |
| 150 private: | 151 private: |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 174 | 175 |
| 175 // Map of all known storage devices,including fixed and removable storages. | 176 // Map of all known storage devices,including fixed and removable storages. |
| 176 StorageMap storage_map_; | 177 StorageMap storage_map_; |
| 177 | 178 |
| 178 scoped_ptr<TransientDeviceIds> transient_device_ids_; | 179 scoped_ptr<TransientDeviceIds> transient_device_ids_; |
| 179 }; | 180 }; |
| 180 | 181 |
| 181 } // namespace chrome | 182 } // namespace chrome |
| 182 | 183 |
| 183 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ | 184 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_H_ |
| OLD | NEW |