Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/media_gallery/media_storage_util.h

Issue 10871049: Connect MediaFileSystemRegistry with MediaGalleriesPreferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 12 matching lines...) Expand all
23 REMOVABLE_MASS_STORAGE_WITH_DCIM, 23 REMOVABLE_MASS_STORAGE_WITH_DCIM,
24 // A removable mass storage device without a DCIM directory. 24 // A removable mass storage device without a DCIM directory.
25 REMOVABLE_MASS_STORAGE_NO_DCIM, 25 REMOVABLE_MASS_STORAGE_NO_DCIM,
26 // A fixed mass storage device. 26 // A fixed mass storage device.
27 FIXED_MASS_STORAGE, 27 FIXED_MASS_STORAGE,
28 // A MTP or PTP device. 28 // A MTP or PTP device.
29 MTP_OR_PTP, 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;
34 33
35 // Returns a device id given properties of the device. A prefix dependent on 34 // Returns a device id given properties of the device. A prefix dependent on
36 // |type| is added so |unique_id| need only be unique within the given type. 35 // |type| is added so |unique_id| need only be unique within the given type.
37 // Returns an empty string if an invalid type is passed in. 36 // Returns an empty string if an invalid type is passed in.
38 static std::string MakeDeviceId(Type type, const std::string& unique_id); 37 static std::string MakeDeviceId(Type type, const std::string& unique_id);
39 38
40 // Extracts the device |type| and |unique_id| from |device_id|. Returns false 39 // Extracts the device |type| and |unique_id| from |device_id|. Returns false
41 // if the device_id isn't properly formatted. 40 // if the device_id isn't properly formatted.
42 static bool CrackDeviceId(const std::string& device_id, 41 static bool CrackDeviceId(const std::string& device_id,
43 Type* type, std::string* unique_id); 42 Type* type, std::string* unique_id);
44 43
45 // Looks inside |device_id| to determine if it is a media device 44 // Looks inside |device_id| to determine if it is a media device
46 // (type is REMOVABLE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP). 45 // (type is REMOVABLE_MASS_STORAGE_WITH_DCIM or MTP_OR_PTP).
47 static bool IsMediaDevice(const std::string& device_id); 46 static bool IsMediaDevice(const std::string& device_id);
48 47
49 // 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
50 // (type isn't FIXED_MASS_STORAGE). 49 // (type isn't FIXED_MASS_STORAGE).
51 static bool IsRemovableDevice(const std::string& device_id); 50 static bool IsRemovableDevice(const std::string& device_id);
52 51
52 // Looks inside |device_id| to determine if it is a mass storage device
53 // (type isn't MTP_OR_PTP).
54 static bool IsMassStorageDevice(const std::string& device_id);
55
53 // Determines if the device is attached to the computer. 56 // Determines if the device is attached to the computer.
54 static void IsDeviceAttached(const std::string& device_id, 57 static void IsDeviceAttached(const std::string& device_id,
55 const BoolCallback& callback); 58 const BoolCallback& callback);
56 59
57 // Given |path|, fill in |device_id|, |device_name|, and |relative_path| 60 // Given |path|, fill in |device_id|, |device_name|, and |relative_path|
58 // (from the root of the device) if they are not NULL. 61 // (from the root of the device) if they are not NULL.
59 static void GetDeviceInfoFromPath(const FilePath& path, 62 static void GetDeviceInfoFromPath(const FilePath& path,
60 std::string* device_id, 63 std::string* device_id,
61 string16* device_name, 64 string16* device_name,
62 FilePath* relative_path); 65 FilePath* relative_path);
63 66
64 // Get a FilePath for the given |device_id|. If the device isn't connected 67 // Get a FilePath for the given |device_id|. If the device isn't a mass
65 // or isn't a mass storage type, the FilePath will be empty. 68 // storage type, the FilePath will be empty. This does not check that
66 static void FindDevicePathById(const std::string& device_id, 69 // the device is connected.
67 const FilePathCallback& callback); 70 static FilePath FindDevicePathById(const std::string& device_id);
68 71
69 protected: 72 protected:
70 typedef void (*GetDeviceInfoFromPathFunction)(const FilePath& path, 73 typedef void (*GetDeviceInfoFromPathFunction)(const FilePath& path,
71 std::string* device_id, 74 std::string* device_id,
72 string16* device_name, 75 string16* device_name,
73 FilePath* relative_path); 76 FilePath* relative_path);
74 77
75 // Set the implementation of GetDeviceInfoFromPath for testing. 78 // Set the implementation of GetDeviceInfoFromPath for testing.
76 static void SetGetDeviceInfoFromPathFunctionForTesting( 79 static void SetGetDeviceInfoFromPathFunctionForTesting(
77 GetDeviceInfoFromPathFunction function); 80 GetDeviceInfoFromPathFunction function);
78 81
79 private: 82 private:
80 // All methods are static, this class should not be instantiated. 83 // All methods are static, this class should not be instantiated.
81 MediaStorageUtil(); 84 MediaStorageUtil();
82 85
83 // Per platform implementation. 86 // Per platform implementation.
84 static void GetDeviceInfoFromPathImpl(const FilePath& path, 87 static void GetDeviceInfoFromPathImpl(const FilePath& path,
85 std::string* device_id, 88 std::string* device_id,
86 string16* device_name, 89 string16* device_name,
87 FilePath* relative_path); 90 FilePath* relative_path);
88 91
89 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil); 92 DISALLOW_COPY_AND_ASSIGN(MediaStorageUtil);
90 }; 93 };
91 94
92 } // namespace chrome 95 } // namespace chrome
93 96
94 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_ 97 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_STORAGE_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698