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