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 "chrome/browser/system_monitor/media_storage_util.h" | |
| 12 | 13 |
| 13 class ChromeBrowserMainPartsLinux; | 14 class ChromeBrowserMainPartsLinux; |
| 14 class ChromeBrowserMainPartsMac; | 15 class ChromeBrowserMainPartsMac; |
| 15 class MediaGalleriesPrivateApiTest; | 16 class MediaGalleriesPrivateApiTest; |
| 16 | 17 |
| 17 namespace chrome { | 18 namespace chrome { |
| 18 | 19 |
| 19 class MediaFileSystemRegistryTest; | 20 class MediaFileSystemRegistryTest; |
| 20 class RemovableStorageObserver; | 21 class RemovableStorageObserver; |
| 21 | 22 |
| 22 // Base class for platform-specific instances watching for removable storage | 23 // Base class for platform-specific instances watching for removable storage |
| 23 // attachments/detachments. | 24 // attachments/detachments. |
| 24 class RemovableStorageNotifications { | 25 class RemovableStorageNotifications { |
| 25 public: | 26 public: |
| 26 struct StorageInfo { | 27 struct StorageInfo { |
| 27 StorageInfo(); | 28 StorageInfo(); |
| 28 StorageInfo(const std::string& id, | 29 StorageInfo(const std::string& id, |
|
vandebo (ex-Chrome)
2013/02/08 02:03:31
This constructor implies that sometimes the new fi
Greg Billock
2013/02/08 16:42:02
That's correct -- we won't necessarily collect all
vandebo (ex-Chrome)
2013/02/08 23:20:36
If we don't collect something on a platform that's
| |
| 29 const string16& device_name, | 30 const string16& device_name, |
| 30 const base::FilePath::StringType& device_location); | 31 const base::FilePath::StringType& device_location); |
| 31 | 32 |
| 32 // Unique device id - persists between device attachments. | 33 // Unique device id - persists between device attachments. |
| 34 // This is the string that should be used as the label for a particular | |
| 35 // storage device when interacting with the API. Clients should treat | |
| 36 // this as an opaque string. | |
| 33 std::string device_id; | 37 std::string device_id; |
| 34 | 38 |
| 35 // Human readable removable storage device name. | 39 // Human readable removable storage device name. |
| 36 string16 name; | 40 string16 name; |
|
vandebo (ex-Chrome)
2013/02/08 02:03:31
Do you want to remove this and instead have a func
Greg Billock
2013/02/08 16:42:02
Yes. I left it alone for now -- my idea was to str
vandebo (ex-Chrome)
2013/02/08 23:20:36
I think that's a sufficiently focused CL: Push nam
| |
| 37 | 41 |
| 38 // Current attached removable storage device location. | 42 // Current attached removable storage device location. |
| 43 // TODO(gbillock): Just use a FilePath here? | |
|
vandebo (ex-Chrome)
2013/02/08 02:03:31
For MTP devices it is not a real file path.
Greg Billock
2013/02/08 16:42:02
Right. They'd leave the FilePath as empty(). Curre
vandebo (ex-Chrome)
2013/02/08 23:20:36
But we need a location string to be able to connec
| |
| 39 base::FilePath::StringType location; | 44 base::FilePath::StringType location; |
| 45 | |
| 46 // Label given to this storage device by the user. | |
| 47 // May be empty if not found or the device is unlabeled. | |
| 48 string16 storage_label; | |
| 49 | |
| 50 // Vendor name for the removable device. (Human readable) | |
| 51 // May be empty if not collected. | |
| 52 string16 vendor_name; | |
| 53 | |
| 54 // Model name for the removable device. (Human readable) | |
| 55 // May be empty if not collected. | |
| 56 string16 model_name; | |
| 57 | |
| 58 // Size of the removable device in bytes. | |
| 59 // Zero if not collected or unknown. | |
| 60 uint64 total_size_in_bytes; | |
| 61 | |
| 62 // Type of device. | |
| 63 // TODO(gbillock): Move this enum to this class. | |
| 64 MediaStorageUtil::Type device_type; | |
|
vandebo (ex-Chrome)
2013/02/08 02:03:31
This is already in device_id, there's no reason to
Greg Billock
2013/02/08 16:42:02
The existence of CrackDeviceId and MakeDeviceId me
vandebo (ex-Chrome)
2013/02/08 23:20:36
Prefs only stores a device id. To make them store
| |
| 40 }; | 65 }; |
| 41 | 66 |
| 42 // This interface is provided to generators of storage notifications. | 67 // This interface is provided to generators of storage notifications. |
| 43 class Receiver { | 68 class Receiver { |
| 44 public: | 69 public: |
| 45 virtual ~Receiver(); | 70 virtual ~Receiver(); |
| 46 | 71 |
| 47 virtual void ProcessAttach(const std::string& id, | 72 virtual void ProcessAttach(const StorageInfo& info) = 0; |
| 48 const string16& name, | |
| 49 const base::FilePath::StringType& location) = 0; | |
| 50 virtual void ProcessDetach(const std::string& id) = 0; | 73 virtual void ProcessDetach(const std::string& id) = 0; |
| 51 }; | 74 }; |
| 52 | 75 |
| 53 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime | 76 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime |
| 54 // somewhat shorter than a process Singleton. | 77 // somewhat shorter than a process Singleton. |
| 55 static RemovableStorageNotifications* GetInstance(); | 78 static RemovableStorageNotifications* GetInstance(); |
| 56 | 79 |
| 57 // Finds the device that contains |path| and populates |device_info|. | 80 // Finds the device that contains |path| and populates |device_info|. |
| 58 // Should be able to handle any path on the local system, not just removable | 81 // Should be able to handle any path on the local system, not just removable |
| 59 // storage. Returns false if unable to find the device. | 82 // storage. Returns false if unable to find the device. |
| 60 virtual bool GetDeviceInfoForPath( | 83 virtual bool GetDeviceInfoForPath( |
| 61 const base::FilePath& path, | 84 const base::FilePath& path, |
| 62 StorageInfo* device_info) const = 0; | 85 StorageInfo* device_info) const = 0; |
| 63 | 86 |
| 64 // Returns the storage size of the device present at |location|. If the | 87 // Returns the storage size of the device present at |location|. If the |
| 65 // device information is unavailable, returns zero. | 88 // device information is unavailable, returns zero. |
| 66 virtual uint64 GetStorageSize(const std::string& location) const = 0; | 89 virtual uint64 GetStorageSize(const std::string& location) const = 0; |
|
vandebo (ex-Chrome)
2013/02/08 02:03:31
If we have storage size in the storage info, then
Greg Billock
2013/02/08 16:42:02
Right. I'm planning to get rid of it. The use is i
| |
| 67 | 90 |
| 68 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
| 69 // Gets the MTP device storage information specified by |storage_device_id|. | 92 // Gets the MTP device storage information specified by |storage_device_id|. |
| 70 // On success, returns true and fills in |device_location| with device | 93 // On success, returns true and fills in |device_location| with device |
| 71 // interface details and |storage_object_id| with the string ID that | 94 // interface details and |storage_object_id| with the string ID that |
| 72 // uniquely identifies the object on the device. This ID need not be | 95 // uniquely identifies the object on the device. This ID need not be |
| 73 // persistent across sessions. | 96 // persistent across sessions. |
| 74 virtual bool GetMTPStorageInfoFromDeviceId( | 97 virtual bool GetMTPStorageInfoFromDeviceId( |
| 75 const std::string& storage_device_id, | 98 const std::string& storage_device_id, |
| 76 string16* device_location, | 99 string16* device_location, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 // For manipulating removable_storage_map_ structure. | 135 // For manipulating removable_storage_map_ structure. |
| 113 mutable base::Lock storage_lock_; | 136 mutable base::Lock storage_lock_; |
| 114 | 137 |
| 115 // Map of all the attached removable storage devices. | 138 // Map of all the attached removable storage devices. |
| 116 RemovableStorageMap storage_map_; | 139 RemovableStorageMap storage_map_; |
| 117 }; | 140 }; |
| 118 | 141 |
| 119 } // namespace chrome | 142 } // namespace chrome |
| 120 | 143 |
| 121 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 144 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| OLD | NEW |