OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // chrome::MediaStorageUtil provides information about storage devices attached | |
6 // to the computer. | |
7 | |
8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | |
9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | |
10 | |
11 #include <string> | |
12 | |
13 #include "base/basictypes.h" | |
14 #include "base/callback_forward.h" | |
15 #include "base/file_path.h" | |
16 | |
17 namespace chrome { | |
18 | |
19 class MediaStorageUtil { | |
20 public: | |
21 enum Type { | |
22 // A USB mass storage device with a DCIM directory. | |
23 USB_MASS_STORAGE_WITH_DCIM, | |
24 // A USB mass storage device without a DCIM directory. | |
25 USB_MASS_STORAGE_NO_DCIM, | |
26 // Mass storage not connected through USB - a proxy for fixed/removable. | |
27 OTHER_MASS_STORAGE, | |
28 // A MTP or PTP device. | |
29 USB_MTP, | |
30 }; | |
31 | |
32 typedef base::Callback<void(bool)> BoolCallback; | |
33 typedef base::Callback<void(FilePath)> FilePathCallback; | |
kmadhusu
2012/08/20 17:13:50
const FilePath&
vandebo (ex-Chrome)
2012/08/20 18:35:14
Both in this case the the one below, the purpose o
| |
34 typedef base::Callback<void(std::string /*device id*/, | |
kmadhusu
2012/08/20 17:13:50
const std::string&
const FilePath&
| |
35 FilePath /*path relative to device root*/, | |
36 string16 /*display name*/)> DeviceInfoCallback; | |
37 | |
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. | |
40 static std::string MakeDeviceId(Type type, const std::string& unique_id); | |
41 | |
42 // Extracts the device |type| and |unique_id| from |device_id|. | |
43 static void CrackDeviceId(const std::string& device_id, | |
44 Type* type, std::string* unique_id); | |
45 | |
46 // Looks inside |device_id| to determine if it is a media device | |
47 // (type is USB_MASS_STORAGE_WITH_DCIM or USB_MTP). | |
48 static bool IsMediaDevice(const std::string& device_id); | |
49 | |
50 // Looks inside |device_id| to determine if it is a media device | |
51 // (type isn't OTHER_MASS_STORAGE). | |
52 static bool IsRemovableDevice(const std::string& device_id); | |
53 | |
54 // Determines if the device is attached to the computer. | |
55 static void IsDeviceAttached(const std::string& device_id, | |
56 const BoolCallback& callback); | |
57 | |
58 // Given |path|, get the device_id, relative path from the root of the | |
59 // device, and the device name. | |
60 static void GetDeviceInfoFromPath(const FilePath& path, | |
61 const DeviceInfoCallback& callback); | |
62 | |
63 // Get a FilePath for the given |device_id|. If the device isn't connected | |
64 // or isn't a mass storage type, the FilePath will be empty. | |
65 static void FindDevicePathById(const std::string& device_id, | |
66 const FilePathCallback& callback); | |
67 | |
68 private: | |
69 // All methods are static, this class should not be instantiated. | |
70 MediaStorageUtil(); | |
71 | |
72 // A platform specific helper. | |
73 static void FindUSBDeviceById(const std::string unique_id, | |
74 const FilePathCallback& callback); | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); | |
77 }; | |
78 | |
79 } // namespace chromeos | |
kmadhusu
2012/08/20 17:13:50
chromeos => chrome
vandebo (ex-Chrome)
2012/08/20 18:35:14
Done.
| |
80 | |
81 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | |
OLD | NEW |