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_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/observer_list_threadsafe.h" | 9 #include "base/observer_list_threadsafe.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/system_monitor/system_monitor.h" | 12 |
| 13 class MediaGalleriesPrivateApiTest; | |
| 13 | 14 |
| 14 namespace chrome { | 15 namespace chrome { |
| 15 | 16 |
| 16 class RemovableStorageObserver; | 17 class RemovableStorageObserver; |
| 17 | 18 |
| 18 // Base class for platform-specific instances watching for removable storage | 19 // Base class for platform-specific instances watching for removable storage |
| 19 // attachments/detachments. | 20 // attachments/detachments. |
| 20 class RemovableStorageNotifications { | 21 class RemovableStorageNotifications { |
| 21 public: | 22 public: |
| 22 struct StorageInfo { | 23 struct StorageInfo { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 37 | 38 |
| 38 virtual ~RemovableStorageNotifications(); | 39 virtual ~RemovableStorageNotifications(); |
| 39 | 40 |
| 40 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime | 41 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime |
| 41 // somewhat shorter than a process Singleton. | 42 // somewhat shorter than a process Singleton. |
| 42 static RemovableStorageNotifications* GetInstance(); | 43 static RemovableStorageNotifications* GetInstance(); |
| 43 | 44 |
| 44 // Finds the device that contains |path| and populates |device_info|. | 45 // Finds the device that contains |path| and populates |device_info|. |
| 45 // Should be able to handle any path on the local system, not just removable | 46 // Should be able to handle any path on the local system, not just removable |
| 46 // storage. Returns false if unable to find the device. | 47 // storage. Returns false if unable to find the device. |
| 47 // TODO(gbillock): Change this method signature to use StorageInfo. | 48 // TODO(gbillock): Change this method signature to use StorageInfo. |
|
Hongbo Min
2013/01/20 03:41:19
What I see is you have already changed the signatu
Greg Billock
2013/01/22 20:00:39
Done.
| |
| 48 virtual bool GetDeviceInfoForPath( | 49 virtual bool GetDeviceInfoForPath( |
| 49 const FilePath& path, | 50 const FilePath& path, |
| 50 base::SystemMonitor::RemovableStorageInfo* device_info) const = 0; | 51 StorageInfo* device_info) const = 0; |
| 51 | 52 |
| 52 // Returns the storage size of the device present at |location|. If the | 53 // Returns the storage size of the device present at |location|. If the |
| 53 // device information is unavailable, returns zero. | 54 // device information is unavailable, returns zero. |
| 54 virtual uint64 GetStorageSize(const std::string& location) const = 0; | 55 virtual uint64 GetStorageSize(const std::string& location) const = 0; |
| 55 | 56 |
| 56 // Returns information for attached removable storage. | 57 // Returns information for attached removable storage. |
| 57 std::vector<StorageInfo> GetAttachedStorage() const; | 58 std::vector<StorageInfo> GetAttachedStorage() const; |
| 58 | 59 |
| 59 void AddObserver(RemovableStorageObserver* obs); | 60 void AddObserver(RemovableStorageObserver* obs); |
| 60 void RemoveObserver(RemovableStorageObserver* obs); | 61 void RemoveObserver(RemovableStorageObserver* obs); |
| 61 | 62 |
| 62 protected: | 63 protected: |
| 63 RemovableStorageNotifications(); | 64 RemovableStorageNotifications(); |
| 64 | 65 |
| 66 // TODO(gbillock): remove these friends by making the classes owned by the | |
|
vandebo (ex-Chrome)
2013/01/18 18:42:58
nit: I don't think you're going to fix the tests t
Greg Billock
2013/01/22 20:00:39
Done.
| |
| 67 // platform-specific implementation. | |
| 68 friend class MediaFileSystemRegistryTest; | |
| 69 friend class ::MediaGalleriesPrivateApiTest; | |
| 70 friend class MediaStorageUtilTest; | |
| 71 friend class MediaTransferProtocolDeviceObserverLinux; | |
| 72 friend class PortableDeviceWatcherWin; | |
| 73 friend class VolumeMountWatcherWin; | |
| 74 | |
| 65 void ProcessAttach(const std::string& id, | 75 void ProcessAttach(const std::string& id, |
| 66 const string16& name, | 76 const string16& name, |
| 67 const FilePath::StringType& location); | 77 const FilePath::StringType& location); |
| 68 void ProcessDetach(const std::string& id); | 78 void ProcessDetach(const std::string& id); |
| 69 | 79 |
| 70 private: | 80 private: |
| 71 typedef std::map<std::string, StorageInfo> RemovableStorageMap; | 81 typedef std::map<std::string, StorageInfo> RemovableStorageMap; |
| 72 | 82 |
| 73 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > | 83 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > |
| 74 observer_list_; | 84 observer_list_; |
| 75 | 85 |
| 76 // For manipulating removable_storage_map_ structure. | 86 // For manipulating removable_storage_map_ structure. |
| 77 mutable base::Lock storage_lock_; | 87 mutable base::Lock storage_lock_; |
| 78 | 88 |
| 79 // Map of all the attached removable storage devices. | 89 // Map of all the attached removable storage devices. |
| 80 RemovableStorageMap storage_map_; | 90 RemovableStorageMap storage_map_; |
| 81 }; | 91 }; |
| 82 | 92 |
| 83 } // namespace chrome | 93 } // namespace chrome |
| 84 | 94 |
| 85 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 95 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| OLD | NEW |