| 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 11 matching lines...) Expand all Loading... |
| 22 MOUNT_DISK_CHANGED, | 22 MOUNT_DISK_CHANGED, |
| 23 MOUNT_DISK_MOUNTED, | 23 MOUNT_DISK_MOUNTED, |
| 24 MOUNT_DISK_UNMOUNTED, | 24 MOUNT_DISK_UNMOUNTED, |
| 25 MOUNT_DEVICE_ADDED, | 25 MOUNT_DEVICE_ADDED, |
| 26 MOUNT_DEVICE_REMOVED, | 26 MOUNT_DEVICE_REMOVED, |
| 27 MOUNT_DEVICE_SCANNED, | 27 MOUNT_DEVICE_SCANNED, |
| 28 MOUNT_FORMATTING_STARTED, | 28 MOUNT_FORMATTING_STARTED, |
| 29 MOUNT_FORMATTING_FINISHED | 29 MOUNT_FORMATTING_FINISHED |
| 30 } MountLibraryEventType; | 30 } MountLibraryEventType; |
| 31 | 31 |
| 32 typedef enum MountCondition { |
| 33 MOUNT_CONDITION_NONE, |
| 34 MOUNT_CONDITION_UNKNOWN_FILESYSTEM, |
| 35 MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM |
| 36 } MountCondition; |
| 37 |
| 32 class MountLibcrosProxy { | 38 class MountLibcrosProxy { |
| 33 public: | 39 public: |
| 34 virtual ~MountLibcrosProxy() {} | 40 virtual ~MountLibcrosProxy() {} |
| 35 virtual void CallMountPath(const char* source_path, | 41 virtual void CallMountPath(const char* source_path, |
| 36 MountType type, | 42 MountType type, |
| 37 const MountPathOptions& options, | 43 const MountPathOptions& options, |
| 38 MountCompletedMonitor callback, | 44 MountCompletedMonitor callback, |
| 39 void* object) = 0; | 45 void* object) = 0; |
| 40 virtual void CallUnmountPath(const char* path, | 46 virtual void CallUnmountPath(const char* path, |
| 41 UnmountRequestCallback callback, | 47 UnmountRequestCallback callback, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 bool has_media_; | 134 bool has_media_; |
| 129 bool on_boot_device_; | 135 bool on_boot_device_; |
| 130 }; | 136 }; |
| 131 typedef std::map<std::string, Disk*> DiskMap; | 137 typedef std::map<std::string, Disk*> DiskMap; |
| 132 typedef std::map<std::string, std::string> PathMap; | 138 typedef std::map<std::string, std::string> PathMap; |
| 133 | 139 |
| 134 struct MountPointInfo { | 140 struct MountPointInfo { |
| 135 std::string source_path; | 141 std::string source_path; |
| 136 std::string mount_path; | 142 std::string mount_path; |
| 137 MountType mount_type; | 143 MountType mount_type; |
| 144 MountCondition mount_condition; |
| 138 | 145 |
| 139 MountPointInfo(const char* source, const char* mount, const MountType type) | 146 MountPointInfo(const char* source, const char* mount, const MountType type, |
| 147 MountCondition condition) |
| 140 : source_path(source ? source : ""), | 148 : source_path(source ? source : ""), |
| 141 mount_path(mount ? mount : ""), | 149 mount_path(mount ? mount : ""), |
| 142 mount_type(type) { | 150 mount_type(type), |
| 151 mount_condition(condition) { |
| 143 } | 152 } |
| 144 }; | 153 }; |
| 145 | 154 |
| 146 // MountPointMap key is mount_path. | 155 // MountPointMap key is mount_path. |
| 147 typedef std::map<std::string, MountPointInfo> MountPointMap; | 156 typedef std::map<std::string, MountPointInfo> MountPointMap; |
| 148 | 157 |
| 149 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); | 158 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); |
| 150 | 159 |
| 151 class Observer { | 160 class Observer { |
| 152 public: | 161 public: |
| 153 virtual ~Observer() {} | 162 virtual ~Observer() {} |
| 154 // Async API events. | 163 // Async API events. |
| 155 virtual void DiskChanged(MountLibraryEventType event, | 164 virtual void DiskChanged(MountLibraryEventType event, |
| 156 const Disk* disk) = 0; | 165 const Disk* disk) = 0; |
| 157 virtual void DeviceChanged(MountLibraryEventType event, | 166 virtual void DeviceChanged(MountLibraryEventType event, |
| 158 const std::string& device_path ) = 0; | 167 const std::string& device_path) = 0; |
| 159 virtual void MountCompleted(MountEvent event_type, | 168 virtual void MountCompleted(MountEvent event_type, |
| 160 MountError error_code, | 169 MountError error_code, |
| 161 const MountPointInfo& mount_info) = 0; | 170 const MountPointInfo& mount_info) = 0; |
| 162 }; | 171 }; |
| 163 | 172 |
| 164 virtual ~MountLibrary() {} | 173 virtual ~MountLibrary() {} |
| 165 virtual void AddObserver(Observer* observer) = 0; | 174 virtual void AddObserver(Observer* observer) = 0; |
| 166 virtual void RemoveObserver(Observer* observer) = 0; | 175 virtual void RemoveObserver(Observer* observer) = 0; |
| 167 virtual const DiskMap& disks() const = 0; | 176 virtual const DiskMap& disks() const = 0; |
| 168 virtual const MountPointMap& mount_points() const = 0; | 177 virtual const MountPointMap& mount_points() const = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 182 // Example: mount_path: /media/VOLUME_LABEL | 191 // Example: mount_path: /media/VOLUME_LABEL |
| 183 virtual void FormatMountedDevice(const char* mount_path) = 0; | 192 virtual void FormatMountedDevice(const char* mount_path) = 0; |
| 184 | 193 |
| 185 // Unmounts device_poath and all of its known children. | 194 // Unmounts device_poath and all of its known children. |
| 186 virtual void UnmountDeviceRecursive(const char* device_path, | 195 virtual void UnmountDeviceRecursive(const char* device_path, |
| 187 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; | 196 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; |
| 188 | 197 |
| 189 // Helper functions for parameter conversions. | 198 // Helper functions for parameter conversions. |
| 190 static std::string MountTypeToString(MountType type); | 199 static std::string MountTypeToString(MountType type); |
| 191 static MountType MountTypeFromString(const std::string& type_str); | 200 static MountType MountTypeFromString(const std::string& type_str); |
| 201 static std::string MountConditionToString(MountCondition type); |
| 192 | 202 |
| 193 // Used in testing. Enables mocking libcros. | 203 // Used in testing. Enables mocking libcros. |
| 194 virtual void SetLibcrosProxy(MountLibcrosProxy* proxy) {} | 204 virtual void SetLibcrosProxy(MountLibcrosProxy* proxy) {} |
| 195 | 205 |
| 196 // Factory function, creates a new instance and returns ownership. | 206 // Factory function, creates a new instance and returns ownership. |
| 197 // For normal usage, access the singleton via CrosLibrary::Get(). | 207 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 198 static MountLibrary* GetImpl(bool stub); | 208 static MountLibrary* GetImpl(bool stub); |
| 199 }; | 209 }; |
| 200 | 210 |
| 201 } // namespace chromeos | 211 } // namespace chromeos |
| 202 | 212 |
| 203 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ | 213 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ |
| OLD | NEW |