| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 std::string parent_path_; | 94 std::string parent_path_; |
| 95 DeviceType device_type_; | 95 DeviceType device_type_; |
| 96 uint64 total_size_; | 96 uint64 total_size_; |
| 97 bool is_parent_; | 97 bool is_parent_; |
| 98 bool is_read_only_; | 98 bool is_read_only_; |
| 99 bool has_media_; | 99 bool has_media_; |
| 100 bool on_boot_device_; | 100 bool on_boot_device_; |
| 101 }; | 101 }; |
| 102 typedef std::map<std::string, Disk*> DiskMap; | 102 typedef std::map<std::string, Disk*> DiskMap; |
| 103 | 103 |
| 104 // MountPointInfo: {mount_path, mount_type}. | |
| 105 struct MountPointInfo { | 104 struct MountPointInfo { |
| 106 std::string source_path; | 105 std::string source_path; |
| 107 std::string mount_path; | 106 std::string mount_path; |
| 108 MountType mount_type; | 107 MountType mount_type; |
| 109 | 108 |
| 110 MountPointInfo(const char* source, const char* mount, const MountType type) | 109 MountPointInfo(const char* source, const char* mount, const MountType type) |
| 111 : source_path(source ? source : ""), | 110 : source_path(source ? source : ""), |
| 112 mount_path(mount ? mount : ""), | 111 mount_path(mount ? mount : ""), |
| 113 mount_type(type) { | 112 mount_type(type) { |
| 114 } | 113 } |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 // MountPointMap key is source_path. | 116 // MountPointMap key is mount_path. |
| 118 typedef std::map<std::string, MountPointInfo> MountPointMap; | 117 typedef std::map<std::string, MountPointInfo> MountPointMap; |
| 119 | 118 |
| 120 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); | 119 typedef void(*UnmountDeviceRecursiveCallbackType)(void*, bool); |
| 121 | 120 |
| 122 class Observer { | 121 class Observer { |
| 123 public: | 122 public: |
| 124 virtual ~Observer() {} | 123 virtual ~Observer() {} |
| 125 // Async API events. | 124 // Async API events. |
| 126 virtual void DiskChanged(MountLibraryEventType event, | 125 virtual void DiskChanged(MountLibraryEventType event, |
| 127 const Disk* disk) = 0; | 126 const Disk* disk) = 0; |
| 128 virtual void DeviceChanged(MountLibraryEventType event, | 127 virtual void DeviceChanged(MountLibraryEventType event, |
| 129 const std::string& device_path ) = 0; | 128 const std::string& device_path ) = 0; |
| 130 virtual void MountCompleted(MountEvent event_type, | 129 virtual void MountCompleted(MountEvent event_type, |
| 131 MountError error_code, | 130 MountError error_code, |
| 132 const MountPointInfo& mount_info) = 0; | 131 const MountPointInfo& mount_info) = 0; |
| 133 }; | 132 }; |
| 134 | 133 |
| 135 virtual ~MountLibrary() {} | 134 virtual ~MountLibrary() {} |
| 136 virtual void AddObserver(Observer* observer) = 0; | 135 virtual void AddObserver(Observer* observer) = 0; |
| 137 virtual void RemoveObserver(Observer* observer) = 0; | 136 virtual void RemoveObserver(Observer* observer) = 0; |
| 138 virtual const DiskMap& disks() const = 0; | 137 virtual const DiskMap& disks() const = 0; |
| 139 virtual const MountPointMap& mount_points() const = 0; | 138 virtual const MountPointMap& mount_points() const = 0; |
| 140 | 139 |
| 141 virtual void RequestMountInfoRefresh() = 0; | 140 virtual void RequestMountInfoRefresh() = 0; |
| 142 virtual void MountPath(const char* source_path, | 141 virtual void MountPath(const char* source_path, |
| 143 MountType type, | 142 MountType type, |
| 144 const MountPathOptions& options) = 0; | 143 const MountPathOptions& options) = 0; |
| 145 // |path| may be source od mount path. | 144 // |path| is device's mount path. |
| 146 virtual void UnmountPath(const char* path) = 0; | 145 virtual void UnmountPath(const char* path) = 0; |
| 147 | 146 |
| 148 // Unmounts device_poath and all of its known children. | 147 // Unmounts device_poath and all of its known children. |
| 149 virtual void UnmountDeviceRecursive(const char* device_path, | 148 virtual void UnmountDeviceRecursive(const char* device_path, |
| 150 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; | 149 UnmountDeviceRecursiveCallbackType callback, void* user_data) = 0; |
| 151 | 150 |
| 152 // Helper functions for parameter conversions. | 151 // Helper functions for parameter conversions. |
| 153 static std::string MountTypeToString(MountType type); | 152 static std::string MountTypeToString(MountType type); |
| 154 static MountType MountTypeFromString(const std::string& type_str); | 153 static MountType MountTypeFromString(const std::string& type_str); |
| 155 | 154 |
| 156 // Factory function, creates a new instance and returns ownership. | 155 // Factory function, creates a new instance and returns ownership. |
| 157 // For normal usage, access the singleton via CrosLibrary::Get(). | 156 // For normal usage, access the singleton via CrosLibrary::Get(). |
| 158 static MountLibrary* GetImpl(bool stub); | 157 static MountLibrary* GetImpl(bool stub); |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 } // namespace chromeos | 160 } // namespace chromeos |
| 162 | 161 |
| 163 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ | 162 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ |
| OLD | NEW |