| Index: chrome/browser/system_monitor/removable_device_notifications_window_win.h
|
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_window_win.h b/chrome/browser/system_monitor/removable_device_notifications_window_win.h
|
| index b05782677af63d7eaf2174182c47b9d159c37b4a..9d00a0e65f3701b9c339f40cf43f83e5db2ae71c 100644
|
| --- a/chrome/browser/system_monitor/removable_device_notifications_window_win.h
|
| +++ b/chrome/browser/system_monitor/removable_device_notifications_window_win.h
|
| @@ -7,61 +7,89 @@
|
|
|
| #include <windows.h>
|
|
|
| +#include <map>
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/file_path.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/system_monitor/system_monitor.h"
|
|
|
| -typedef LRESULT (*VolumeNameFunc)(LPCWSTR drive,
|
| - LPWSTR volume_name,
|
| - unsigned int volume_name_len);
|
| namespace chrome {
|
|
|
| +// Gets device information given a |device_path|. On success, returns true and
|
| +// fills in |unique_id|, |name|, and |removable|.
|
| +typedef bool (*GetDeviceInfoFunc)(const FilePath& device,
|
| + std::wstring* location,
|
| + std::string* unique_id,
|
| + string16* name,
|
| + bool* removable);
|
| +
|
| +// Returns a vector of all the removable devices that are connected.
|
| +typedef std::vector<FilePath> (*GetAttachedDevicesFunc)();
|
| +
|
| class RemovableDeviceNotificationsWindowWin
|
| : public base::RefCountedThreadSafe<RemovableDeviceNotificationsWindowWin> {
|
| public:
|
| RemovableDeviceNotificationsWindowWin();
|
| +
|
| + static RemovableDeviceNotificationsWindowWin* GetInstance();
|
| +
|
| + // Must be called after the file thread is created.
|
| + void Init();
|
| +
|
| + // Finds the device that contains |path| and populates |device_info|.
|
| + // Returns false if unable to find the device.
|
| + bool GetDeviceInfoForPath(
|
| + const FilePath& path,
|
| + base::SystemMonitor::RemovableStorageInfo* device_info);
|
| +
|
| + protected:
|
| // Only for use in unit tests.
|
| - explicit RemovableDeviceNotificationsWindowWin(VolumeNameFunc volumeNameFunc);
|
| + void Init(GetDeviceInfoFunc getDeviceInfo,
|
| + GetAttachedDevicesFunc getAttachedDevices);
|
|
|
| - LRESULT OnDeviceChange(UINT event_type, DWORD data);
|
| + void OnDeviceChange(UINT event_type, DWORD data);
|
|
|
| private:
|
| friend class
|
| base::RefCountedThreadSafe<RemovableDeviceNotificationsWindowWin>;
|
| + friend class TestRemovableDeviceNotificationsWindowWin;
|
| +
|
| + typedef std::map<FilePath, std::string> MountPointDeviceIdMap;
|
|
|
| virtual ~RemovableDeviceNotificationsWindowWin();
|
|
|
| - void Init();
|
| + static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
|
| + LPARAM lparam);
|
|
|
| - LRESULT CALLBACK WndProc(HWND hwnd,
|
| - UINT message,
|
| - WPARAM wparam,
|
| + LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
|
| LPARAM lparam);
|
|
|
| - static LRESULT CALLBACK WndProcThunk(HWND hwnd,
|
| - UINT message,
|
| - WPARAM wparam,
|
| - LPARAM lparam);
|
| + void DoInit(GetAttachedDevicesFunc get_attached_devices_func);
|
| +
|
| + void AddNewDevice(const FilePath& device_path);
|
|
|
| - void CheckDeviceTypeOnFileThread(const std::string& id,
|
| + void CheckDeviceTypeOnFileThread(const std::string& unique_id,
|
| const FilePath::StringType& device_name,
|
| - const FilePath& path);
|
| + const FilePath& device);
|
|
|
| - void ProcessRemovableDeviceAttachedOnUIThread(
|
| - const std::string& id,
|
| + void ProcessDeviceAttachedOnUIThread(
|
| + const std::string& device_id,
|
| const FilePath::StringType& device_name,
|
| - const FilePath& path);
|
| + const FilePath& device);
|
|
|
| // The window class of |window_|.
|
| - ATOM atom_;
|
| -
|
| + ATOM window_class_;
|
| // The handle of the module that contains the window procedure of |window_|.
|
| HMODULE instance_;
|
| -
|
| HWND window_;
|
| - VolumeNameFunc volume_name_func_;
|
| +
|
| + GetDeviceInfoFunc get_device_info_func_;
|
| +
|
| + // A map from device mount point to device id. Only accessed on the UI Thread.
|
| + MountPointDeviceIdMap device_ids_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin);
|
| };
|
|
|