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

Side by Side Diff: chrome/browser/storage_monitor/volume_mount_watcher_win.h

Issue 16056002: Cleanup Various bits of Windows StorageMonitor classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 #ifndef CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ 6 #define CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 // Returns the volume file path of the drive specified by the |drive_number|. 37 // Returns the volume file path of the drive specified by the |drive_number|.
38 // |drive_number| inputs of 0 - 25 are valid. Returns an empty file path if 38 // |drive_number| inputs of 0 - 25 are valid. Returns an empty file path if
39 // the |drive_number| is invalid. 39 // the |drive_number| is invalid.
40 static base::FilePath DriveNumberToFilePath(int drive_number); 40 static base::FilePath DriveNumberToFilePath(int drive_number);
41 41
42 void Init(); 42 void Init();
43 43
44 // Gets the information about the device mounted at |device_path|. On success, 44 // Gets the information about the device mounted at |device_path|. On success,
45 // returns true and fills in |info|. 45 // returns true and fills in |info|.
46 // Can block during startup while device info is still loading. 46 // Can block during startup while device info is still loading.
47 virtual bool GetDeviceInfo(const base::FilePath& device_path, 47 bool GetDeviceInfo(const base::FilePath& device_path,
48 StorageInfo* info) const; 48 StorageInfo* info) const;
49 49
50 // Processes DEV_BROADCAST_VOLUME messages and triggers a 50 // Processes DEV_BROADCAST_VOLUME messages and triggers a
51 // notification if appropriate. 51 // notification if appropriate.
52 void OnWindowMessage(UINT event_type, LPARAM data); 52 void OnWindowMessage(UINT event_type, LPARAM data);
53 53
54 // Set the volume notifications object to be used when new 54 // Set the volume notifications object to be used when new
55 // removable volumes are found. 55 // removable volumes are found.
56 void SetNotifications(StorageMonitor::Receiver* notifications); 56 void SetNotifications(StorageMonitor::Receiver* notifications);
57 57
58 void EjectDevice(const std::string& device_id, 58 void EjectDevice(const std::string& device_id,
59 base::Callback<void(StorageMonitor::EjectStatus)> callback); 59 base::Callback<void(StorageMonitor::EjectStatus)> callback);
60 60
61 protected: 61 protected:
62 typedef base::Callback<bool(const base::FilePath&, 62 typedef base::Callback<bool(const base::FilePath&,
63 StorageInfo*)> GetDeviceDetailsCallbackType; 63 StorageInfo*)> GetDeviceDetailsCallbackType;
64 64
65 typedef base::Callback<std::vector<base::FilePath>(void)> 65 typedef base::Callback<std::vector<base::FilePath>(void)>
66 GetAttachedDevicesCallbackType; 66 GetAttachedDevicesCallbackType;
67 67
68 // Handles mass storage device attach event on UI thread. 68 // Handles mass storage device attach event on UI thread.
69 void HandleDeviceAttachEventOnUIThread( 69 void HandleDeviceAttachEventOnUIThread(
70 const base::FilePath& device_path, 70 const base::FilePath& device_path,
71 const StorageInfo& info); 71 const StorageInfo& info);
72 72
73 // Handles mass storage device detach event on UI thread. 73 // Handles mass storage device detach event on UI thread.
74 void HandleDeviceDetachEventOnUIThread(const string16& device_location); 74 void HandleDeviceDetachEventOnUIThread(const base::string16& device_location);
75 75
76 // UI thread delegate to set up adding storage devices. 76 // UI thread delegate to set up adding storage devices.
77 void AddDevicesOnUIThread(std::vector<base::FilePath> removable_devices); 77 void AddDevicesOnUIThread(std::vector<base::FilePath> removable_devices);
78 78
79 // Runs |get_device_details_callback| for |device_path| on a worker thread. 79 // Runs |get_device_details_callback| for |device_path| on a worker thread.
80 // |volume_watcher| points back to the VolumeMountWatcherWin that called it. 80 // |volume_watcher| points back to the VolumeMountWatcherWin that called it.
81 static void RetrieveInfoForDeviceAndAdd( 81 static void RetrieveInfoForDeviceAndAdd(
82 const base::FilePath& device_path, 82 const base::FilePath& device_path,
83 const GetDeviceDetailsCallbackType& get_device_details_callback, 83 const GetDeviceDetailsCallbackType& get_device_details_callback,
84 base::WeakPtr<chrome::VolumeMountWatcherWin> volume_watcher); 84 base::WeakPtr<VolumeMountWatcherWin> volume_watcher);
85 85
86 // Mark that a device we started a metadata check for has completed. 86 // Mark that a device we started a metadata check for has completed.
87 virtual void DeviceCheckComplete(const base::FilePath& device_path); 87 virtual void DeviceCheckComplete(const base::FilePath& device_path);
88 88
89 virtual GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const; 89 virtual GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const;
90 virtual GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const; 90 virtual GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const;
91 91
92 // Worker pool used to collect device information. Used because some 92 // Worker pool used to collect device information. Used because some
93 // devices freeze workers trying to get device info, resulting in 93 // devices freeze workers trying to get device info, resulting in
94 // shutdown hangs. 94 // shutdown hangs.
95 scoped_refptr<base::SequencedWorkerPool> device_info_worker_pool_; 95 scoped_refptr<base::SequencedWorkerPool> device_info_worker_pool_;
96 scoped_refptr<base::SequencedTaskRunner> task_runner_; 96 scoped_refptr<base::SequencedTaskRunner> task_runner_;
97 97
98 private: 98 private:
99 friend class test::TestVolumeMountWatcherWin; 99 friend class test::TestVolumeMountWatcherWin;
100 100
101 // Key: Mass storage device mount point. 101 // Key: Mass storage device mount point.
102 // Value: Mass storage device metadata. 102 // Value: Mass storage device metadata.
103 typedef std::map<string16, StorageInfo> MountPointDeviceMetadataMap; 103 typedef std::map<base::string16, StorageInfo> MountPointDeviceMetadataMap;
104 104
105 // Maintain a set of device attribute check calls in-flight. Only accessed 105 // Maintain a set of device attribute check calls in-flight. Only accessed
106 // on the UI thread. This is to try and prevent the same device from 106 // on the UI thread. This is to try and prevent the same device from
107 // occupying our worker pool in case of windows API call hangs. 107 // occupying our worker pool in case of windows API call hangs.
108 std::set<base::FilePath> pending_device_checks_; 108 std::set<base::FilePath> pending_device_checks_;
109 109
110 // A map from device mount point to device metadata. Only accessed on the UI 110 // A map from device mount point to device metadata. Only accessed on the UI
111 // thread. 111 // thread.
112 MountPointDeviceMetadataMap device_metadata_; 112 MountPointDeviceMetadataMap device_metadata_;
113 113
114 base::WeakPtrFactory<VolumeMountWatcherWin> weak_factory_; 114 base::WeakPtrFactory<VolumeMountWatcherWin> weak_factory_;
115 115
116 // The notifications object to use to signal newly attached volumes. Only 116 // The notifications object to use to signal newly attached volumes. Only
117 // removable devices will be notified. 117 // removable devices will be notified.
118 StorageMonitor::Receiver* notifications_; 118 StorageMonitor::Receiver* notifications_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(VolumeMountWatcherWin); 120 DISALLOW_COPY_AND_ASSIGN(VolumeMountWatcherWin);
121 }; 121 };
122 122
123 } // namespace chrome 123 } // namespace chrome
124 124
125 #endif // CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ 125 #endif // CHROME_BROWSER_STORAGE_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698