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_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | 8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |
9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | 9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 | 16 |
17 namespace chrome { | 17 namespace chrome { |
18 | 18 |
19 class MediaStorageUtil { | 19 class MediaStorageUtil { |
20 public: | 20 public: |
21 enum Type { | 21 enum Type { |
22 // A USB mass storage device with a DCIM directory. | 22 // A removable mass storage device with a DCIM directory. |
23 USB_MASS_STORAGE_WITH_DCIM, | 23 REMOVALBE_MASS_STORAGE_WITH_DCIM, |
Lei Zhang
2012/08/27 23:06:59
typo here and below and everywhere else.
| |
24 // A USB mass storage device without a DCIM directory. | 24 // A removable mass storage device without a DCIM directory. |
25 USB_MASS_STORAGE_NO_DCIM, | 25 REMOVALBE_MASS_STORAGE_NO_DCIM, |
26 // Mass storage not connected through USB - a proxy for fixed/removable. | 26 // A fixed mass storage device. |
27 OTHER_MASS_STORAGE, | 27 FIXED_MASS_STORAGE, |
28 // A MTP or PTP device. | 28 // A MTP or PTP device. |
29 USB_MTP, | 29 MTP_OR_PTP, |
30 }; | 30 }; |
31 | 31 |
32 typedef base::Callback<void(bool)> BoolCallback; | 32 typedef base::Callback<void(bool)> BoolCallback; |
33 typedef base::Callback<void(FilePath)> FilePathCallback; | 33 typedef base::Callback<void(FilePath)> FilePathCallback; |
34 typedef base::Callback<void(std::string /*device id*/, | 34 typedef base::Callback<void(std::string /*device id*/, |
35 FilePath /*path relative to device root*/, | 35 FilePath /*path relative to device root*/, |
36 string16 /*display name*/)> DeviceInfoCallback; | 36 string16 /*display name*/)> DeviceInfoCallback; |
37 | 37 |
38 // Returns a device id given properties of the device. A prefix dependent on | 38 // Returns a device id given properties of the device. A prefix dependent on |
39 // |type| is added so |unique_id| need only be unique within the given type. | 39 // |type| is added so |unique_id| need only be unique within the given type. |
40 // Returns an empty string if an invalid type is passed in. | 40 // Returns an empty string if an invalid type is passed in. |
41 static std::string MakeDeviceId(Type type, const std::string& unique_id); | 41 static std::string MakeDeviceId(Type type, const std::string& unique_id); |
42 | 42 |
43 // Extracts the device |type| and |unique_id| from |device_id|. Returns false | 43 // Extracts the device |type| and |unique_id| from |device_id|. Returns false |
44 // if the device_id isn't properly formatted. | 44 // if the device_id isn't properly formatted. |
45 static bool CrackDeviceId(const std::string& device_id, | 45 static bool CrackDeviceId(const std::string& device_id, |
46 Type* type, std::string* unique_id); | 46 Type* type, std::string* unique_id); |
47 | 47 |
48 // Looks inside |device_id| to determine if it is a media device | 48 // Looks inside |device_id| to determine if it is a media device |
49 // (type is USB_MASS_STORAGE_WITH_DCIM or USB_MTP). | 49 // (type is REMOVALBE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP). |
50 static bool IsMediaDevice(const std::string& device_id); | 50 static bool IsMediaDevice(const std::string& device_id); |
51 | 51 |
52 // Looks inside |device_id| to determine if it is a media device | 52 // Looks inside |device_id| to determine if it is a media device |
53 // (type isn't OTHER_MASS_STORAGE). | 53 // (type isn't FIXED_MASS_STORAGE). |
54 static bool IsRemovableDevice(const std::string& device_id); | 54 static bool IsRemovableDevice(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|, get the device_id, relative path from the root of the | 60 // Given |path|, get the device_id, relative path from the root of the |
61 // device, and the device name. | 61 // device, and the device name. |
62 static void GetDeviceInfoFromPath(const FilePath& path, | 62 static void GetDeviceInfoFromPath(const FilePath& path, |
63 const DeviceInfoCallback& callback); | 63 const DeviceInfoCallback& callback); |
(...skipping 10 matching lines...) Expand all Loading... | |
74 // A platform specific helper. | 74 // A platform specific helper. |
75 static void FindUSBDeviceById(const std::string& unique_id, | 75 static void FindUSBDeviceById(const std::string& unique_id, |
76 const FilePathCallback& callback); | 76 const FilePathCallback& callback); |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); | 78 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); |
79 }; | 79 }; |
80 | 80 |
81 } // namespace chrome | 81 } // namespace chrome |
82 | 82 |
83 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | 83 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ |
OLD | NEW |