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.
5 // MediaStorageUtil provides information about storage devices attached
8 #ifndef CHROME_BROWSER_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_
9 #define CHROME_BROWSER_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_
14 #include "base/basictypes.h"
15 #include "base/callback_forward.h"
16 #include "base/files/file_path.h"
20 class MediaStorageUtil
{
22 typedef std::set
<std::string
/*device id*/> DeviceIdSet
;
24 // Check if the file system at the passed mount point looks like a media
25 // device using the existence of DCIM directory.
26 // Returns true if it looks like a media device, otherwise returns false.
27 // Mac OS X behaves similarly, but this is not the only heuristic it uses.
28 // TODO(vandebo) Try to figure out how Mac OS X decides this, and rename
29 // if additional OS X heuristic is implemented.
30 static bool HasDcim(const base::FilePath
& mount_point
);
32 // Returns true if we will be able to create a filesystem for this device.
33 static bool CanCreateFileSystem(const std::string
& device_id
,
34 const base::FilePath
& path
);
36 // Removes disconnected devices from |devices| and then calls |done|.
37 static void FilterAttachedDevices(DeviceIdSet
* devices
,
38 const base::Closure
& done
);
40 // Given |path|, fill in |device_info|, and |relative_path|
41 // (from the root of the device).
42 static bool GetDeviceInfoFromPath(const base::FilePath
& path
,
43 StorageInfo
* device_info
,
44 base::FilePath
* relative_path
);
46 // Get a base::FilePath for the given |device_id|. If the device isn't a mass
47 // storage type, the base::FilePath will be empty. This does not check that
48 // the device is connected.
49 static base::FilePath
FindDevicePathById(const std::string
& device_id
);
51 // Record device information histogram for the given |device_uuid| and
52 // |device_label|. |mass_storage| indicates whether the current device is a
53 // mass storage device, as defined by IsMassStorageDevice().
54 static void RecordDeviceInfoHistogram(bool mass_storage
,
55 const std::string
& device_uuid
,
56 const base::string16
& device_label
);
58 // Returns true if the |id| is both a removable device and also
59 // currently attached.
60 static bool IsRemovableStorageAttached(const std::string
& id
);
63 DISALLOW_IMPLICIT_CONSTRUCTORS(MediaStorageUtil
);
66 #endif // CHROME_BROWSER_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_