| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_CROS_MOUNT_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void* object) = 0; | 48 void* object) = 0; |
| 49 virtual void CallRequestMountInfo(RequestMountInfoCallback callback, | 49 virtual void CallRequestMountInfo(RequestMountInfoCallback callback, |
| 50 void* object) = 0; | 50 void* object) = 0; |
| 51 virtual void CallFormatDevice(const char* device_path, | 51 virtual void CallFormatDevice(const char* device_path, |
| 52 const char* filesystem, | 52 const char* filesystem, |
| 53 FormatRequestCallback callback, | 53 FormatRequestCallback callback, |
| 54 void* object) = 0; | 54 void* object) = 0; |
| 55 virtual void CallGetDiskProperties(const char* device_path, | 55 virtual void CallGetDiskProperties(const char* device_path, |
| 56 GetDiskPropertiesCallback callback, | 56 GetDiskPropertiesCallback callback, |
| 57 void* object) = 0; | 57 void* object) = 0; |
| 58 virtual void CallGetSizeStats(const char* mount_path, |
| 59 GetSizeStatsCallback callback, |
| 60 void* object) = 0; |
| 58 virtual MountEventConnection MonitorCrosDisks(MountEventMonitor monitor, | 61 virtual MountEventConnection MonitorCrosDisks(MountEventMonitor monitor, |
| 59 MountCompletedMonitor mount_complete_monitor, | 62 MountCompletedMonitor mount_complete_monitor, |
| 60 void* object) = 0; | 63 void* object) = 0; |
| 61 virtual void DisconnectCrosDisksMonitorIfSet(MountEventConnection connection) | 64 virtual void DisconnectCrosDisksMonitorIfSet(MountEventConnection connection) |
| 62 = 0; | 65 = 0; |
| 63 }; | 66 }; |
| 64 | 67 |
| 65 // This class handles the interaction with the ChromeOS mount library APIs. | 68 // This class handles the interaction with the ChromeOS mount library APIs. |
| 66 // Classes can add themselves as observers. Users can get an instance of this | 69 // Classes can add themselves as observers. Users can get an instance of this |
| 67 // library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary() | 70 // library class like this: chromeos::CrosLibrary::Get()->GetMountLibrary() |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Async API events. | 166 // Async API events. |
| 164 virtual void DiskChanged(MountLibraryEventType event, | 167 virtual void DiskChanged(MountLibraryEventType event, |
| 165 const Disk* disk) = 0; | 168 const Disk* disk) = 0; |
| 166 virtual void DeviceChanged(MountLibraryEventType event, | 169 virtual void DeviceChanged(MountLibraryEventType event, |
| 167 const std::string& device_path) = 0; | 170 const std::string& device_path) = 0; |
| 168 virtual void MountCompleted(MountEvent event_type, | 171 virtual void MountCompleted(MountEvent event_type, |
| 169 MountError error_code, | 172 MountError error_code, |
| 170 const MountPointInfo& mount_info) = 0; | 173 const MountPointInfo& mount_info) = 0; |
| 171 }; | 174 }; |
| 172 | 175 |
| 176 class CallbackDelegate { |
| 177 public: |
| 178 virtual ~CallbackDelegate() {} |
| 179 virtual void GetSizeStatsCallback(const char* mount_path, |
| 180 bool success, |
| 181 size_t total_size_kb, |
| 182 size_t remaining_size_kb) = 0; |
| 183 }; |
| 184 |
| 173 virtual ~MountLibrary() {} | 185 virtual ~MountLibrary() {} |
| 174 virtual void AddObserver(Observer* observer) = 0; | 186 virtual void AddObserver(Observer* observer) = 0; |
| 175 virtual void RemoveObserver(Observer* observer) = 0; | 187 virtual void RemoveObserver(Observer* observer) = 0; |
| 176 virtual const DiskMap& disks() const = 0; | 188 virtual const DiskMap& disks() const = 0; |
| 177 virtual const MountPointMap& mount_points() const = 0; | 189 virtual const MountPointMap& mount_points() const = 0; |
| 178 | 190 |
| 179 virtual void RequestMountInfoRefresh() = 0; | 191 virtual void RequestMountInfoRefresh() = 0; |
| 180 virtual void MountPath(const char* source_path, | 192 virtual void MountPath(const char* source_path, |
| 181 MountType type, | 193 MountType type, |
| 182 const MountPathOptions& options) = 0; | 194 const MountPathOptions& options) = 0; |
| 183 // |path| is device's mount path. | 195 // |path| is device's mount path. |
| 184 virtual void UnmountPath(const char* path) = 0; | 196 virtual void UnmountPath(const char* path) = 0; |
| 185 | 197 |
| 198 // Retrieves total and remaining available size on |mount_path|. |
| 199 virtual void GetSizeStats(const char* mount_path, |
| 200 CallbackDelegate* callback_delegate) = 0; |
| 201 |
| 186 // Formats device given its file path. | 202 // Formats device given its file path. |
| 187 // Example: file_path: /dev/sdb1 | 203 // Example: file_path: /dev/sdb1 |
| 188 virtual void FormatUnmountedDevice(const char* file_path) = 0; | 204 virtual void FormatUnmountedDevice(const char* file_path) = 0; |
| 189 | 205 |
| 190 // Formats Device given its mount path. Unmount's the device | 206 // Formats Device given its mount path. Unmount's the device |
| 191 // Example: mount_path: /media/VOLUME_LABEL | 207 // Example: mount_path: /media/VOLUME_LABEL |
| 192 virtual void FormatMountedDevice(const char* mount_path) = 0; | 208 virtual void FormatMountedDevice(const char* mount_path) = 0; |
| 193 | 209 |
| 194 // Unmounts device_poath and all of its known children. | 210 // Unmounts device_poath and all of its known children. |
| 195 virtual void UnmountDeviceRecursive(const char* device_path, | 211 virtual void UnmountDeviceRecursive(const char* device_path, |
| 196 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; | 212 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; |
| 197 | 213 |
| 198 // Helper functions for parameter conversions. | 214 // Helper functions for parameter conversions. |
| 199 static std::string MountTypeToString(MountType type); | 215 static std::string MountTypeToString(MountType type); |
| 200 static MountType MountTypeFromString(const std::string& type_str); | 216 static MountType MountTypeFromString(const std::string& type_str); |
| 201 static std::string MountConditionToString(MountCondition type); | 217 static std::string MountConditionToString(MountCondition type); |
| 202 | 218 |
| 203 // Used in testing. Enables mocking libcros. | 219 // Used in testing. Enables mocking libcros. |
| 204 virtual void SetLibcrosProxy(MountLibcrosProxy* proxy) {} | 220 virtual void SetLibcrosProxy(MountLibcrosProxy* proxy) {} |
| 205 | 221 |
| 206 // Factory function, creates a new instance and returns ownership. | 222 // Factory function, creates a new instance and returns ownership. |
| 207 // For normal usage, access the singleton via CrosLibrary::Get(). | 223 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 208 static MountLibrary* GetImpl(bool stub); | 224 static MountLibrary* GetImpl(bool stub); |
| 209 }; | 225 }; |
| 210 | 226 |
| 211 } // namespace chromeos | 227 } // namespace chromeos |
| 212 | 228 |
| 213 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ | 229 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ |
| OLD | NEW |