| 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 // chrome::MediaStorageUtil provides information about storage devices attached | 5 // chrome::MediaStorageUtil provides information about storage devices attached |
| 6 // to the computer. | 6 // to the computer. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 8 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| 9 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 9 #define CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Looks inside |device_id| to determine if it is a mass storage device | 52 // Looks inside |device_id| to determine if it is a mass storage device |
| 53 // (type isn't MTP_OR_PTP). | 53 // (type isn't MTP_OR_PTP). |
| 54 static bool IsMassStorageDevice(const std::string& device_id); | 54 static bool IsMassStorageDevice(const std::string& device_id); |
| 55 | 55 |
| 56 // Determines if the device is attached to the computer. | 56 // Determines if the device is attached to the computer. |
| 57 static void IsDeviceAttached(const std::string& device_id, | 57 static void IsDeviceAttached(const std::string& device_id, |
| 58 const BoolCallback& callback); | 58 const BoolCallback& callback); |
| 59 | 59 |
| 60 // Given |path|, fill in |device_id|, |device_name|, and |relative_path| | 60 // Given |path|, fill in |device_id|, |device_name|, and |relative_path| |
| 61 // (from the root of the device) if they are not NULL. | 61 // (from the root of the device) if they are not NULL. |
| 62 static void GetDeviceInfoFromPath(const FilePath& path, | 62 static bool GetDeviceInfoFromPath(const FilePath& path, |
| 63 std::string* device_id, | 63 std::string* device_id, |
| 64 string16* device_name, | 64 string16* device_name, |
| 65 FilePath* relative_path); | 65 FilePath* relative_path); |
| 66 | 66 |
| 67 // Get a FilePath for the given |device_id|. If the device isn't a mass | 67 // Get a FilePath for the given |device_id|. If the device isn't a mass |
| 68 // storage type, the FilePath will be empty. This does not check that | 68 // storage type, the FilePath will be empty. This does not check that |
| 69 // the device is connected. | 69 // the device is connected. |
| 70 static FilePath FindDevicePathById(const std::string& device_id); | 70 static FilePath FindDevicePathById(const std::string& device_id); |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 typedef void (*GetDeviceInfoFromPathFunction)(const FilePath& path, | 73 typedef bool (*GetDeviceInfoFromPathFunction)(const FilePath& path, |
| 74 std::string* device_id, | 74 std::string* device_id, |
| 75 string16* device_name, | 75 string16* device_name, |
| 76 FilePath* relative_path); | 76 FilePath* relative_path); |
| 77 | 77 |
| 78 // Set the implementation of GetDeviceInfoFromPath for testing. | 78 // Set the implementation of GetDeviceInfoFromPath for testing. |
| 79 static void SetGetDeviceInfoFromPathFunctionForTesting( | 79 static void SetGetDeviceInfoFromPathFunctionForTesting( |
| 80 GetDeviceInfoFromPathFunction function); | 80 GetDeviceInfoFromPathFunction function); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // All methods are static, this class should not be instantiated. | 83 // All methods are static, this class should not be instantiated. |
| 84 MediaStorageUtil(); | 84 MediaStorageUtil(); |
| 85 | 85 |
| 86 // Per platform implementation. | 86 // Per platform implementation. |
| 87 static void GetDeviceInfoFromPathImpl(const FilePath& path, | 87 static bool GetDeviceInfoFromPathImpl(const FilePath& path, |
| 88 std::string* device_id, | 88 std::string* device_id, |
| 89 string16* device_name, | 89 string16* device_name, |
| 90 FilePath* relative_path); | 90 FilePath* relative_path); |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); | 92 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace chrome | 95 } // namespace chrome |
| 96 | 96 |
| 97 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ | 97 #endif // CHROME_BROWSER_SYSTEM_MONITOR_MEDIA_STORAGE_UTIL_H_ |
| OLD | NEW |