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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 6#define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 7 8#include "base/basictypes.h" 9#include "base/memory/ref_counted.h" 10#include "base/memory/scoped_ptr.h" 11#include "chrome/browser/storage_monitor/storage_monitor.h" 12 13namespace base { 14class FilePath; 15} 16 17namespace chrome { 18 19namespace test { 20class TestStorageMonitorWin; 21} 22 23class PortableDeviceWatcherWin; 24class VolumeMountWatcherWin; 25 26class StorageMonitorWin : public StorageMonitor { 27 public: 28 virtual ~StorageMonitorWin(); 29 30 // Must be called after the file thread is created. 31 virtual void Init() OVERRIDE; 32 33 // StorageMonitor: 34 virtual bool GetStorageInfoForPath(const base::FilePath& path, 35 StorageInfo* device_info) const OVERRIDE; 36 virtual bool GetMTPStorageInfoFromDeviceId( 37 const std::string& storage_device_id, 38 base::string16* device_location, 39 base::string16* storage_object_id) const OVERRIDE; 40 41 virtual void EjectDevice( 42 const std::string& device_id, 43 base::Callback<void(EjectStatus)> callback) OVERRIDE; 44 45 private: 46 class PortableDeviceNotifications; 47 friend class test::TestStorageMonitorWin; 48 friend StorageMonitor* StorageMonitor::Create(); 49 50 // To support unit tests, this constructor takes |volume_mount_watcher| and 51 // |portable_device_watcher| objects. These params are either constructed in 52 // unit tests or in StorageMonitorWin Create() function. 53 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher, 54 PortableDeviceWatcherWin* portable_device_watcher); 55 56 // Gets the removable storage information given a |device_path|. On success, 57 // returns true and fills in |info|. 58 bool GetDeviceInfo(const base::FilePath& device_path, 59 StorageInfo* info) const; 60 61 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, 62 LPARAM lparam); 63 64 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, 65 LPARAM lparam); 66 67 void OnDeviceChange(UINT event_type, LPARAM data); 68 69 // The window class of |window_|. 70 ATOM window_class_; 71 72 // The handle of the module that contains the window procedure of |window_|. 73 HMODULE instance_; 74 HWND window_; 75 76 // The volume mount point watcher, used to manage the mounted devices. 77 scoped_ptr<VolumeMountWatcherWin> volume_mount_watcher_; 78 79 // The portable device watcher, used to manage media transfer protocol 80 // devices. 81 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; 82 83 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); 84}; 85 86} // namespace chrome 87 88#endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 89