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/callback_forward.h" | |
14 #include "base/file_path.h" | |
15 #include "base/lazy_instance.h" | |
16 | |
17 namespace chrome { | |
18 | |
19 class MediaStorageUtil { | |
kmadhusu
2012/08/17 18:53:35
nit: Either move the comments from line 5 to here
vandebo (ex-Chrome)
2012/08/17 22:55:51
Seems unnecessary to me.
| |
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, | |
kmadhusu
2012/08/17 18:53:35
You might want to add TODO's
(1) To handle mass st
vandebo (ex-Chrome)
2012/08/17 22:55:51
Where would you like me to add those TODOs?
kmadhusu
2012/08/20 17:13:49
You can add these TODO's in IsMediaDevice function
vandebo (ex-Chrome)
2012/08/20 18:35:14
Actually there's already TODO's in the implementat
| |
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 // Makes a device id given properties of the device. A prefix dependant on | |
kmadhusu
2012/08/17 18:53:35
nit: dependent
kmadhusu
2012/08/17 18:53:35
nit: Returns device id ....
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
33 // |type| is added so |unique_id| need only be unique within the given type. | |
34 static std::string MakeDeviceId(Type type, const std::string& unique_id); | |
35 | |
36 // Extracts the device type from |device_id|. | |
kmadhusu
2012/08/17 18:53:35
nit: Extracts device |type| and |unique_id| given
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
37 static void CrackDeviceId(const std::string& device_id, | |
38 Type* type, std::string* unique_id); | |
39 | |
40 // Looks inside |device_id| to determine if it is a media device | |
41 // (type is USB_MASS_STORAGE_WITH_DCIM or USB_MTP). | |
kmadhusu
2012/08/17 18:53:35
A device of type USB_MASS_STORAGE_WITH_NO_DCIM can
vandebo (ex-Chrome)
2012/08/17 22:55:51
No, it would be type USB_MASS_STORAGE_WITH_DCIM in
| |
42 static bool IsMediaDevice(const std::string& device_id); | |
43 | |
44 // Looks inside |device_id| to determine if it is a media device | |
45 // (type isn't OTHER_MASS_STORAGE). | |
46 static bool IsRemovableDevice(const std::string& device_id); | |
kmadhusu
2012/08/17 18:53:35
If IsMediaDevice() returns true of USB_MASS_STORAG
| |
47 | |
48 // Determines if the device is attached to the computer. | |
49 static void IsDeviceAttached(const std::string& device_id, | |
50 const base::Callback<void(bool)>& callback); | |
kmadhusu
2012/08/17 18:53:35
nit: Can we create a typedef for the Query callbac
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
51 | |
52 // Given a path |input|, get the device_id, relative path from the root of | |
kmadhusu
2012/08/17 18:53:35
nit: Can we rename |input| to |path|? Since it is
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
53 // the device, and the device name. | |
54 static void GetDeviceInfoFromPath( | |
55 const FilePath& input, | |
56 const base::Callback<void(std::string /*device id*/, | |
kmadhusu
2012/08/17 18:53:35
nit: /* ABC */ (Space after /*)
vandebo (ex-Chrome)
2012/08/17 22:55:51
Actually there's no clear guidance on this in the
| |
57 FilePath /*path relative to device root*/, | |
58 string16 /*display name*/)>& callback); | |
59 | |
60 // Get a FilePath for the given |device_id|. If the device isn't connected | |
61 // or isn't a mass storage type, the FilePath will be empty. | |
62 static void FindDevicePathById( | |
63 const std::string& device_id, | |
64 const base::Callback<void(FilePath)>& callback); | |
65 | |
66 private: | |
67 MediaStorageUtil(); | |
kmadhusu
2012/08/17 18:53:35
nit: Document this function // Do not instantiate
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
68 | |
69 static void FindUSBDeviceById(const std::string unique_id, | |
kmadhusu
2012/08/17 18:53:35
nit: Document this function (To specify that this
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
70 const base::Callback<void(FilePath)>& callback); | |
kmadhusu
2012/08/17 18:53:35
DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil);
vandebo (ex-Chrome)
2012/08/17 22:55:51
Done.
| |
71 }; | |
72 | |
73 } // namespace chromeos | |
74 | |
75 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ | |
OLD | NEW |