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

Side by Side Diff: components/storage_monitor/storage_monitor_linux.h

Issue 2358493002: Remove MTP support on Linux. (Closed)
Patch Set: move files Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 // StorageMonitorLinux processes mount point change events, notifies listeners 5 // StorageMonitorLinux processes mount point change events, notifies listeners
6 // about the addition and deletion of media devices, and answers queries about 6 // about the addition and deletion of media devices, and answers queries about
7 // mounted devices. 7 // mounted devices.
8 // StorageMonitorLinux lives on the UI thread, and uses a MtabWatcherLinux on 8 // StorageMonitorLinux lives on the UI thread, and uses a MtabWatcherLinux on
9 // the FILE thread to get mount point change events. 9 // the FILE thread to get mount point change events.
10 10
(...skipping 13 matching lines...) Expand all
24 #include "base/files/file_path_watcher.h" 24 #include "base/files/file_path_watcher.h"
25 #include "base/macros.h" 25 #include "base/macros.h"
26 #include "base/memory/weak_ptr.h" 26 #include "base/memory/weak_ptr.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "components/storage_monitor/mtab_watcher_linux.h" 28 #include "components/storage_monitor/mtab_watcher_linux.h"
29 #include "components/storage_monitor/storage_monitor.h" 29 #include "components/storage_monitor/storage_monitor.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 31
32 namespace storage_monitor { 32 namespace storage_monitor {
33 33
34 class MediaTransferProtocolDeviceObserverLinux;
35
36 class StorageMonitorLinux : public StorageMonitor, 34 class StorageMonitorLinux : public StorageMonitor,
37 public MtabWatcherLinux::Delegate { 35 public MtabWatcherLinux::Delegate {
38 public: 36 public:
39 // Should only be called by browser start up code. 37 // Should only be called by browser start up code.
40 // Use StorageMonitor::GetInstance() instead. 38 // Use StorageMonitor::GetInstance() instead.
41 // |mtab_file_path| is the path to a mtab file to watch for mount points. 39 // |mtab_file_path| is the path to a mtab file to watch for mount points.
42 explicit StorageMonitorLinux(const base::FilePath& mtab_file_path); 40 explicit StorageMonitorLinux(const base::FilePath& mtab_file_path);
43 ~StorageMonitorLinux() override; 41 ~StorageMonitorLinux() override;
44 42
45 // Must be called for StorageMonitorLinux to work. 43 // Must be called for StorageMonitorLinux to work.
46 void Init() override; 44 void Init() override;
47 45
48 protected: 46 protected:
49 // Gets device information given a |device_path| and |mount_point|. 47 // Gets device information given a |device_path| and |mount_point|.
50 using GetDeviceInfoCallback = base::Callback<std::unique_ptr<StorageInfo>( 48 using GetDeviceInfoCallback = base::Callback<std::unique_ptr<StorageInfo>(
51 const base::FilePath& device_path, 49 const base::FilePath& device_path,
52 const base::FilePath& mount_point)>; 50 const base::FilePath& mount_point)>;
53 51
54 void SetGetDeviceInfoCallbackForTest( 52 void SetGetDeviceInfoCallbackForTest(
55 const GetDeviceInfoCallback& get_device_info_callback); 53 const GetDeviceInfoCallback& get_device_info_callback);
56 54
57 void SetMediaTransferProtocolManagerForTest(
58 device::MediaTransferProtocolManager* test_manager);
59
60 // MtabWatcherLinux::Delegate implementation. 55 // MtabWatcherLinux::Delegate implementation.
61 void UpdateMtab( 56 void UpdateMtab(
62 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override; 57 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override;
63 58
64 private: 59 private:
65 // Structure to save mounted device information such as device path, unique 60 // Structure to save mounted device information such as device path, unique
66 // identifier, device name and partition size. 61 // identifier, device name and partition size.
67 struct MountPointInfo { 62 struct MountPointInfo {
68 base::FilePath mount_device; 63 base::FilePath mount_device;
69 StorageInfo storage_info; 64 StorageInfo storage_info;
(...skipping 18 matching lines...) Expand all
88 // (mount device, map of known mount points) 83 // (mount device, map of known mount points)
89 // For each mount device, track the places it is mounted and which one (if 84 // For each mount device, track the places it is mounted and which one (if
90 // any) we have notified system monitor about. 85 // any) we have notified system monitor about.
91 typedef std::map<base::FilePath, ReferencedMountPoint> MountPriorityMap; 86 typedef std::map<base::FilePath, ReferencedMountPoint> MountPriorityMap;
92 87
93 // StorageMonitor implementation. 88 // StorageMonitor implementation.
94 bool GetStorageInfoForPath(const base::FilePath& path, 89 bool GetStorageInfoForPath(const base::FilePath& path,
95 StorageInfo* device_info) const override; 90 StorageInfo* device_info) const override;
96 void EjectDevice(const std::string& device_id, 91 void EjectDevice(const std::string& device_id,
97 base::Callback<void(EjectStatus)> callback) override; 92 base::Callback<void(EjectStatus)> callback) override;
98 device::MediaTransferProtocolManager* media_transfer_protocol_manager()
99 override;
100 93
101 // Called when the MtabWatcher has been created. 94 // Called when the MtabWatcher has been created.
102 void OnMtabWatcherCreated(MtabWatcherLinux* watcher); 95 void OnMtabWatcherCreated(MtabWatcherLinux* watcher);
103 96
104 bool IsDeviceAlreadyMounted(const base::FilePath& mount_device) const; 97 bool IsDeviceAlreadyMounted(const base::FilePath& mount_device) const;
105 98
106 // Assuming |mount_device| is already mounted, and it gets mounted again at 99 // Assuming |mount_device| is already mounted, and it gets mounted again at
107 // |mount_point|, update the mappings. 100 // |mount_point|, update the mappings.
108 void HandleDeviceMountedMultipleTimes(const base::FilePath& mount_device, 101 void HandleDeviceMountedMultipleTimes(const base::FilePath& mount_device,
109 const base::FilePath& mount_point); 102 const base::FilePath& mount_point);
(...skipping 13 matching lines...) Expand all
123 // Keep in mind on Linux, a device can be mounted at multiple mount points, 116 // Keep in mind on Linux, a device can be mounted at multiple mount points,
124 // and multiple devices can be mounted at a mount point. 117 // and multiple devices can be mounted at a mount point.
125 MountMap mount_info_map_; 118 MountMap mount_info_map_;
126 119
127 // Because a device can be mounted to multiple places, we only want to 120 // Because a device can be mounted to multiple places, we only want to
128 // notify about one of them. If (and only if) that one is unmounted, we need 121 // notify about one of them. If (and only if) that one is unmounted, we need
129 // to notify about it's departure and notify about another one of it's mount 122 // to notify about it's departure and notify about another one of it's mount
130 // points. 123 // points.
131 MountPriorityMap mount_priority_map_; 124 MountPriorityMap mount_priority_map_;
132 125
133 std::unique_ptr<device::MediaTransferProtocolManager>
134 media_transfer_protocol_manager_;
135 std::unique_ptr<MediaTransferProtocolDeviceObserverLinux>
136 media_transfer_protocol_device_observer_;
137
138 std::unique_ptr<MtabWatcherLinux, MtabWatcherLinuxDeleter> mtab_watcher_; 126 std::unique_ptr<MtabWatcherLinux, MtabWatcherLinuxDeleter> mtab_watcher_;
139 127
140 base::WeakPtrFactory<StorageMonitorLinux> weak_ptr_factory_; 128 base::WeakPtrFactory<StorageMonitorLinux> weak_ptr_factory_;
141 129
142 DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinux); 130 DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinux);
143 }; 131 };
144 132
145 } // namespace storage_monitor 133 } // namespace storage_monitor
146 134
147 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_ 135 #endif // COMPONENTS_STORAGE_MONITOR_STORAGE_MONITOR_LINUX_H_
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_chromeos_unittest.cc ('k') | components/storage_monitor/storage_monitor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698