| OLD | NEW |
| 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_SYSTEM_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ | 6 #define CHROME_BROWSER_SYSTEM_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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/callback.h" |
| 14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 16 #include "base/string16.h" | 17 #include "base/string16.h" |
| 17 #include "base/system_monitor/system_monitor.h" | |
| 18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
| 19 | 19 |
| 20 namespace chrome { | 20 namespace chrome { |
| 21 | 21 |
| 22 // This class watches the volume mount points and sends notifications to | 22 // This class watches the volume mount points and sends notifications to |
| 23 // base::SystemMonitor about the device attach/detach events. This is a | 23 // base::SystemMonitor about the device attach/detach events. This is a |
| 24 // singleton class instantiated by RemovableDeviceNotificationsWindowWin. | 24 // singleton class instantiated by RemovableDeviceNotificationsWindowWin. |
| 25 class VolumeMountWatcherWin { | 25 class VolumeMountWatcherWin { |
| 26 public: | 26 public: |
| 27 // TODO(gbillock): Take the RemovableStorageNotifications as an argument. |
| 27 VolumeMountWatcherWin(); | 28 VolumeMountWatcherWin(); |
| 28 virtual ~VolumeMountWatcherWin(); | 29 virtual ~VolumeMountWatcherWin(); |
| 29 | 30 |
| 30 // Returns the volume file path of the drive specified by the |drive_number|. | 31 // Returns the volume file path of the drive specified by the |drive_number|. |
| 31 // |drive_number| inputs of 0 - 25 are valid. Returns an empty file path if | 32 // |drive_number| inputs of 0 - 25 are valid. Returns an empty file path if |
| 32 // the |drive_number| is invalid. | 33 // the |drive_number| is invalid. |
| 33 static FilePath DriveNumberToFilePath(int drive_number); | 34 static FilePath DriveNumberToFilePath(int drive_number); |
| 34 | 35 |
| 35 void Init(); | 36 void Init(); |
| 36 | 37 |
| 37 // Gets the information about the device mounted at |device_path|. On success, | 38 // Gets the information about the device mounted at |device_path|. On success, |
| 38 // returns true and fills in |location|, |unique_id|, |name|, and |removable|. | 39 // returns true and fills in |location|, |unique_id|, |name|, and |removable|. |
| 39 // Can block during startup while device info is still loading. | 40 // Can block during startup while device info is still loading. |
| 40 virtual bool GetDeviceInfo(const FilePath& device_path, | 41 virtual bool GetDeviceInfo(const FilePath& device_path, |
| 41 string16* location, | 42 string16* location, |
| 42 std::string* unique_id, | 43 std::string* unique_id, |
| 43 string16* name, | 44 string16* name, |
| 44 bool* removable) const; | 45 bool* removable) const; |
| 45 | 46 |
| 46 // Processes DEV_BROADCAST_VOLUME messages and triggers a SystemMonitor | 47 // Processes DEV_BROADCAST_VOLUME messages and triggers a |
| 47 // notification if appropriate. | 48 // notification if appropriate. |
| 48 void OnWindowMessage(UINT event_type, LPARAM data); | 49 void OnWindowMessage(UINT event_type, LPARAM data); |
| 49 | 50 |
| 50 protected: | 51 protected: |
| 51 struct MountPointInfo { | 52 struct MountPointInfo { |
| 52 std::string device_id; | 53 std::string device_id; |
| 53 string16 location; | 54 string16 location; |
| 54 std::string unique_id; | 55 std::string unique_id; |
| 55 string16 name; | 56 string16 name; |
| 56 bool removable; | 57 bool removable; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 MountPointDeviceMetadataMap device_metadata_; | 108 MountPointDeviceMetadataMap device_metadata_; |
| 108 | 109 |
| 109 base::WeakPtrFactory<VolumeMountWatcherWin> weak_factory_; | 110 base::WeakPtrFactory<VolumeMountWatcherWin> weak_factory_; |
| 110 | 111 |
| 111 DISALLOW_COPY_AND_ASSIGN(VolumeMountWatcherWin); | 112 DISALLOW_COPY_AND_ASSIGN(VolumeMountWatcherWin); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 } // namespace chrome | 115 } // namespace chrome |
| 115 | 116 |
| 116 #endif // CHROME_BROWSER_SYSTEM_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ | 117 #endif // CHROME_BROWSER_SYSTEM_MONITOR_VOLUME_MOUNT_WATCHER_WIN_H_ |
| OLD | NEW |