Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / components / storage_monitor / media_storage_util.h
1 // Copyright 2014 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 // MediaStorageUtil provides information about storage devices attached
6 // to the computer.
7
8 #ifndef COMPONENTS_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_
9 #define COMPONENTS_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_
10
11 #include <set>
12 #include <string>
13
14 #include "base/basictypes.h"
15 #include "base/callback_forward.h"
16 #include "base/files/file_path.h"
17
18 struct StorageInfo;
19
20 class MediaStorageUtil {
21  public:
22   typedef std::set<std::string /*device id*/> DeviceIdSet;
23
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);
31
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);
35
36   // Removes disconnected devices from |devices| and then calls |done|.
37   static void FilterAttachedDevices(DeviceIdSet* devices,
38                                     const base::Closure& done);
39
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);
45
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);
50
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);
57
58   // Returns true if the |id| is both a removable device and also
59   // currently attached.
60   static bool IsRemovableStorageAttached(const std::string& id);
61
62  private:
63   DISALLOW_IMPLICIT_CONSTRUCTORS(MediaStorageUtil);
64 };
65
66 #endif  // COMPONENTS_STORAGE_MONITOR_MEDIA_STORAGE_UTIL_H_